public class GuildExplodeListener implements Listener { @EventHandler(priority=EventPriority.MONITOR) public void explode(EntityExplodeEvent e) { Guild g = GuildManager.getGuildByLoc(e.getEntity().getLocation()); Guild o; if (g == null) { for (Block b : e.blockList()) { if (g == null) { o = GuildManager.getGuild(b.getLocation()); if (o != null) { g = o; } } } } if (g == null) { e.setCancelled(true); return; } g.setLastExplodeTime(System.currentTimeMillis() + TimeUtil.MINUTE.getTime(2)); g.message(""); g.message("&4Na terenie gildii wybuchlo tnt!"); g.message(""); if (g.getRegion().isInCentrum(e.getLocation(), 3, 1, 2)) { e.setCancelled(true); return; } if (g.getCreateTime() + TimeUtil.HOUR.getTime(24) > System.currentTimeMillis()) { e.setCancelled(true); return; } List sphere = SpaceUtil.sphere(e.getLocation(), 5, 5, false, true, 0); for (Location location : sphere) { if (location.getBlock().getType() == Material.OBSIDIAN) { if (RandomUtil.getChance(5.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.STATIONARY_WATER) { if (RandomUtil.getChance(10.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.STATIONARY_LAVA) { if (RandomUtil.getChance(10.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.WATER) { if (RandomUtil.getChance(50.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.LAVA) { if (RandomUtil.getChance(50.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.ENDER_CHEST) { if (RandomUtil.getChance(50.0D)) { location.getBlock().setType(Material.AIR); } } else if (location.getBlock().getType() == Material.ENCHANTMENT_TABLE) { location.getBlock().setType(Material.AIR); } } } }