use of com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion in project CombatLogX by SirBlobman.
the class ListenerForceField method isSafe.
private boolean isSafe(Player player, Location location, TagType tagType) {
ICombatLogX plugin = getCombatLogX();
ExpansionManager expansionManager = plugin.getExpansionManager();
List<Expansion> enabledExpansionList = expansionManager.getEnabledExpansions();
for (Expansion expansion : enabledExpansionList) {
if (expansion instanceof RegionExpansion) {
RegionExpansion regionExpansion = (RegionExpansion) expansion;
RegionHandler regionHandler = regionExpansion.getRegionHandler();
if (regionHandler.isSafeZone(player, location, tagType)) {
return true;
}
}
}
return false;
}
use of com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion in project CombatLogX by SirBlobman.
the class TownyRegionHandler method isSafeZone.
@Override
public boolean isSafeZone(Player player, Location location, TagType tagType) {
if (tagType != TagType.PLAYER) {
return false;
}
RegionExpansion expansion = getExpansion();
ConfigurationManager configurationManager = expansion.getConfigurationManager();
YamlConfiguration configuration = configurationManager.get("config.yml");
TownBlock townBlock = getTownBlock(location);
if (townBlock == null) {
return false;
}
if (configuration.getBoolean("prevent-all-town-entries", false)) {
if (isOwnTown(townBlock, player)) {
return true;
}
}
TownyWorld townyWorld = townBlock.getWorld();
if (townyWorld == null || townyWorld.isForcePVP()) {
return false;
}
Town town;
try {
town = townBlock.getTown();
if (town == null || town.isPVP() || town.isAdminEnabledPVP() || town.hasActiveWar()) {
return false;
}
} catch (NotRegisteredException ex) {
return false;
}
PluginManager pluginManager = Bukkit.getPluginManager();
if (pluginManager.isPluginEnabled("FlagWar")) {
if (FlagWarAPI.isUnderAttack(town)) {
return false;
}
}
TownyPermission townBlockPermissions = townBlock.getPermissions();
return !townBlockPermissions.pvp;
}
Aggregations