Skip to content

Commit

Permalink
MAKE THE ADDON WORK ON 1.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
HerXayah committed Sep 11, 2024
1 parent a1caf7c commit f0a534b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "de.funkeln.pronouns"
version = System.getenv().getOrDefault("VERSION", "1.0.5")
version = System.getenv().getOrDefault("VERSION", "1.0.6")

labyMod {
defaultPackageName = "de.funkeln.pronouns" //change this to your main package name (used by all modules)
Expand All @@ -14,7 +14,7 @@ labyMod {
displayName = "PronounsDisplay"
author = "funkeln"
description = "Display your Pronouns from pronouns.page ingame"
minecraftVersion = "1.20.1<*"
minecraftVersion = "*"
version = getVersion().toString()
}

Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.1.0"
version = "0.1.6"

plugins {
id("java-library")
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/com/funkeln/pronouns/PronounAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ protected void enable() {

public void publishNameUpdate() {
String newName = configuration().name().get();
logger().info("Publishing name change to " + newName);
logger().info("Publishing pronoun name change to " + newName);
JsonObject data = new JsonObject();
data.addProperty("name", newName
);
data.addProperty("name", newName);
labyAPI().labyConnect().getSession().sendBroadcastPayload("pronouns", data);
ProfileRepository.clearExpired();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public FlagNameTag(RectangleRenderer rectangleRenderer) {
return null;
}

Icon[] flags = myFlags();
if (flags == null || flags.length == 0) {
return null;
}

return RenderableComponent.of(component, alignment);
} else {
return null;
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/com/funkeln/pronouns/profile/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public void update() {
URL url = new URI(API_URL + "profile/get/" + websiteName + "?version=2").toURL();
JsonObject profile = null;
try (InputStream stream = url.openStream()) {
JsonElement element = JsonParser.parseReader(new InputStreamReader(stream));
// Deprecated API usage is required as static methods do not exist in gson 2.2.4
// noinspection deprecation
JsonElement element = new JsonParser().parse(new InputStreamReader(stream));
profile = element.getAsJsonObject();
}
updatePronouns(pronounFromJson(profile));
Expand All @@ -83,7 +85,9 @@ public boolean requiresUpdateNow() {

public static String pronounFromJson(JsonObject profile) {
JsonArray pronounsArray = profile.getAsJsonObject("profiles").getAsJsonObject("en").getAsJsonArray("pronouns");
if (pronounsArray == null || pronounsArray.isEmpty()) return null;
// JsonArray#isEmpty() doesn't exist in 2.2.4
//noinspection SizeReplaceableByIsEmpty
if (pronounsArray == null || pronounsArray.size() == 0) return null;
List<String> outputPronounList = new ArrayList<>();
for(JsonElement pronoun : pronounsArray) {
outputPronounList.add(pronoun.getAsJsonObject().get("value").getAsString());
Expand All @@ -104,7 +108,9 @@ public static List<String> flagNamesFromJson(JsonObject profile) {
return null;
}
JsonArray flagsArray = enProfile.getAsJsonArray("flags");
if (flagsArray == null || flagsArray.isEmpty()) {
// JsonArray#isEmpty() doesn't exist in 2.2.4
//noinspection SizeReplaceableByIsEmpty
if (flagsArray == null || flagsArray.size() == 0) {
return null;
}
List<String> flagNamesList = new ArrayList<>();
Expand Down

0 comments on commit f0a534b

Please sign in to comment.