/** * Does this WorldCoord fall within a plot owned by an enemy town? * * @param player * @param worldCoord * @return true if it is an enemy plot. */ public boolean isEnemyTownBlock(Player player, WorldCoord worldCoord) { try { return CombatUtil.isEnemy( TownyUniverse.getDataSource().getResident(player.getName()).getTown(), worldCoord.getTownBlock().getTown()); } catch (NotRegisteredException e) { return false; } }
/** * Should we be preventing friendly fire? * * @param attacker * @param defender * @return true if we should cancel damage. */ public static boolean preventFriendlyFire(Player attacker, Player defender) { /* * Don't block potion use (self damaging) on ourselves. */ if (attacker == defender) return false; if ((attacker != null) && (defender != null)) if (!TownySettings.getFriendlyFire() && CombatUtil.isAlly(attacker.getName(), defender.getName())) { try { TownBlock townBlock = new WorldCoord(defender.getWorld().getName(), Coord.parseCoord(defender)) .getTownBlock(); if (!townBlock.getType().equals(TownBlockType.ARENA)) return true; } catch (TownyException x) { // World or TownBlock failure // But we are configured to prevent friendly fire in the // wilderness too. return true; } } return false; }