From 2a3536bfb4e6c09287c2e2239c5a3b86aefd630d Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Thu, 20 Jun 2024 01:49:05 +1000 Subject: Add toggle to disable slot locking in storage (#1199) Co-authored-by: jani270 <69345714+jani270@users.noreply.github.com> --- .../notenoughupdates/miscfeatures/SlotLocking.java | 20 ++++++++++++++++++++ .../options/separatesections/SlotLocking.java | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index f3757243..8f11f5c7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -62,6 +62,8 @@ import org.lwjgl.util.vector.Vector2f; import java.io.File; import java.util.Arrays; import java.util.HashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @NEUAutoSubscribe public class SlotLocking { @@ -156,11 +158,29 @@ public class SlotLocking { ConfigUtil.saveConfig(config, file, GSON); } + + private static final Pattern WINDOW_REGEX = Pattern.compile(".+ Backpack (?:✦ )?\\(Slot #(\\d+)\\)"); + private static final Pattern ECHEST_WINDOW_REGEX = Pattern.compile("Ender Chest \\((\\d+)/(\\d+)\\)"); + + private LockedSlot[] getDataForProfile() { if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null; + if (NotEnoughUpdates.INSTANCE.config.slotLocking.disableInStorage) { + if (StorageManager.getInstance().isStorageOpen) return null; + String openChestName = Utils.getOpenChestName(); + if (openChestName.trim().equals("Storage")) return null; + + Matcher matcher = WINDOW_REGEX.matcher(openChestName); + Matcher matcherEchest = ECHEST_WINDOW_REGEX.matcher(openChestName); + + if (matcher.matches() || matcherEchest.matches()) { + return null; + } + } + String profileName = SBInfo.getInstance().currentProfile; if (profileName == null) profileName = "generic"; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/SlotLocking.java index 45422347..e373747f 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/SlotLocking.java @@ -77,6 +77,14 @@ public class SlotLocking { @ConfigEditorBoolean public boolean lockSlotsInTrade = true; + @Expose + @ConfigOption( + name = "Disable Locking in Storage", + desc = "Disables slot locking and binding in the storage gui" + ) + @ConfigEditorBoolean + public boolean disableInStorage = false; + @Expose /*@ConfigOption( name = "Item Swap drop delay", -- cgit