Search in sources :

Example 81 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ProtectionManager method isProtected.

public boolean isProtected(Player player) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        return false;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    if (!configuration.getBoolean("newbie-helper.protected")) {
        return false;
    }
    long expireTime = configuration.getLong("newbie-helper.protection-expire-time", 0L);
    long systemTime = System.currentTimeMillis();
    if (systemTime < expireTime) {
        return true;
    }
    setProtected(player, false);
    LanguageManager languageManager = this.expansion.getPlugin().getLanguageManager();
    languageManager.sendMessage(player, "expansion.newbie-helper.protection-disabled.expired", null, true);
    return false;
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 82 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class RewardExpansion method onEnable.

@Override
public void onEnable() {
    ICombatLogX plugin = getPlugin();
    ExpansionManager expansionManager = plugin.getExpansionManager();
    if (!checkDependency("Vault", true)) {
        expansionManager.disableExpansion(this);
        return;
    }
    this.hookVault = new HookVault(this);
    if (!this.hookVault.setupEconomy()) {
        expansionManager.disableExpansion(this);
        return;
    }
    RewardManager rewardManager = getRewardManager();
    rewardManager.loadRewards();
    new ListenerRewards(this).register();
}
Also used : ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) ListenerRewards(combatlogx.expansion.rewards.listener.ListenerRewards) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) HookVault(combatlogx.expansion.rewards.hook.HookVault) RewardManager(combatlogx.expansion.rewards.manager.RewardManager)

Example 83 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class VanishNoPacketExpansion method onEnable.

@Override
public void onEnable() {
    if (!checkDependency("VanishNoPacket", true, "3")) {
        ICombatLogX plugin = getPlugin();
        ExpansionManager expansionManager = plugin.getExpansionManager();
        expansionManager.disableExpansion(this);
        return;
    }
    new ListenerVanish(this).register();
}
Also used : ListenerVanish(combatlogx.expansion.compatibility.vnp.listener.ListenerVanish) ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 84 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class ListenerLands method getNewbieHelperExpansion.

private NewbieHelperExpansion getNewbieHelperExpansion() {
    ICombatLogX combatLogX = getCombatLogX();
    ExpansionManager expansionManager = combatLogX.getExpansionManager();
    Optional<Expansion> optionalExpansion = expansionManager.getExpansion("NewbieHelper");
    if (!optionalExpansion.isPresent()) {
        throw new IllegalArgumentException("NewbieHelper expansion is missing.");
    }
    Expansion expansion = optionalExpansion.get();
    if (!(expansion instanceof NewbieHelperExpansion)) {
        throw new IllegalArgumentException("NewbieHelper expansion is not a proper instance.");
    }
    return (NewbieHelperExpansion) expansion;
}
Also used : NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion) ExpansionManager(com.github.sirblobman.combatlogx.api.expansion.ExpansionManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Expansion(com.github.sirblobman.combatlogx.api.expansion.Expansion) LandsExpansion(combatlogx.expansion.compatibility.region.lands.LandsExpansion) NewbieHelperExpansion(combatlogx.expansion.newbie.helper.NewbieHelperExpansion)

Example 85 with ICombatLogX

use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.

the class HookMVdWPlaceholderAPI method onPlaceholderReplace.

@Override
public String onPlaceholderReplace(PlaceholderReplaceEvent e) {
    ICombatLogX plugin = this.expansion.getPlugin();
    Player player = e.getPlayer();
    if (player == null)
        return null;
    String id = e.getPlaceholder();
    if (!id.startsWith("combatlogx_"))
        return null;
    String placeholder = id.substring("combatlogx_".length());
    switch(placeholder) {
        case "time_left":
            return getTimeLeft(plugin, player);
        case "in_combat":
            return getInCombat(plugin, player);
        case "status":
            return getStatus(plugin, player);
        case "punishment_count":
            return getPunishmentCount(plugin, player);
        case "newbie_helper_pvp_status":
            return getNewbieHelperPVPStatus(player);
        case "newbie_helper_protected":
            return getNewbieHelperProtected(player);
        default:
            break;
    }
    if (placeholder.startsWith("enemy_")) {
        String enemyPlaceholder = placeholder.substring("enemy_".length());
        switch(enemyPlaceholder) {
            case "name":
                return getEnemyName(plugin, player);
            case "type":
                return getEnemyType(plugin, player);
            case "display_name":
                return getEnemyDisplayName(plugin, player);
            case "health":
                return getEnemyHealth(plugin, player);
            case "health_rounded":
                return getEnemyHealthRounded(plugin, player);
            case "hearts":
                return getEnemyHearts(plugin, player);
            case "hearts_count":
                return getEnemyHeartsCount(plugin, player);
            case "world":
                return getEnemyWorld(plugin, player);
            case "x":
                return getEnemyX(plugin, player);
            case "y":
                return getEnemyY(plugin, player);
            case "z":
                return getEnemyZ(plugin, player);
            default:
                break;
        }
        return getEnemyPlaceholder(player, enemyPlaceholder);
    }
    return null;
}
Also used : Player(org.bukkit.entity.Player) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Aggregations

ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)96 ExpansionManager (com.github.sirblobman.combatlogx.api.expansion.ExpansionManager)24 ICombatManager (com.github.sirblobman.combatlogx.api.manager.ICombatManager)19 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)19 Player (org.bukkit.entity.Player)18 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)14 LivingEntity (org.bukkit.entity.LivingEntity)13 LanguageManager (com.github.sirblobman.api.language.LanguageManager)12 Logger (java.util.logging.Logger)11 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)10 MultiVersionHandler (com.github.sirblobman.api.nms.MultiVersionHandler)9 PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)8 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)8 List (java.util.List)8 Replacer (com.github.sirblobman.api.language.Replacer)6 EntityHandler (com.github.sirblobman.api.nms.EntityHandler)5 State (com.github.sirblobman.combatlogx.api.expansion.Expansion.State)5 Collections (java.util.Collections)5 EventHandler (org.bukkit.event.EventHandler)5 NewbieHelperExpansion (combatlogx.expansion.newbie.helper.NewbieHelperExpansion)4