Search in sources :

Example 16 with ICombatLogX

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

the class ListenerDamage method getDamager.

private Entity getDamager(EntityDamageByEntityEvent e) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("config.yml");
    Entity damager = e.getDamager();
    if (configuration.getBoolean("link-projectiles")) {
        ICombatLogX plugin = getCombatLogX();
        damager = EntityHelper.linkProjectile(plugin, damager);
    }
    if (configuration.getBoolean("link-pets")) {
        damager = EntityHelper.linkPet(damager);
    }
    return damager;
}
Also used : Entity(org.bukkit.entity.Entity) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

Example 17 with ICombatLogX

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

the class PVPManager method setPVP.

public void setPVP(Player player, boolean pvp) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        return;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    playerData.set("newbie-helper.pvp-toggle", pvp);
    playerDataManager.save(player);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 18 with ICombatLogX

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

the class ProtectionManager method setProtected.

public void setProtected(Player player, boolean protect) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        return;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    if (!protect) {
        playerData.set("newbie-helper.protected", false);
        playerData.set("newbie-helper.protection-expire-time", null);
        playerDataManager.save(player);
        return;
    }
    long newExpireTime = getProtectionExpireTime();
    playerData.set("newbie-helper.protected", true);
    playerData.set("newbie-helper.protection-expire-time", newExpireTime);
    playerDataManager.save(player);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 19 with ICombatLogX

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

the class ListenerDamage method checkTag.

private void checkTag(Entity entity, Entity enemy, TagReason tagReason) {
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    plugin.printDebug("Checking if the entity '" + getName(entity) + "' should be tagged " + "for reason '" + tagReason + "' by enemy '" + getName(enemy) + "'.");
    if (!(entity instanceof Player)) {
        plugin.printDebug("Entity was not a player.");
        return;
    }
    if (!(enemy instanceof Player)) {
        plugin.printDebug("Enemy was not a player.");
        return;
    }
    Player playerEntity = (Player) entity;
    Player playerEnemy = (Player) enemy;
    plugin.printDebug("Triggering tag for player " + getName(playerEntity) + " with enemy " + getName(playerEnemy) + "...");
    boolean tag = combatManager.tag(playerEntity, playerEnemy, TagType.PLAYER, tagReason);
    plugin.printDebug("Tag Status: " + tag);
}
Also used : Player(org.bukkit.entity.Player) ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX)

Example 20 with ICombatLogX

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

the class ListenerUntag method runUntagCommands.

private void runUntagCommands(Player player, LivingEntity previousEnemy) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("commands.yml");
    List<String> untagCommandList = configuration.getStringList("untag-command-list");
    if (untagCommandList.isEmpty()) {
        return;
    }
    ICombatLogX plugin = getCombatLogX();
    ICombatManager combatManager = getCombatManager();
    for (String untagCommand : untagCommandList) {
        String replacedCommand = combatManager.replaceVariables(player, previousEnemy, untagCommand);
        if (replacedCommand.startsWith("[PLAYER]")) {
            String command = replacedCommand.substring("[PLAYER]".length());
            CommandHelper.runAsPlayer(plugin, player, command);
            continue;
        }
        if (replacedCommand.startsWith("[OP]")) {
            String command = replacedCommand.substring("[OP]".length());
            CommandHelper.runAsOperator(plugin, player, command);
            continue;
        }
        CommandHelper.runAsConsole(plugin, replacedCommand);
    }
}
Also used : ICombatManager(com.github.sirblobman.combatlogx.api.manager.ICombatManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager)

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