Skip to content

Commit 706b7f9

Browse files
committed
feat: allow locking bound slots
1 parent 2e6be45 commit 706b7f9

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/main/kotlin/events/IsSlotProtectedEvent.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ data class IsSlotProtectedEvent(
2121
val itemStack get() = itemStackOverride ?: slot!!.item
2222

2323
fun protect() {
24+
if (!isProtected) {
25+
silent = false
26+
}
2427
isProtected = true
25-
silent = false
2628
}
2729

2830
fun protectSilent() {
@@ -55,7 +57,7 @@ data class IsSlotProtectedEvent(
5557
.red()
5658
.append(tr("firmament.protectitem.hoverhint", "Hover for more info.").grey())
5759
.hover(tr("firmament.protectitem.hint",
58-
"To unlock this item use the Lock Slot or Lock Item keybind from Firmament while hovering over this item.")))
60+
"To unlock this item use the Lock Slot or Lock Item keybind from Firmament while hovering over this item. If this is a bound slot, you can use disable the Lock Bound Slots setting.")))
5961
CommonSoundEffects.playFailure()
6062
}
6163
return event.isProtected

src/main/kotlin/features/inventory/SlotLocking.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ object SlotLocking {
150150
SavedKeyBinding.keyWithMods(GLFW.GLFW_KEY_L, InputModifiers.of(shift = true))
151151
}
152152
val slotBind by keyBinding("bind") { GLFW.GLFW_KEY_L }
153+
val lockBound by toggle("lock-bind") { false }
153154
val slotBindRequireShift by toggle("require-quick-move") { true }
154155
val slotRenderLines by choice("bind-render") { SlotRenderLinesMode.ONLY_BOXES }
155156
val slotBindOnlyInInv by toggle("bind-only-in-inv") { false }
@@ -254,7 +255,14 @@ object SlotLocking {
254255

255256
@Subscribe
256257
fun onProtectSlot(it: IsSlotProtectedEvent) {
257-
if (it.slot != null && it.slot.container is Inventory && it.slot.containerSlot in (lockedSlots ?: setOf())) {
258+
if (it.slot != null
259+
&& it.slot.container is Inventory
260+
&& (it.slot.containerSlot in (lockedSlots ?: setOf())
261+
|| (
262+
TConfig.lockBound &&
263+
currentWorldData.boundSlots.findMatchingSlots(it.slot.containerSlot).isNotEmpty())
264+
)
265+
) {
258266
it.protect()
259267
}
260268
}

translations/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@
396396
"firmament.config.slot-locking.hunting-box": "Protect Hunting Box",
397397
"firmament.config.slot-locking.hunting-box.description": "The Hunting Box frequently changes its UUID, and as such cannot be reliably protected using UUID locking. Instead this option can be used to block from dropping any Hunting Box.",
398398
"firmament.config.slot-locking.lock": "Lock Slot",
399+
"firmament.config.slot-locking.lock-bind": "Lock Bound Slots",
400+
"firmament.config.slot-locking.lock-bind.description": "Prevent moving bound slots, except for slot quick moving.",
399401
"firmament.config.slot-locking.lock-uuid": "Lock UUID (Lock Item)",
400402
"firmament.config.slot-locking.lock-uuid.description": "Lock a SkyBlock item by it's UUID. This blocks a specific item from being dropped/sold, but still allows moving it around.",
401403
"firmament.config.slot-locking.lock.description": "Lock a slot, preventing any item from being moved from, dropped from, or placed into this slot.",

0 commit comments

Comments
 (0)