Fix: Always emit InventoryPickupItemEvent in suction module#32
Open
Distolfix wants to merge 1 commit intoSongoda-Plugins:masterfrom
Open
Fix: Always emit InventoryPickupItemEvent in suction module#32Distolfix wants to merge 1 commit intoSongoda-Plugins:masterfrom
Distolfix wants to merge 1 commit intoSongoda-Plugins:masterfrom
Conversation
The suction module was only emitting InventoryPickupItemEvent when the EMIT_INVENTORYPICKUPITEMEVENT setting was enabled. This prevented other plugins from cancelling item pickup for their custom items. This change makes the suction module always emit the event, allowing any plugin to cancel pickup by listening to InventoryPickupItemEvent, maintaining consistency with standard hopper behavior. This is important because suction is an aggressive collection mechanism that bypasses normal hopper behavior, and other plugins should have control over what items can be collected. Benefits: - Universal plugin compatibility - Plugins can block their custom items from being collected - Uses standard Bukkit event system - Backwards compatible with existing plugins
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.
Problem
The suction module was only emitting
InventoryPickupItemEventwhen theEMIT_INVENTORYPICKUPITEMEVENTsetting was enabled (which defaults tofalse). This prevented other plugins from cancelling item pickup for their custom items that should not be collected by hoppers.Solution
This PR modifies the suction module to always emit the
InventoryPickupItemEvent, regardless of the setting value. This allows any plugin to control what items can be collected by listening to the standard Bukkit event and cancelling it when needed.Why This Matters
Suction is an aggressive collection mechanism that bypasses normal hopper behavior by collecting items in a radius. It's important that other plugins can control what gets collected, just like they can with regular hoppers.
Changes Made
File:
ModuleSuction.javaEMIT_INVENTORYPICKUPITEMEVENTsetting when creating the inventoryEMIT_INVENTORYPICKUPITEMEVENTsetting when emitting the eventThe inventory is now always created and the event is always emitted for the suction module.
Benefits
InventoryPickupItemEventUse Cases
This change enables plugins to protect their custom items from suction collection:
Testing
mvn clean compilemvn packageNote
The
EMIT_INVENTORYPICKUPITEMEVENTsetting can remain for other purposes (such as regular hopper-to-hopper transfers), but for suction, the event should always be emitted to maintain proper plugin compatibility.