Skip to content

Fix: Always emit InventoryPickupItemEvent in suction module#32

Open
Distolfix wants to merge 1 commit intoSongoda-Plugins:masterfrom
Distolfix:fix/suction-inventory-pickup-event
Open

Fix: Always emit InventoryPickupItemEvent in suction module#32
Distolfix wants to merge 1 commit intoSongoda-Plugins:masterfrom
Distolfix:fix/suction-inventory-pickup-event

Conversation

@Distolfix
Copy link
Copy Markdown

Problem

The suction module was only emitting InventoryPickupItemEvent when the EMIT_INVENTORYPICKUPITEMEVENT setting was enabled (which defaults to false). 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.java

  1. Lines 78-80: Removed the conditional check for EMIT_INVENTORYPICKUPITEMEVENT setting when creating the inventory
  2. Lines 123-130: Removed the conditional check for EMIT_INVENTORYPICKUPITEMEVENT setting when emitting the event

The inventory is now always created and the event is always emitted for the suction module.

Benefits

  • Universal plugin compatibility: Any plugin can now block their custom items from being collected
  • Standard Bukkit API: Uses the standard InventoryPickupItemEvent
  • Backwards compatible: Existing plugins continue to work as before
  • Consistent behavior: Mirrors how regular hoppers already work

Use Cases

This change enables plugins to protect their custom items from suction collection:

  • Economy plugins can protect currency items
  • Quest plugins can protect quest items that must be manually collected
  • Shop plugins can protect their shop items
  • Any plugin with special items that use PDC tags

Testing

  • ✅ Compiled successfully with mvn clean compile
  • ✅ Built JAR with mvn package
  • ✅ No breaking changes to existing functionality

Note

The EMIT_INVENTORYPICKUPITEMEVENT setting 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant