@SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(PlayerInteractEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); final Block block = event.getClickedBlock(); final ItemStack item = event.getItem(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (block != null) { final Material t = block.getType(); plugin.debug("Interact with block: " + t.getId() + " : " + block); if (!(plugin.getConfig().getBoolean("flags.use-switches", false) && isSwitch(t))) { if (!(isOnAllowedList(t) || plugin.canBuildOnLocation(player, block.getLocation()))) event.setCancelled(true); } } else { if (item != null) { plugin.debug("Using item: " + item.getTypeId()); if (!(isOnAllowedList(item.getType()) || plugin.canBuildOnLocation(player, player.getLocation()))) event.setCancelled(true); } } plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.isCancelled()) return; final Entity target = event.getEntity(); Player attacker = null; if (event.getDamager() instanceof Player) { attacker = (Player) event.getDamager(); } else if (event.getDamager() instanceof Projectile) { if (((Projectile) event.getDamager()).getShooter() instanceof Player) attacker = (Player) ((Projectile) event.getDamager()).getShooter(); } if (target != null && attacker != null) { plugin.debug("Attacker: " + attacker + ", Target: " + target + ""); if (attacker.getWorld() != plugin.getIslandWorld()) return; if (attacker.isOp()) return; if (attacker.hasPermission("islandworld.bypass.damage")) return; if (target instanceof Player) { if (!Config.FLAG_PVP) event.setCancelled(true); } else { if (target instanceof ItemFrame) { if (!plugin.canBuildOnLocation(attacker, target.getLocation())) event.setCancelled(true); } else if (target instanceof Monster || target instanceof WaterMob) { if (plugin.canBuildOnLocation(attacker, target.getLocation()) || plugin.getConfig().getBoolean("flags.kill-monster", false)) { } else { event.setCancelled(true); } } else if (target instanceof Animals || target instanceof NPC) { if (plugin.canBuildOnLocation(attacker, target.getLocation()) || plugin.getConfig().getBoolean("flags.kill-animals", false)) { } else { event.setCancelled(true); } } } } plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPortal(PlayerPortalEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (!(plugin.getConfig().getBoolean("flags.use-portal", false) || plugin.canBuildOnLocation(player, event.getFrom()))) event.setCancelled(true); plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPickupItemEvent(PlayerPickupItemEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); final Item item = event.getItem(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (item != null && !(plugin.getConfig().getBoolean("flags.item-pickup", false) || plugin.canBuildOnLocation(player, item.getLocation()))) event.setCancelled(true); plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onProjectileLaunchEvent(ProjectileLaunchEvent event) { if (event.isCancelled()) return; if (event.getEntity().getShooter() instanceof Player && event.getEntity() instanceof ThrownPotion) { final Player player = (Player) event.getEntity().getShooter(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (player != null && !(plugin.getConfig().getBoolean("flags.potion-throw", false) || plugin.canBuildOnLocation(player, player.getLocation()))) event.setCancelled(true); } plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }
@EventHandler(priority = EventPriority.HIGHEST) public void onVehicleDamage(VehicleDamageEvent event) { if (event.isCancelled()) return; if (event.getAttacker() instanceof Player) { final Player player = (Player) event.getAttacker(); final Vehicle vehicle = event.getVehicle(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (vehicle != null && !(plugin.getConfig().getBoolean("flags.use-vehicle", false) || plugin.canBuildOnLocation(player, vehicle.getLocation()))) event.setCancelled(true); plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (event.isCancelled()) return; final Player player = event.getPlayer(); final Entity e = event.getRightClicked(); if (player.getWorld() != plugin.getIslandWorld()) return; if (player.isOp()) return; if (player.hasPermission("islandworld.bypass.island")) return; if (e instanceof Vehicle) { if (!(plugin.getConfig().getBoolean("flags.use-vehicle", false) || plugin.canBuildOnLocation(player, e.getLocation()))) event.setCancelled(true); } else { if (e != null && !plugin.canBuildOnLocation(player, e.getLocation())) event.setCancelled(true); } plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled()); }