Skip to content

Commit

Permalink
Removed debug and added translations
Browse files Browse the repository at this point in the history
  • Loading branch information
HerXayah committed Sep 8, 2024
1 parent 5013d67 commit 1018d55
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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 @@ -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();
}

Expand Down
14 changes: 14 additions & 0 deletions core/src/main/java/com/funkeln/pronouns/PronounConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ public class PronounConfiguration extends AddonConfig {
@SwitchSetting
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);

@SwitchSetting
private final ConfigProperty<Boolean> renderFlags = new ConfigProperty<>(true);

@SwitchSetting
private final ConfigProperty<Boolean> renderTag = new ConfigProperty<>(true);

@Override
public ConfigProperty<Boolean> enabled() {
return this.enabled;
}

public ConfigProperty<Boolean> renderTag() {
return this.renderTag;
}

public ConfigProperty<Boolean> renderFlags() {
return this.renderFlags;
}

@TextFieldSetting
private final ConfigProperty<String> name = new ConfigProperty<>("");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 21 additions & 3 deletions core/src/main/resources/assets/pronouns/i18n/en_us.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Expand Down

0 comments on commit 1018d55

Please sign in to comment.