diff options
author | hackthetime <l4bg0jb7@duck.com> | 2023-10-09 17:27:52 +0200 |
---|---|---|
committer | hackthetime <l4bg0jb7@duck.com> | 2023-10-09 17:27:52 +0200 |
commit | a8ae900fbf06face41fabc428247c852f1fa0e1d (patch) | |
tree | e646082e9b3b8ddb3d2e57d9eba66bede5b77c07 /src/main/java | |
parent | d4ada83ec3e7416bbac10c7d79a9ac5a0f939de6 (diff) | |
download | BBsentials-a8ae900fbf06face41fabc428247c852f1fa0e1d.tar.gz BBsentials-a8ae900fbf06face41fabc428247c852f1fa0e1d.tar.bz2 BBsentials-a8ae900fbf06face41fabc428247c852f1fa0e1d.zip |
experiments with conditions in config
Diffstat (limited to 'src/main/java')
3 files changed, 37 insertions, 18 deletions
diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java index 63dc8f1..fe51139 100644 --- a/src/main/java/de/hype/bbsentials/client/BBsentials.java +++ b/src/main/java/de/hype/bbsentials/client/BBsentials.java @@ -252,4 +252,10 @@ public class BBsentials implements ClientModInitializer { }); } } // KeyBinds + + public void manualLoad() { + initialised = true; + config = Config.load(); + connectToBBserver(); + } }
\ No newline at end of file diff --git a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java index dc521f2..831b22d 100644 --- a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java +++ b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java @@ -4,6 +4,10 @@ import de.hype.bbsentials.constants.enviromentShared.Islands; import me.shedaniel.clothconfig2.api.ConfigBuilder; import me.shedaniel.clothconfig2.api.ConfigCategory; import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import me.shedaniel.clothconfig2.api.Requirement; +import me.shedaniel.clothconfig2.gui.entries.BooleanListEntry; +import me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry; +import me.shedaniel.clothconfig2.gui.entries.StringListEntry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.NoticeScreen; import net.minecraft.client.gui.screen.Screen; @@ -46,7 +50,6 @@ public class BBsentialsConfigScreemFactory { .setSaveConsumer(newValue -> config.bbServerURL = newValue) .build()); } - server.addEntry(entryBuilder.startStrField(Text.of("BBsentials API key"), config.apiKey.replaceAll(".", "*")) .setDefaultValue("unset") .setTooltip(Text.of("Put you API Key here (the one generated in the Discord! with /link). §cThe Text is visually censored. Not saved unless you changed it.")) @@ -88,23 +91,31 @@ public class BBsentialsConfigScreemFactory { .build()); //Notifications ConfigCategory notifications = builder.getOrCreateCategory(Text.of("Notifications")); - notifications.addEntry(entryBuilder.startBooleanToggle(Text.of("Do Desktop Notifications"), config.doDesktopNotifications) + BooleanListEntry doNotifications = entryBuilder.startBooleanToggle(Text.of("Do Desktop Notifications"), config.doDesktopNotifications) .setDefaultValue(true) .setTooltip(Text.of("Select if you want BBsentials to automatically accept reparties")) .setSaveConsumer(newValue -> config.doDesktopNotifications = newValue) - .build()); - notifications.addEntry(entryBuilder.startStrField(Text.of("Nickname"), config.nickname) - .setDefaultValue("") - .setTooltip(Text.of("Nickname. you will get send desktop notifications if a message contains one")) - .setSaveConsumer(newValue -> config.nickname = newValue) - .build()); - notifications.addEntry(entryBuilder.startStringDropdownMenu(Text.of("Notification on"), config.NotifForPartyMessagesType) // Start the StringDropdownMenu entry + .build(); + DropdownBoxEntry<String> notificationOn = entryBuilder.startStringDropdownMenu(Text.of("Notification on"), config.notifForMessagesType) // Start the StringDropdownMenu entry .setSelections(List.of("all", "nick", "none")) - .setTooltip(Text.of("When do you want to receive Desktop Notifications? on all party, party messages containing nickname or no party messages")) + .setTooltip(Text.of("When do you want to receive Desktop Notifications? on all party, messages containing nickname")) .setDefaultValue("all") + .setRequirement(Requirement.isTrue(doNotifications)) .setSuggestionMode(false) - .setSaveConsumer(newValue -> config.NotifForPartyMessagesType = newValue) - .build()); + .setSaveConsumer(newValue -> config.notifForMessagesType = newValue) + .build(); + StringListEntry nickname = entryBuilder.startStrField(Text.of("Nickname"), config.nickname) + .setDefaultValue("") + .setTooltip(Text.of("Nickname. you will get send desktop notifications if a message contains one")) + .setRequirement(() -> { + return doNotifications.getValue() && notificationOn.getValue().equals("nick"); + }) + .setSaveConsumer(newValue -> config.nickname = newValue) + .build(); + + notifications.addEntry(doNotifications); + notifications.addEntry(notificationOn); + notifications.addEntry(nickname); //other ConfigCategory other = builder.getOrCreateCategory(Text.of("Other")); other.addEntry(entryBuilder.startBooleanToggle(Text.of("Gamma Override"), config.doGammaOverride) @@ -124,11 +135,13 @@ public class BBsentialsConfigScreemFactory { .build()); ConfigCategory chChestItems = builder.getOrCreateCategory(Text.of("Ch Chest Items")); { - chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("All Chest Items"), config.toDisplayConfig.allChChestItem) + + BooleanListEntry allItems = entryBuilder.startBooleanToggle(Text.of("All Chest Items"), config.toDisplayConfig.allChChestItem) .setDefaultValue(true) .setTooltip(Text.of("Select to receive notifications when an any Item is found")) .setSaveConsumer(newValue -> config.toDisplayConfig.allChChestItem = newValue) - .build()); + .build(); + chChestItems.addEntry(allItems); chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("ALL Robo Parts "), config.toDisplayConfig.allRoboPart) .setDefaultValue(false) diff --git a/src/main/java/de/hype/bbsentials/client/Config.java b/src/main/java/de/hype/bbsentials/client/Config.java index 9c62d2e..5598872 100644 --- a/src/main/java/de/hype/bbsentials/client/Config.java +++ b/src/main/java/de/hype/bbsentials/client/Config.java @@ -43,7 +43,7 @@ public class Config implements Serializable { public boolean acceptReparty; public boolean autoSplashStatusUpdates; public String nickname; - public String NotifForPartyMessagesType; + public String notifForMessagesType; // Set default attribute values private void setDefaults() { @@ -51,12 +51,12 @@ public class Config implements Serializable { acceptReparty = true; if (username.equals("Hype_the_Time")) { nickname = "Hype"; - NotifForPartyMessagesType = "nick"; + notifForMessagesType = "nick"; doDesktopNotifications=true; } //Gimmic for Developer due too things which dont make it into releases (bugs) else { nickname = ""; - NotifForPartyMessagesType = "none"; + notifForMessagesType = "none"; } } @@ -128,7 +128,7 @@ public class Config implements Serializable { } public String getNotifForParty() { - return NotifForPartyMessagesType; + return notifForMessagesType; } public boolean isDevModeEnabled() { |