/** * Called when a player attempts to log in to the server * * @param event Relevant event details */ @Override public void onPlayerLogin(PlayerLoginEvent event) { Player player = event.getPlayer(); GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName()); if (wcfg.enforceOneSession) { String name = player.getName(); for (Player pl : plugin.getServer().getOnlinePlayers()) { if (pl.getName().equalsIgnoreCase(name)) { pl.kickPlayer("Logged in from another location."); } } } if (!checkediConomy) { iConomy iconomy = (iConomy) plugin.getServer().getPluginManager().getPlugin("iConomy"); if (iconomy != null) { plugin.getGlobalConfiguration().setiConomy(iconomy); } checkediConomy = true; } }
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { Entity attacker = event.getDamager(); Entity defender = event.getEntity(); if (defender instanceof Player) { Player player = (Player) defender; GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName()); if (cfg.isInvinciblePlayer(player.getName())) { event.setCancelled(true); return; } if (attacker != null && attacker instanceof Player) { if (wcfg.useRegions) { Vector pt = toVector(defender.getLocation()); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.PVP)) { ((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area."); event.setCancelled(true); return; } } } if (attacker != null && attacker instanceof Monster) { if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) { event.setCancelled(true); return; } if (wcfg.useRegions) { Vector pt = toVector(defender.getLocation()); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); ApplicableRegionSet set = mgr.getApplicableRegions(pt); if (!set.isStateFlagAllowed(Flags.MOB_DAMAGE)) { event.setCancelled(true); return; } if (attacker instanceof Creeper) { if (!set.isStateFlagAllowed(Flags.CREEPER_EXPLOSION)) { event.setCancelled(true); return; } } } } } }
/* * Called when a block is destroyed from burning. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } if (wcfg.disableFireSpread) { event.setCancelled(true); return; } if (wcfg.fireSpreadDisableToggle) { Block block = event.getBlock(); event.setCancelled(true); checkAndDestroyAround( block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE); return; } if (wcfg.disableFireSpreadBlocks.size() > 0) { Block block = event.getBlock(); if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) { event.setCancelled(true); checkAndDestroyAround( block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE); return; } } if (wcfg.isChestProtected(event.getBlock())) { event.setCancelled(true); return; } if (wcfg.useRegions) { Block block = event.getBlock(); int x = block.getX(); int y = block.getY(); int z = block.getZ(); Vector pt = toVector(block); RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld()); ApplicableRegionSet set = mgr.getApplicableRegions(pt); if (!set.allows(DefaultFlag.FIRE_SPREAD)) { checkAndDestroyAround(block.getWorld(), x, y, z, BlockID.FIRE); event.setCancelled(true); return; } } }
/** Called when a block is broken. */ @Override public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled()) { return; } Player player = event.getPlayer(); WorldConfiguration wcfg = getWorldConfig(player); if (!wcfg.itemDurability) { ItemStack held = player.getItemInHand(); if (held.getTypeId() > 0) { held.setDurability((short) -1); player.setItemInHand(held); } } if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); event.setCancelled(true); return; } if (wcfg.getBlacklist() != null) { if (!wcfg.getBlacklist() .check( new BlockBreakBlacklistEvent( plugin.wrapPlayer(player), toVector(event.getBlock()), event.getBlock().getTypeId()), false, false)) { event.setCancelled(true); return; } if (!wcfg.getBlacklist() .check( new DestroyWithBlacklistEvent( plugin.wrapPlayer(player), toVector(event.getBlock()), player.getItemInHand().getTypeId()), false, false)) { event.setCancelled(true); return; } } if (wcfg.isChestProtected(event.getBlock(), player)) { player.sendMessage(ChatColor.DARK_RED + "The chest is protected."); event.setCancelled(true); return; } }
/* * Called when a block is broken. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { Player player = event.getPlayer(); WorldConfiguration wcfg = getWorldConfig(player); if (!wcfg.itemDurability) { ItemStack held = player.getItemInHand(); if (held.getTypeId() > 0 && !(ItemType.usesDamageValue(held.getTypeId()) || BlockType.usesData(held.getTypeId()))) { held.setDurability((short) 0); player.setItemInHand(held); } } if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock()) || !plugin.getGlobalRegionManager().canConstruct(player, event.getBlock())) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); event.setCancelled(true); return; } if (wcfg.getBlacklist() != null) { if (!wcfg.getBlacklist() .check( new BlockBreakBlacklistEvent( plugin.wrapPlayer(player), toVector(event.getBlock()), event.getBlock().getTypeId()), false, false)) { event.setCancelled(true); return; } if (!wcfg.getBlacklist() .check( new DestroyWithBlacklistEvent( plugin.wrapPlayer(player), toVector(event.getBlock()), player.getItemInHand().getTypeId()), false, false)) { event.setCancelled(true); return; } } if (wcfg.isChestProtected(event.getBlock(), player)) { player.sendMessage(ChatColor.DARK_RED + "The chest is protected."); event.setCancelled(true); return; } }
/* * Called when a block yields exp */ @EventHandler(priority = EventPriority.HIGH) public void onBlockExp(BlockExpEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (wcfg.disableExpDrops || !plugin .getGlobalRegionManager() .allows(DefaultFlag.EXP_DROPS, event.getBlock().getLocation())) { event.setExpToDrop(0); } }
/* * Called when a player places a block. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { Block blockPlaced = event.getBlock(); Player player = event.getPlayer(); World world = blockPlaced.getWorld(); ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(world); if (wcfg.useRegions) { final Location location = blockPlaced.getLocation(); if (!plugin.getGlobalRegionManager().canBuild(player, location) || !plugin.getGlobalRegionManager().canConstruct(player, location)) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); event.setCancelled(true); return; } } if (wcfg.getBlacklist() != null) { if (!wcfg.getBlacklist() .check( new BlockPlaceBlacklistEvent( plugin.wrapPlayer(player), toVector(blockPlaced), blockPlaced.getTypeId()), false, false)) { event.setCancelled(true); return; } } if (wcfg.signChestProtection && wcfg.getChestProtection().isChest(blockPlaced.getTypeId())) { if (wcfg.isAdjacentChestProtected(event.getBlock(), player)) { player.sendMessage( ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for."); event.setCancelled(true); return; } } if (wcfg.simulateSponge && blockPlaced.getTypeId() == 19) { if (wcfg.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) { return; } int ox = blockPlaced.getX(); int oy = blockPlaced.getY(); int oz = blockPlaced.getZ(); SpongeUtil.clearSpongeWater(plugin, world, ox, oy, oz); } }
@Override public void onEntityExplode(EntityExplodeEvent event) { if (event.isCancelled()) { return; } GlobalConfiguration cfg = plugin.getGlobalConfiguration(); Location l = event.getLocation(); WorldConfiguration wcfg = cfg.getWorldConfig(l.getWorld().getName()); if (event.getEntity() instanceof LivingEntity) { if (wcfg.blockCreeperBlockDamage) { event.setCancelled(true); return; } if (wcfg.blockCreeperExplosions) { event.setCancelled(true); return; } if (wcfg.useRegions) { Vector pt = toVector(l); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName()); if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.CREEPER_EXPLOSION)) { event.setCancelled(true); return; } } } else { // Shall assume that this is TNT if (wcfg.blockTNT) { event.setCancelled(true); return; } if (wcfg.useRegions) { Vector pt = toVector(l); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(wcfg.getWorldName()); if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.TNT)) { event.setCancelled(true); return; } } } }
/* * Called when a piston retracts */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (wcfg.useRegions && event.isSticky()) { if (!(plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, event.getRetractLocation())) || !(plugin .getGlobalRegionManager() .allows(DefaultFlag.PISTONS, event.getBlock().getLocation()))) { event.setCancelled(true); return; } } }
/* * Called when block physics occurs. */ @EventHandler(ignoreCancelled = true) public void onBlockPhysics(BlockPhysicsEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } int id = event.getChangedTypeId(); if (id == 13 && wcfg.noPhysicsGravel) { event.setCancelled(true); return; } if (id == 12 && wcfg.noPhysicsSand) { event.setCancelled(true); return; } if (id == 90 && wcfg.allowPortalAnywhere) { event.setCancelled(true); return; } if (wcfg.ropeLadders && event.getBlock().getType() == Material.LADDER) { if (event.getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) { event.setCancelled(true); return; } } }
public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { Entity defender = event.getEntity(); DamageCause type = event.getCause(); if (defender instanceof Player) { Player player = (Player) defender; GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName()); if (cfg.isInvinciblePlayer(player.getName())) { event.setCancelled(true); return; } if (wcfg.disableLavaDamage && type == DamageCause.LAVA) { event.setCancelled(true); return; } if (wcfg.disableContactDamage && type == DamageCause.CONTACT) { event.setCancelled(true); return; } } }
/** * Called when a player attempts to pickup an item * * @param event Relevant event details */ @Override public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (event.isCancelled()) { return; } GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName()); if (wcfg.getBlacklist() != null) { Item ci = event.getItem(); if (!wcfg.getBlacklist() .check( new ItemAcquireBlacklistEvent( BukkitPlayer.wrapPlayer(plugin, event.getPlayer()), toVector(ci.getLocation()), ci.getItemStack().getTypeId()), false, false)) { event.setCancelled(true); return; } } }
@Override public void onPlayerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); Location location = player.getLocation(); ApplicableRegionSet regions = plugin .getGlobalRegionManager() .getRegionManager(player.getWorld().getName()) .getApplicableRegions(BukkitUtil.toVector(location)); Location spawn = regions.getLocationFlag(Flags.SPAWN_LOC, true).getValue(player.getServer()); if (spawn != null) { RegionGroup spawnconfig = regions.getRegionGroupFlag(Flags.SPAWN_PERM, true).getValue(); if (spawnconfig != null) { BukkitPlayer localPlayer = BukkitPlayer.wrapPlayer(plugin, player); if (spawnconfig == RegionGroup.OWNER) { if (regions.isOwner(localPlayer)) { event.setRespawnLocation(spawn); } } else if (spawnconfig == RegionGroup.MEMBER) { if (regions.isMember(localPlayer)) { event.setRespawnLocation(spawn); } } else { event.setRespawnLocation(spawn); } } else { event.setRespawnLocation(spawn); } } }
/** * Called when block physics occurs * * @param event Relevant event details */ @Override public void onBlockPhysics(BlockPhysicsEvent event) { if (event.isCancelled()) { return; } ConfigurationManager cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); int id = event.getChangedTypeId(); if (id == 13 && wcfg.noPhysicsGravel) { event.setCancelled(true); return; } if (id == 12 && wcfg.noPhysicsSand) { event.setCancelled(true); return; } if (id == 90 && wcfg.allowPortalAnywhere) { event.setCancelled(true); return; } }
/* * Called when redstone changes. */ @EventHandler(priority = EventPriority.HIGH) public void onBlockRedstoneChange(BlockRedstoneEvent event) { Block blockTo = event.getBlock(); World world = blockTo.getWorld(); ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(world); if (wcfg.simulateSponge && wcfg.redstoneSponges) { int ox = blockTo.getX(); int oy = blockTo.getY(); int oz = blockTo.getZ(); for (int cx = -1; cx <= 1; cx++) { for (int cy = -1; cy <= 1; cy++) { for (int cz = -1; cz <= 1; cz++) { Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz); if (sponge.getTypeId() == 19 && sponge.isBlockIndirectlyPowered()) { SpongeUtil.clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } else if (sponge.getTypeId() == 19 && !sponge.isBlockIndirectlyPowered()) { SpongeUtil.addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); } } } } return; } }
public void registerEvents() { PluginManager pm = plugin.getServer().getPluginManager(); pm.registerEvent(Event.Type.ENTITY_DAMAGED, this, Priority.High, plugin); pm.registerEvent(Event.Type.ENTITY_EXPLODE, this, Priority.High, plugin); pm.registerEvent(Event.Type.CREATURE_SPAWN, this, Priority.High, plugin); }
/** * Called when a player places a block * * @param event Relevant event details */ @Override public void onBlockPlace(BlockPlaceEvent event) { if (event.isCancelled()) { return; } Block blockPlaced = event.getBlock(); Player player = event.getPlayer(); World world = blockPlaced.getWorld(); ConfigurationManager cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.get(world); if (wcfg.useRegions) { if (!plugin.getGlobalRegionManager().canBuild(player, blockPlaced.getLocation())) { player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); event.setCancelled(true); return; } } if (wcfg.getBlacklist() != null) { if (!wcfg.getBlacklist() .check( new BlockPlaceBlacklistEvent( plugin.wrapPlayer(player), toVector(blockPlaced), blockPlaced.getTypeId()), false, false)) { event.setCancelled(true); return; } } if (wcfg.simulateSponge && blockPlaced.getTypeId() == 19) { if (wcfg.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) { return; } int ox = blockPlaced.getX(); int oy = blockPlaced.getY(); int oz = blockPlaced.getZ(); clearSpongeWater(world, ox, oy, oz); } }
// @Override public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName()); if (wcfg.fireSpreadDisableToggle) { player.sendMessage(ChatColor.YELLOW + "Fire spread is currently globally disabled."); } // if (cfg.godmode || plugin.inGroup(player, "wg-invincible")) { cfg.addInvinciblePlayer(player.getName()); // } if (plugin.inGroup(player, "wg-amphibious")) { cfg.addAmphibiousPlayer(player.getName()); } }
@Override public void onCreatureSpawn(CreatureSpawnEvent event) { if (event.isCancelled()) { return; } GlobalConfiguration cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName()); // CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString()); CreatureType creaType = event.getCreatureType(); String creaName = ""; Boolean cancelEvent = false; if (wcfg.blockCreatureSpawn.contains(creaType)) { cancelEvent = true; } if (wcfg.useRegions) { Vector pt = toVector(event.getEntity().getLocation()); RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName()); Boolean flagValue = mgr.getApplicableRegions(pt) .getStringFlag(Flags.DENY_SPAWN, true) .getValue("") .contains(creaType.getName()); if (flagValue != null) { if (flagValue) { cancelEvent = true; } else { cancelEvent = false; } } } if (cancelEvent) { event.setCancelled(true); return; } }
/* * Called when a piston extends */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (wcfg.useRegions) { if (!plugin .getGlobalRegionManager() .allows(DefaultFlag.PISTONS, event.getBlock().getLocation())) { event.setCancelled(true); return; } for (Block block : event.getBlocks()) { if (!plugin.getGlobalRegionManager().allows(DefaultFlag.PISTONS, block.getLocation())) { event.setCancelled(true); return; } } } }
public void updateCommandBookGodMode() { try { if (plugin.getServer().getPluginManager().isPluginEnabled("CommandBook")) { Class.forName("com.sk89q.commandbook.GodComponent"); hasCommandBookGodMode = true; return; } } catch (ClassNotFoundException ignore) { } hasCommandBookGodMode = false; }
/** * Called when a player leaves a server * * @param event Relevant event details */ @Override public void onPlayerQuit(PlayerQuitEvent event) { Player player = event.getPlayer(); GlobalConfiguration cfg = plugin.getGlobalConfiguration(); cfg.removeInvinciblePlayer(player.getName()); cfg.removeAmphibiousPlayer(player.getName()); cfg.forgetPlayer(BukkitPlayer.wrapPlayer(plugin, player)); }
/** * Called when a block is destroyed from burning * * @param event Relevant event details */ @Override public void onBlockBurn(BlockBurnEvent event) { if (event.isCancelled()) { return; } ConfigurationManager cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (wcfg.disableFireSpread) { event.setCancelled(true); return; } if (wcfg.fireSpreadDisableToggle) { event.setCancelled(true); return; } if (wcfg.disableFireSpreadBlocks.size() > 0) { Block block = event.getBlock(); if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) { event.setCancelled(true); return; } } if (wcfg.useRegions) { Block block = event.getBlock(); Vector pt = toVector(block); RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld()); ApplicableRegionSet set = mgr.getApplicableRegions(pt); if (!set.allows(DefaultFlag.FIRE_SPREAD)) { event.setCancelled(true); return; } } }
public void registerEvents() { PluginManager pm = plugin.getServer().getPluginManager(); /* pm.registerEvent(Event.Type.PLAYER_ITEM, this, Priority.High, plugin); */ pm.registerEvent(Event.Type.PLAYER_INTERACT, this, Priority.High, plugin); pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, this, Priority.High, plugin); pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, this, Priority.High, plugin); pm.registerEvent(Event.Type.PLAYER_JOIN, this, Priority.Normal, plugin); pm.registerEvent(Event.Type.PLAYER_LOGIN, this, Priority.Normal, plugin); pm.registerEvent(Event.Type.PLAYER_QUIT, this, Priority.Normal, plugin); pm.registerEvent(Event.Type.PLAYER_RESPAWN, this, Priority.High, plugin); }
@Override public void onSnowForm(SnowFormEvent event) { if (event.isCancelled()) { return; } if (!plugin .getGlobalRegionManager() .allows(DefaultFlag.SNOW_FALL, event.getBlock().getLocation())) { event.setCancelled(true); } }
/* * Called when a block is formed based on world conditions. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockForm(BlockFormEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } int type = event.getNewState().getTypeId(); if (type == BlockID.ICE) { if (wcfg.disableIceFormation) { event.setCancelled(true); return; } if (wcfg.useRegions && !plugin .getGlobalRegionManager() .allows(DefaultFlag.ICE_FORM, event.getBlock().getLocation())) { event.setCancelled(true); return; } } if (type == BlockID.SNOW) { if (wcfg.disableSnowFormation) { event.setCancelled(true); return; } if (wcfg.useRegions && !plugin .getGlobalRegionManager() .allows(DefaultFlag.SNOW_FALL, event.getBlock().getLocation())) { event.setCancelled(true); return; } } }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onLeavesDecay(LeavesDecayEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); if (cfg.activityHaltToggle) { event.setCancelled(true); return; } if (wcfg.disableLeafDecay) { event.setCancelled(true); return; } if (wcfg.useRegions) { if (!plugin .getGlobalRegionManager() .allows(DefaultFlag.LEAF_DECAY, event.getBlock().getLocation())) { event.setCancelled(true); } } }
/* * Called when a block is damaged. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockDamage(BlockDamageEvent event) { Player player = event.getPlayer(); Block blockDamaged = event.getBlock(); // Cake are damaged and not broken when they are eaten, so we must // handle them a bit separately if (blockDamaged.getTypeId() == BlockID.CAKE_BLOCK) { if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) { player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); event.setCancelled(true); return; } } }
/** * Remove water around a sponge. * * @param world * @param ox * @param oy * @param oz */ private void clearSpongeWater(World world, int ox, int oy, int oz) { ConfigurationManager cfg = plugin.getGlobalConfiguration(); WorldConfiguration wcfg = cfg.get(world); for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) { for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) { for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) { if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) { world.getBlockAt(ox + cx, oy + cy, oz + cz).setTypeId(0); } } } } }
/* * Called when a block fades. */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockFade(BlockFadeEvent event) { ConfigurationManager cfg = plugin.getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld()); int type = event.getBlock().getTypeId(); if (type == BlockID.ICE) { if (wcfg.disableIceMelting) { event.setCancelled(true); return; } if (wcfg.useRegions && !plugin .getGlobalRegionManager() .allows(DefaultFlag.ICE_MELT, event.getBlock().getLocation())) { event.setCancelled(true); return; } } if (type == BlockID.SNOW) { if (wcfg.disableSnowMelting) { event.setCancelled(true); return; } if (wcfg.useRegions && !plugin .getGlobalRegionManager() .allows(DefaultFlag.SNOW_MELT, event.getBlock().getLocation())) { event.setCancelled(true); return; } } }