diff options
| author | Sage <salbeira@gmail.com> | 2025-06-27 06:40:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-27 00:40:20 -0400 |
| commit | a26dda609cc4fbbe5b64635ba73b7707930d72f7 (patch) | |
| tree | 77036b0daeb54838f56edd787e071ad723ac5c94 | |
| parent | 13fb72006f2d59d21534be087541d112a7a8ef31 (diff) | |
| download | Skyblocker-a26dda609cc4fbbe5b64635ba73b7707930d72f7.tar.gz Skyblocker-a26dda609cc4fbbe5b64635ba73b7707930d72f7.tar.bz2 Skyblocker-a26dda609cc4fbbe5b64635ba73b7707930d72f7.zip | |
Add a config option to toggle item protection chat notifications (#1382)
* Add a config option to toggle chat notifications
* Update src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java
Co-authored-by: Mona <59416038+meowora@users.noreply.github.com>
* Update src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java
Co-authored-by: Mona <59416038+meowora@users.noreply.github.com>
* Update src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java
Co-authored-by: Mona <59416038+meowora@users.noreply.github.com>
* Update src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java
Co-authored-by: Mona <59416038+meowora@users.noreply.github.com>
---------
Co-authored-by: Sebastian Hauer <sebastian.hauer@tu-dortmund.de>
Co-authored-by: Mona <59416038+meowora@users.noreply.github.com>
4 files changed, 28 insertions, 8 deletions
diff --git a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java index f1ab7eb8..70121942 100644 --- a/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java +++ b/src/main/java/de/hysky/skyblocker/config/categories/GeneralCategory.java @@ -349,6 +349,14 @@ public class GeneralCategory { newValue -> config.general.itemProtection.protectValuableConsumables = newValue) .controller(ConfigUtils::createBooleanController) .build()) + .option(Option.<Boolean>createBuilder() + .name(Text.translatable("skyblocker.config.general.itemProtection.displayChatNotification")) + .description(OptionDescription.of(Text.translatable("skyblocker.config.general.itemProtection.displayChatNotification.@Tooltip"))) + .binding(defaults.general.itemProtection.displayChatNotification, + () -> config.general.itemProtection.displayChatNotification, + newValue -> config.general.itemProtection.displayChatNotification = newValue) + .controller(ConfigUtils::createBooleanController) + .build()) .build()) //Wiki Lookup diff --git a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java index a4dcbf8c..73bc4469 100644 --- a/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java +++ b/src/main/java/de/hysky/skyblocker/config/configs/GeneralConfig.java @@ -231,6 +231,9 @@ public class GeneralConfig { @SerialEntry public SlotLockStyle slotLockStyle = SlotLockStyle.FANCY; + @SerialEntry + public boolean displayChatNotification = true; + @SerialEntry public boolean protectValuableConsumables = true; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java index c691cc56..b18b33b0 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/ItemProtection.java @@ -60,6 +60,7 @@ public class ItemProtection { } private static int protectMyItem(FabricClientCommandSource source) { + boolean notifyConfiguration = SkyblockerConfigManager.get().general.itemProtection.displayChatNotification; ItemStack heldItem = source.getPlayer().getMainHandStack(); if (Utils.isOnSkyblock()) { @@ -71,13 +72,15 @@ public class ItemProtection { if (!protectedItems.contains(itemUuid)) { protectedItems.add(itemUuid); SkyblockerConfigManager.save(); - - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.added", heldItem.getName()))); + if (notifyConfiguration) { + source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.added", heldItem.getName()))); + } } else { protectedItems.remove(itemUuid); SkyblockerConfigManager.save(); - - source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName()))); + if (notifyConfiguration) { + source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName()))); + } } } else { source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.noItemUuid"))); @@ -90,6 +93,8 @@ public class ItemProtection { } public static void handleKeyPressed(ItemStack heldItem) { + boolean notifyConfiguration = SkyblockerConfigManager.get().general.itemProtection.displayChatNotification; + PlayerEntity playerEntity = MinecraftClient.getInstance().player; if (playerEntity == null) { return; @@ -111,13 +116,15 @@ public class ItemProtection { if (!protectedItems.contains(itemUuid)) { protectedItems.add(itemUuid); SkyblockerConfigManager.save(); - - playerEntity.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.added", heldItem.getName())), false); + if (notifyConfiguration) { + playerEntity.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.added", heldItem.getName())), false); + } } else { protectedItems.remove(itemUuid); SkyblockerConfigManager.save(); - - playerEntity.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName())), false); + if (notifyConfiguration) { + playerEntity.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName())), false); + } } } else { playerEntity.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.noItemUuid")), false); diff --git a/src/main/resources/assets/skyblocker/lang/en_us.json b/src/main/resources/assets/skyblocker/lang/en_us.json index acde5d3a..fb0d66c4 100644 --- a/src/main/resources/assets/skyblocker/lang/en_us.json +++ b/src/main/resources/assets/skyblocker/lang/en_us.json @@ -330,6 +330,8 @@ "skyblocker.config.general.itemProtection": "Item Protection", "skyblocker.config.general.itemProtection.protectValuableConsumables": "Protect Valuable Consumables", "skyblocker.config.general.itemProtection.protectValuableConsumables.@Tooltip": "Prevents consuming items such as Bottles of Jyrre, Dark Cacao Truffles, and Discrite before they have evolved.", + "skyblocker.config.general.itemProtection.displayChatNotification": "Display Chat Notifications", + "skyblocker.config.general.itemProtection.displayChatNotification.@Tooltip": "Displays a chat notification when toggling the protection state of an item.", "skyblocker.config.general.itemProtection.slotLockStyle": "Slot Lock Icon Style", "skyblocker.config.general.itemProtection.slotLockStyle.@Tooltip": "Choose between the fancy or the classic slot lock icon.", "skyblocker.config.general.itemProtection.slotLockStyle.style.CLASSIC": "Classic", |
