Search in sources :

Example 1 with RegionExpansion

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;
}
Also used : RegionExpansion(com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion) RegionHandler(com.github.sirblobman.combatlogx.api.expansion.region.RegionHandler) ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) RegionExpansion(com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) ForceFieldExpansion(combatlogx.expansion.force.field.ForceFieldExpansion)

Example 2 with RegionExpansion

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;
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) TownyPermission(com.palmergames.bukkit.towny.object.TownyPermission) RegionExpansion(com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) Town(com.palmergames.bukkit.towny.object.Town) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) TownyWorld(com.palmergames.bukkit.towny.object.TownyWorld) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) TownBlock(com.palmergames.bukkit.towny.object.TownBlock)

Aggregations

RegionExpansion (com.github.sirblobman.combatlogx.api.expansion.region.RegionExpansion)2 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)1 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)1 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)1 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)1 RegionHandler (com.github.sirblobman.combatlogx.api.expansion.region.RegionHandler)1 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)1 Town (com.palmergames.bukkit.towny.object.Town)1 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)1 TownyPermission (com.palmergames.bukkit.towny.object.TownyPermission)1 TownyWorld (com.palmergames.bukkit.towny.object.TownyWorld)1 ForceFieldExpansion (combatlogx.expansion.force.field.ForceFieldExpansion)1 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)1 PluginManager (org.bukkit.plugin.PluginManager)1