diff --git a/build.gradle.kts b/build.gradle.kts index 891d5b7..c7000b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ group = "de.funkeln.pronouns" version = System.getenv().getOrDefault("VERSION", "1.0.0") labyMod { - defaultPackageName = "de.funkeln" //change this to your main package name (used by all modules) + defaultPackageName = "de.funkeln.pronouns" //change this to your main package name (used by all modules) addonInfo { namespace = "pronouns" displayName = "PronounsDisplay" diff --git a/core/src/main/java/com/funkeln/pronouns/PronounAddon.java b/core/src/main/java/com/funkeln/pronouns/PronounAddon.java index 5c26eb3..bdb0611 100644 --- a/core/src/main/java/com/funkeln/pronouns/PronounAddon.java +++ b/core/src/main/java/com/funkeln/pronouns/PronounAddon.java @@ -32,21 +32,20 @@ public static PronounAddon getInstance() { return INSTANCE; } - @Override protected void enable() { INSTANCE = this; this.registerSettingCategory(); if(this.configuration().enabled().get()) { if(configuration().name().get().isEmpty()) { - meow = labyAPI().minecraft().getClientPlayer().getName(); + meow = labyAPI().minecraft().getClientPlayer().getName().trim(); } else { meow = configuration().name().get().trim(); } - displayMessage(meow); PronounsAPI.addProfileFetchListener(meow, new ProfileFetchListener() { @Override public void onProfileFetched(Profile profile) { + log.info("Fetched profile for " + meow); pronoun = profile.getPronoun().trim(); } diff --git a/core/src/main/java/com/funkeln/pronouns/PronounConfiguration.java b/core/src/main/java/com/funkeln/pronouns/PronounConfiguration.java index 67574c7..cbfd7f8 100644 --- a/core/src/main/java/com/funkeln/pronouns/PronounConfiguration.java +++ b/core/src/main/java/com/funkeln/pronouns/PronounConfiguration.java @@ -13,11 +13,25 @@ public class PronounConfiguration extends AddonConfig { @SwitchSetting private final ConfigProperty enabled = new ConfigProperty<>(true); + @SwitchSetting + private final ConfigProperty renderFlags = new ConfigProperty<>(true); + + @SwitchSetting + private final ConfigProperty renderTag = new ConfigProperty<>(true); + @Override public ConfigProperty enabled() { return this.enabled; } + public ConfigProperty renderTag() { + return this.renderTag; + } + + public ConfigProperty renderFlags() { + return this.renderFlags; + } + @TextFieldSetting private final ConfigProperty name = new ConfigProperty<>(""); diff --git a/core/src/main/java/com/funkeln/pronouns/nametag/FlagNameTag.java b/core/src/main/java/com/funkeln/pronouns/nametag/FlagNameTag.java index f81d619..6bb6072 100644 --- a/core/src/main/java/com/funkeln/pronouns/nametag/FlagNameTag.java +++ b/core/src/main/java/com/funkeln/pronouns/nametag/FlagNameTag.java @@ -41,10 +41,15 @@ public FlagNameTag(RectangleRenderer rectangleRenderer) { alignment = HorizontalAlignment.CENTER; PronounAddon addon = PronounAddon.getInstance(); + if (!addon.configuration().enabled().get()) { return null; } + if (!addon.configuration().renderFlags().get()) { + return null; + } + Component component = Component.empty(); if (component == null) { return null; diff --git a/core/src/main/java/com/funkeln/pronouns/nametag/PronounNameTag.java b/core/src/main/java/com/funkeln/pronouns/nametag/PronounNameTag.java index 67aee6a..57b5594 100644 --- a/core/src/main/java/com/funkeln/pronouns/nametag/PronounNameTag.java +++ b/core/src/main/java/com/funkeln/pronouns/nametag/PronounNameTag.java @@ -46,6 +46,10 @@ public PronounNameTag(RenderPipeline renderPipeline, RectangleRenderer rectangle return null; } + if (!addon.configuration().renderTag().get()) { + return null; + } + Component component = Component.text(PronounAddon.getInstance().pronoun); if (component == null) { return null; diff --git a/core/src/main/java/com/funkeln/pronouns/utils/PronounsAPI.java b/core/src/main/java/com/funkeln/pronouns/utils/PronounsAPI.java index c37a0f4..a6522ea 100644 --- a/core/src/main/java/com/funkeln/pronouns/utils/PronounsAPI.java +++ b/core/src/main/java/com/funkeln/pronouns/utils/PronounsAPI.java @@ -27,7 +27,6 @@ public static void addProfileFetchListener(String username, ProfileFetchListener listeners.put(username, listener); } - public static PronounsAPI getInstance() { if (instance == null) { instance = new PronounsAPI(); @@ -108,7 +107,6 @@ public static Icon[] getFlags(JsonObject profile) { try { URL iconURL = new URL(url); Icon icon = Icon.url(String.valueOf(iconURL)); - Laby.labyAPI().minecraft().chatExecutor().displayClientMessage(icon.getUrl()); flagsList.add(icon); flagNamesList.add(flag.getAsString()); } catch (Exception e) { diff --git a/core/src/main/resources/assets/pronouns/i18n/en_us.json b/core/src/main/resources/assets/pronouns/i18n/en_us.json index e7a4980..e5f6461 100644 --- a/core/src/main/resources/assets/pronouns/i18n/en_us.json +++ b/core/src/main/resources/assets/pronouns/i18n/en_us.json @@ -1,11 +1,29 @@ { - "example": { + "pronouns": { "settings": { "enabled": { - "name": "Enabled" + "name": "Addon enabled?" }, "name": { - "name": "pronouns.page Username" + "name": "pronouns.page Username", + "description": "The pronouns.page username of the player", + "type": "text", + "value": "player", + "default": "" + }, + "renderFlags": { + "name": "Render Flags", + "description": "Render the flags of the player", + "default": "true", + "type": "boolean", + "value": "true" + }, + "renderTag": { + "name": "Render Tag", + "description": "Render the tag of the player", + "default": "true", + "type": "boolean", + "value": "true" } } }