Shop items now protected from spreading and growing blocks

This commit is contained in:
Eric 2016-09-06 11:16:36 +02:00
parent f76ec6fe2d
commit da772fcbd6

View File

@ -16,6 +16,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.*; import org.bukkit.event.block.*;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.event.world.StructureGrowEvent;
public class ShopItemListener implements Listener { public class ShopItemListener implements Listener {
@ -175,4 +176,30 @@ public class ShopItemListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler(priority = EventPriority.HIGH)
public void onStructureGrow(StructureGrowEvent e) {
for (BlockState state : e.getBlocks()) {
Block newBlock = state.getBlock();
if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
e.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockGrow(BlockGrowEvent e) {
Block newBlock = e.getNewState().getBlock();
if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
e.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockSpread(BlockSpreadEvent e) {
Block newBlock = e.getNewState().getBlock();
if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
e.setCancelled(true);
}
}
} }