Don't cause item loss when the hopper is destroyed.

This commit is contained in:
sk89q 2014-08-24 17:06:13 -07:00
parent 8e320b6dbe
commit 300f69597f

View File

@ -39,6 +39,7 @@
import com.sk89q.worldguard.bukkit.util.Blocks;
import com.sk89q.worldguard.bukkit.util.Events;
import com.sk89q.worldguard.bukkit.util.Materials;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
@ -638,7 +639,7 @@ public void onVehicleEnter(VehicleDamageEvent event) {
@EventHandler(ignoreCancelled = true)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
InventoryHolder causeHolder = event.getInitiator().getHolder();
final InventoryHolder causeHolder = event.getInitiator().getHolder();
InventoryHolder sourceHolder = event.getSource().getHolder();
InventoryHolder targetHolder = event.getDestination().getHolder();
@ -662,7 +663,12 @@ public void onInventoryMoveItem(InventoryMoveItemEvent event) {
handleInventoryHolderUse(event, cause, targetHolder);
if (event.isCancelled() && causeHolder instanceof Hopper) {
((Hopper) causeHolder).getBlock().breakNaturally();
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
@Override
public void run() {
((Hopper) causeHolder).getBlock().breakNaturally();
}
});
} else {
entry.setCancelled(event.isCancelled());
}