Repository navigation
fix: relic inventory dupe and drag-in storage, autosave relics, silent mob-drop checks - #10
Open
happyc0der wants to merge 1 commit into
Open
happyc0der wants to merge 1 commit into
happyc0der wants to merge 1 commit into
Conversation
…t mob-drop checks - RelicInventoryListener.onInventoryClick: a shift-click whose stack only partly fit into the player's inventory added the part that fit but took nothing out of the relic inventory (ItemUtils.consumeItem only ran when everything fit), duplicating those relics. Now the amount that actually moved is removed and the slot is written back; "Your inventory is full!" is shown only when something was left over. - New onInventoryDrag: dragging items into the relic inventory bypassed the click guard, so any item could be stored there permanently. Drags that touch the top (relic) inventory are cancelled. - RelicInventoryManager: relic inventories were only saved in SlimeFrame.onDisable, so a crash lost every relic earned since the last restart. A once-a-minute task saves when the YAML changed, through a temp file that is moved over the old one. - AdvancedMobDropListener.canDrop called canUse(p, true) on every registered Slimefun mob drop, before checking that it is an AdvancedMobDrop, so each kill sent a no-permission/not-researched message per locked drop of that mob, on top of Slimefun's own MobDropListener. It now returns early for non-AdvancedMobDrop items and checks silently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four fixes in the relic inventory and mob drops. All of them have run on our Paper 26.2 server (Slimefun Legacy) since 2026-10-13, built from the SlimefunNewHorizons fork, whose copies of these three files match
mainhere line for line apart from import names.1. Duplication on a partial shift-click (
RelicInventoryListener.onInventoryClick)Shift-clicking a relic stack when it only partly fits into the player's inventory:
addItemgives the player the part that fits, butItemUtils.consumeItemonly runs when everything fit (nonAddedItems.isEmpty()). Nothing leaves the relic inventory, so the moved relics are duplicated. The amount that actually moved (wanted - sum(leftovers)) is now removed and the slot is written back. "Your inventory is full!" shows only when something was left over.2. Any item can be stored by dragging (new
onInventoryDrag)The click handler only lets relics come out, but an
InventoryDragEventisn't covered. Dragging any item over the relic inventory's slots stores it there for good, which turns it into a 54-slot backpack that opens anywhere. Drags that touch a top-inventory raw slot while the top inventory is the player's relic inventory are now cancelled. Drags inside the player's own inventory are unaffected.3. Relics are lost on a crash (
RelicInventoryManager)saveConfig()is only called fromSlimeFrame.onDisable, so a crash or kill loses every relic earned since the last clean stop. ArunTaskTimernow checks once a minute and saves only whensaveToString()changed. It writes a temp file and moves it over the old one (atomic move where the filesystem supports it), so a crash mid-write can't leave a truncated file. Save errors are logged instead ofprintStackTrace.4. A message per locked drop on every kill (
AdvancedMobDropListener.canDrop)canDropcalledsfItem.canUse(p, true)for every Slimefun item registered as a drop of that mob, from any addon, before checkinginstanceof AdvancedMobDrop. Each kill therefore sent a "no permission" / "not researched" message per locked drop, on top of Slimefun's ownMobDropListener. It now returns early for anything that isn't anAdvancedMobDrop, and checkscanUse(p, false), so a locked drop is still withheld, just silently. Drop logic and chances are unchanged.Testing
The three changed files compile against Slimefun 4 (Legacy 4.1.78) and paper-api 1.21.11. I didn't run the full Maven build against RC-34; the code only uses APIs from Java 16 and Bukkit that were already in use here.
🤖 Generated with Claude Code