From 2fbf623b1bfc51c4576a02bf8b02413d718cf514 Mon Sep 17 00:00:00 2001 From: HacktheTime Date: Sun, 17 Sep 2023 18:55:08 +0200 Subject: extended the mod menu to mining events and chchests --- .../java/de/hype/bbsentials/client/BBsentials.java | 10 +- .../client/BBsentialsConfigScreemFactory.java | 180 +++++++++++++++++++-- .../java/de/hype/bbsentials/client/Config.java | 5 +- .../de/hype/bbsentials/client/ModMenuConfig.java | 4 - .../de/hype/bbsentials/client/ToDisplayConfig.java | 51 +++--- 5 files changed, 207 insertions(+), 43 deletions(-) delete mode 100644 src/main/java/de/hype/bbsentials/client/ModMenuConfig.java (limited to 'src/main/java/de/hype/bbsentials/client') diff --git a/src/main/java/de/hype/bbsentials/client/BBsentials.java b/src/main/java/de/hype/bbsentials/client/BBsentials.java index 10bca46..6641c10 100644 --- a/src/main/java/de/hype/bbsentials/client/BBsentials.java +++ b/src/main/java/de/hype/bbsentials/client/BBsentials.java @@ -151,7 +151,7 @@ public class BBsentials implements ClientModInitializer { return 1; }))) ); - }); //bbi} + }); //bbi if (Config.isBingoTime() || config.overrideBingoTime()) { connectToBBserver(); } @@ -161,6 +161,14 @@ public class BBsentials implements ClientModInitializer { } { + KeyBinding devKeyBind = new KeyBinding("Open Mod Menu Config", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_KP_ADD, "BBsentials: Developing Tools"); + KeyBindingHelper.registerKeyBinding(devKeyBind); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + if (devKeyBind.wasPressed()) { + MinecraftClient.getInstance().setScreen(BBsentialsConfigScreemFactory.create(MinecraftClient.getInstance().currentScreen)); + } + }); + KeyBinding promptKeyBind = new KeyBinding("Chat Prompt Yes / Open Menu", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_R, "BBsentials"); KeyBindingHelper.registerKeyBinding(promptKeyBind); ClientTickEvents.END_CLIENT_TICK.register(client -> { diff --git a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java index c4900ec..4719557 100644 --- a/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java +++ b/src/main/java/de/hype/bbsentials/client/BBsentialsConfigScreemFactory.java @@ -1,5 +1,6 @@ package de.hype.bbsentials.client; +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; @@ -18,15 +19,39 @@ public class BBsentialsConfigScreemFactory { //builder.setSavingRunnable(BBsentials.getConfig()::save); ConfigEntryBuilder entryBuilder = builder.entryBuilder(); ConfigCategory server = builder.getOrCreateCategory(Text.of("Server")); - server.addEntry(entryBuilder.startStrField(Text.of("Server URL"), config.getBBServerURL()) - .setDefaultValue("localhost") - .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) - .setSaveConsumer(newValue -> config.bbServerURL = newValue) - .build()); - server.addEntry(entryBuilder.startStrField(Text.of("BBsentials API key"), config.apiKey) + if (config.getUsername().equalsIgnoreCase("Hype_the_Time")) { + server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), config.getBBServerURL().replaceAll(".", "*")) + .setDefaultValue("localhost") + .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) + .setSaveConsumer((newValue) -> { + if (newValue.replace("*", "").trim().isEmpty()) { + return; + } + else { + config.bbServerURL = newValue; + } + }) + .build()); + } + else { + server.addEntry(entryBuilder.startTextField(Text.of("Server URL"), config.getBBServerURL()) + .setDefaultValue("localhost") + .setTooltip(Text.of("Place the Server URL of the BBsentials Server here")) + .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)")) - .setSaveConsumer(newValue -> config.apiKey = newValue) + .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.")) + .setSaveConsumer((newValue) -> { + if (newValue.replace("*", "").trim().isEmpty()) { + return; + } + else { + config.apiKey = newValue; + } + }) .build()); server.addEntry(entryBuilder.startBooleanToggle(Text.of("Connect to Test Server"), config.connectToBeta) .setDefaultValue(false) @@ -61,7 +86,7 @@ public class BBsentialsConfigScreemFactory { .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")) .setDefaultValue("all") - .setSuggestionMode(true) + .setSuggestionMode(false) .setSaveConsumer(newValue -> config.NotifForPartyMessagesType = newValue) .build()); //other @@ -71,8 +96,145 @@ public class BBsentialsConfigScreemFactory { .setTooltip(Text.of("Select if you want BBsentials to automatically accept reparties")) .setSaveConsumer(newValue -> config.showBingoChat = newValue) .build()); + other.addEntry(entryBuilder.startBooleanToggle(Text.of("Accept auto invite"), config.allowBBinviteMe) + .setDefaultValue(true) + .setTooltip(Text.of("Do you want that whenever someone sends you a msg ending with 'bb:party me' to send them a party invite automatically?")) + .setSaveConsumer(newValue -> config.allowBBinviteMe = newValue) + .build()); + ConfigCategory chChestItems = builder.getOrCreateCategory(Text.of("Ch Chest Items")); + { + chChestItems.addEntry(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()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("ALL Robo Parts "), config.toDisplayConfig.allRoboPart) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when an allRoboPartCustomChChestItem is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.allRoboPart = newValue) + .build()); + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Custom (Other) Items"), config.toDisplayConfig.customChChestItem) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when any not already defined Item is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.customChChestItem = newValue) + .build()); + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Prehistoric Egg"), config.toDisplayConfig.prehistoricEgg) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Prehistoric Egg is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.prehistoricEgg = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Pickonimbus 2000"), config.toDisplayConfig.pickonimbus2000) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Pickonimbus 2000 is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.pickonimbus2000 = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Control Switch"), config.toDisplayConfig.controlSwitch) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Control Switch is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.controlSwitch = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Electron Transmitter"), config.toDisplayConfig.electronTransmitter) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when an Electron Transmitter is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.electronTransmitter = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("FTX 3070"), config.toDisplayConfig.ftx3070) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a FTX 3070 is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.ftx3070 = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Robotron Reflector"), config.toDisplayConfig.robotronReflector) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Robotron Reflector is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.robotronReflector = newValue) + .build()); + + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Superlite Motor"), config.toDisplayConfig.superliteMotor) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Superlite Motor is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.superliteMotor = newValue) + .build()); + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Synthetic Heart"), config.toDisplayConfig.syntheticHeart) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when a Synthetic Heart is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.syntheticHeart = newValue) + .build()); + chChestItems.addEntry(entryBuilder.startBooleanToggle(Text.of("Flawless Gemstone"), config.toDisplayConfig.flawlessGemstone) + .setDefaultValue(false) + .setTooltip(Text.of("Select to receive notifications when any Flawless Gemstone is found")) + .setSaveConsumer(newValue -> config.toDisplayConfig.flawlessGemstone = newValue) + .build()); + }//CHChestItems + ConfigCategory miningEvents = builder.getOrCreateCategory(Text.of("Mining Events")); + { + miningEvents.addEntry(entryBuilder.startBooleanToggle(Text.of("All Events"), config.toDisplayConfig.allEvents) + .setDefaultValue(true) + .setTooltip(Text.of("Get updated for any Mining Event")) + .setSaveConsumer(newValue -> config.toDisplayConfig.allEvents = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startBooleanToggle(Text.of("§cBlock Crystal Hollow Events"), config.toDisplayConfig.blockChEvents) + .setDefaultValue(false) + .setTooltip(Text.of("Block getting Crystal Hollow Events. Maybe if you haven't accessed Crystal Hollows yet ")) + .setSaveConsumer(newValue -> config.toDisplayConfig.blockChEvents = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startStringDropdownMenu(Text.of("Gone with the Wind"), config.toDisplayConfig.goneWithTheWind) // Start the StringDropdownMenu entry + .setSelections(List.of("both", Islands.DWARVEN_MINES.getDisplayName(), Islands.CRYSTAL_HOLLOWS.getDisplayName(), "none")) + .setTooltip(Text.of("Get notified when a Gone with the Wind happens in the specified Island")) + .setDefaultValue("none") + .setSuggestionMode(false) + .setSaveConsumer(newValue -> config.toDisplayConfig.goneWithTheWind = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startStringDropdownMenu(Text.of("Better Together"), config.toDisplayConfig.betterTogether) // Start the StringDropdownMenu entry + .setSelections(List.of("both", Islands.DWARVEN_MINES.getDisplayName(), Islands.CRYSTAL_HOLLOWS.getDisplayName(), "none")) + .setTooltip(Text.of("Get notified when a Better Together happens in the specified Island")) + .setDefaultValue("none") + .setSuggestionMode(false) + .setSaveConsumer(newValue -> config.toDisplayConfig.betterTogether = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startStringDropdownMenu(Text.of("Double Powder"), config.toDisplayConfig.doublePowder) // Start the StringDropdownMenu entry + .setSelections(List.of("both", Islands.DWARVEN_MINES.getDisplayName(), Islands.CRYSTAL_HOLLOWS.getDisplayName(), "none")) + .setTooltip(Text.of("Get notified when a Double Powder happens in the specified Island")) + .setDefaultValue("none") + .setSuggestionMode(false) + .setSaveConsumer(newValue -> config.toDisplayConfig.doublePowder = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startBooleanToggle(Text.of("Mithril Gourmand"), config.toDisplayConfig.mithrilGourmand) + .setDefaultValue(false) + .setTooltip(Text.of("Get notified when a Mithril Gourmand happens")) + .setSaveConsumer(newValue -> config.toDisplayConfig.mithrilGourmand = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startBooleanToggle(Text.of("Raffle"), config.toDisplayConfig.raffle) + .setDefaultValue(false) + .setTooltip(Text.of("Get notified when a Raffle happens")) + .setSaveConsumer(newValue -> config.toDisplayConfig.raffle = newValue) + .build()); + miningEvents.addEntry(entryBuilder.startBooleanToggle(Text.of("Goblin Raid"), config.toDisplayConfig.goblinRaid) + .setDefaultValue(false) + .setTooltip(Text.of("Get notified when a Goblin Raid happens")) + .setSaveConsumer(newValue -> config.toDisplayConfig.goblinRaid = newValue) + .build()); + } //Mining Events + if (config.hasBBRoles("dev")){ + ConfigCategory dev = builder.getOrCreateCategory(Text.of("Developing")); + dev.addEntry(entryBuilder.startBooleanToggle(Text.of("Dev Mode"), config.devMode) + .setDefaultValue(false) + .setTooltip(Text.of("Dev Mode")) + .setSaveConsumer(newValue -> config.devMode = newValue) + .build()); + dev.addEntry(entryBuilder.startBooleanToggle(Text.of("Detailed Dev Mode"), config.detailedDevMode) + .setDefaultValue(false) + .setTooltip(Text.of("Detailed Dev Mode")) + .setSaveConsumer(newValue -> config.detailedDevMode = newValue) + .build()); + } return builder.build(); } diff --git a/src/main/java/de/hype/bbsentials/client/Config.java b/src/main/java/de/hype/bbsentials/client/Config.java index f2186ed..2c9e471 100644 --- a/src/main/java/de/hype/bbsentials/client/Config.java +++ b/src/main/java/de/hype/bbsentials/client/Config.java @@ -14,8 +14,8 @@ import java.util.ArrayList; public class Config implements Serializable { //DO NOT Change any of the following unless you know what you are doing! public int apiVersion = 1; - private boolean devMode = false; - private boolean detailedDevMode = false; + boolean devMode = false; + boolean detailedDevMode = false; //You can change again // set automatically @@ -104,6 +104,7 @@ public class Config implements Serializable { } catch (IOException e) { e.printStackTrace(); } + toDisplayConfig.saveToFile(); } // Getter methods for various config attributes diff --git a/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java b/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java deleted file mode 100644 index 015f56c..0000000 --- a/src/main/java/de/hype/bbsentials/client/ModMenuConfig.java +++ /dev/null @@ -1,4 +0,0 @@ -package de.hype.bbsentials.client; - -public class ModMenuConfig { -} diff --git a/src/main/java/de/hype/bbsentials/client/ToDisplayConfig.java b/src/main/java/de/hype/bbsentials/client/ToDisplayConfig.java index 2c513d0..d3a1707 100644 --- a/src/main/java/de/hype/bbsentials/client/ToDisplayConfig.java +++ b/src/main/java/de/hype/bbsentials/client/ToDisplayConfig.java @@ -11,33 +11,30 @@ import java.io.IOException; import java.lang.reflect.Field; public class ToDisplayConfig { - private boolean disableAll = true; - private boolean prehistoricEgg = true; - private boolean pickonimbus2000 = true; - private boolean controlSwitch = true; - private boolean electronTransmitter = true; - private boolean ftx3070 = true; - private boolean robotronReflector = true; - private boolean superliteMotor = true; - private boolean syntheticHeart = true; - private boolean flawlessGemstone = true; - private boolean allRoboPartCustomChChestItem = true; - private boolean allChChestItem = true; - private boolean dwBetterTogether = true; - private boolean dwDoublePowder = true; - private boolean dwGoneWithTheWind = true; - private boolean dwGoblinRaid = true; - private boolean dwMithrilGourmand = true; - private boolean dwRaffle = true; - private boolean dwEvents = true; - private boolean chBetterTogether = true; - private boolean chDoublePowder = true; - private boolean chGoneWithTheWind = true; - private boolean chEvents = true; - private boolean allBetterTogether = true; - private boolean allDoublePowder = true; - private boolean allGoneWithTheWind = true; - private boolean allEvents = true; + public boolean disableAll = false; + public boolean allChChestItem = true; + public boolean allRoboPart = false; + public boolean customChChestItem = false; + + public boolean prehistoricEgg = false; + public boolean pickonimbus2000 = false; + public boolean controlSwitch = false; + public boolean electronTransmitter = false; + public boolean ftx3070 = false; + public boolean robotronReflector = false; + public boolean superliteMotor = false; + public boolean syntheticHeart = false; + public boolean flawlessGemstone = false; + //Mining Events. + public boolean allEvents = true; + public boolean blockChEvents = false; + + public String betterTogether = "none"; + public String doublePowder = "none"; + public String goneWithTheWind = "none"; + public boolean goblinRaid = false; + public boolean mithrilGourmand = false; + public boolean raffle = false; // Serialize the object to JSON and save to file public void saveToFile() { -- cgit