From fa4063d358f3a9f15b867c593532b00c38f5232d Mon Sep 17 00:00:00 2001 From: Kaluub <60589762+Kaluub@users.noreply.github.com> Date: Sat, 20 Jan 2024 15:37:49 -0500 Subject: [PATCH] Dungeons improvements (#493) * Add setting for dropping protected items in dungeons * Fix Livid colour text --- .../de/hysky/skyblocker/config/SkyblockerConfig.java | 3 +++ .../skyblocker/config/categories/DungeonsCategory.java | 10 +++++++++- .../skyblocker/mixin/ClientPlayerEntityMixin.java | 8 +++++++- .../hysky/skyblocker/skyblock/dungeon/LividColor.java | 8 +++----- src/main/java/de/hysky/skyblocker/utils/Utils.java | 2 +- src/main/resources/assets/skyblocker/lang/en_us.json | 3 +++ 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java index 2eddea23b6..aa6e5d24a3 100644 --- a/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/SkyblockerConfig.java @@ -650,6 +650,9 @@ public static class Dungeons { @SerialEntry public boolean floor3GuardianHealthDisplay = true; + @SerialEntry + public boolean allowDroppingProtectedItems = false; + @SerialEntry public LividColor lividColor = new LividColor(); diff --git a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java index ad64e2e4d9..583bc166e8 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/DungeonsCategory.java @@ -410,8 +410,16 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig newValue -> config.locations.dungeons.floor3GuardianHealthDisplay = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.createBuilder() + .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.allowDroppingProtectedItems")) + .description(OptionDescription.of(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.allowDroppingProtectedItems.@Tooltip"))) + .binding(defaults.locations.dungeons.allowDroppingProtectedItems, + () -> config.locations.dungeons.allowDroppingProtectedItems, + newValue -> config.locations.dungeons.allowDroppingProtectedItems = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) - //Livid Color + // Livid Color .group(OptionGroup.createBuilder() .name(Text.translatable("text.autoconfig.skyblocker.option.locations.dungeons.lividColor")) .collapsed(true) diff --git a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java index dd207dc0ab..1d54b02c5e 100644 --- a/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixin/ClientPlayerEntityMixin.java @@ -2,6 +2,7 @@ import com.mojang.authlib.GameProfile; +import de.hysky.skyblocker.config.SkyblockerConfigManager; import de.hysky.skyblocker.skyblock.dungeon.partyfinder.PartyFinderScreen; import de.hysky.skyblocker.skyblock.item.HotbarSlotLock; import de.hysky.skyblocker.skyblock.item.ItemProtection; @@ -31,7 +32,12 @@ public ClientPlayerEntityMixin(ClientWorld world, GameProfile profile) { @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true) public void skyblocker$dropSelectedItem(CallbackInfoReturnable cir) { if (Utils.isOnSkyblock()) { - if (ItemProtection.isItemProtected(this.getInventory().getMainHandStack())) cir.setReturnValue(false); + if (ItemProtection.isItemProtected(this.getInventory().getMainHandStack())) { + if (!SkyblockerConfigManager.get().locations.dungeons.allowDroppingProtectedItems + || (SkyblockerConfigManager.get().locations.dungeons.allowDroppingProtectedItems && !Utils.isInDungeons())) { + cir.setReturnValue(false); + } + } HotbarSlotLock.handleDropSelectedItem(this.getInventory().selectedSlot, cir); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java index b1ed5a227f..4c23fa44be 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/dungeon/LividColor.java @@ -78,11 +78,9 @@ private static void onLividColorFound(MinecraftClient client, Block color) { LividColor.color = WOOL_TO_FORMATTING.get(color); String colorString = Registries.BLOCK.getId(color).getPath(); colorString = colorString.substring(0, colorString.length() - 5).toUpperCase(); - String[] messageParts = CONFIG.lividColorText.split("\\[color]"); - MutableText message = Constants.PREFIX.get().append(messageParts[0]); - for (int i = 1; i < messageParts.length; i++) { - message = message.append(Text.literal(colorString).formatted(LividColor.color)).append(Text.of(messageParts[i])); - } + MutableText message = Constants.PREFIX.get() + .append(CONFIG.lividColorText.replaceAll("\\[color]", colorString)) + .formatted(LividColor.color); if (CONFIG.enableLividColorText) { MessageScheduler.INSTANCE.sendMessageAfterCooldown(message.getString()); } diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index 22601c981a..45ace08536 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -339,7 +339,7 @@ private static void updateLocRaw() { /** * Parses the /locraw reply from the server and updates the player's profile id * - * @return not display the message in chat is the command is sent by the mod + * @return not display the message in chat if the command is sent by the mod */ public static boolean onChatMessage(Text text, boolean overlay) { String message = text.getString(); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index 06f29cc915..461af7e7a9 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -248,6 +248,9 @@ "text.autoconfig.skyblocker.option.locations.dungeons.fireFreezeStaffTimer.@Tooltip": "Display a timer when to use a Fire Freeze Staff in the F3/M3 boss fight.", "text.autoconfig.skyblocker.option.locations.dungeons.floor3GuardianHealthDisplay": "Guardian Health Display (F3/M3)", "text.autoconfig.skyblocker.option.locations.dungeons.floor3GuardianHealthDisplay.@Tooltip": "Displays guardian's health below them in the F3/M3 boss fight.", + "text.autoconfig.skyblocker.option.locations.dungeons.allowDroppingProtectedItems": "Enabled Dropping Protected Items", + "text.autoconfig.skyblocker.option.locations.dungeons.allowDroppingProtectedItems.@Tooltip": "Allows the use of class abilities in Dungeons while holding an item which has been protected using /skyblocker protectItem.", + "text.autoconfig.skyblocker.option.locations.dwarvenMines": "Dwarven Mines", "text.autoconfig.skyblocker.option.locations.dwarvenMines.enableDrillFuel": "Enable Drill Fuel", "text.autoconfig.skyblocker.option.locations.dwarvenMines.solveFetchur": "Solve Fetchur",