mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 13:07:29 +01:00
Don't cause item loss when the hopper is destroyed.
This commit is contained in:
parent
8e320b6dbe
commit
300f69597f
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user