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;
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations