@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()); }