-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Should fix issue #98 and 1.8 compatibility
- Loading branch information
Showing
2 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/com/trophonix/tradeplus/trade/EntityPickupItemEventListener.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.trophonix.tradeplus.trade; | ||
|
||
import com.trophonix.tradeplus.TradePlus; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityPickupItemEvent; | ||
|
||
public class EntityPickupItemEventListener implements Listener { | ||
|
||
private final Trade trade; | ||
|
||
public EntityPickupItemEventListener(Trade trade) { | ||
this.trade = trade; | ||
} | ||
|
||
@EventHandler | ||
public void onPickup(EntityPickupItemEvent event) { | ||
if (trade.isCancelled()) return; | ||
if (!(event.getEntity() instanceof Player)) return; | ||
Player player = (Player) event.getEntity(); | ||
if (player.equals(trade.getPlayer1()) || player.equals(trade.getPlayer2())) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
} |
This file contains 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