use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class HookMVdWPlaceholderAPI method getEnemyPlaceholder.
private String getEnemyPlaceholder(Player player, String enemyPlaceholder) {
ICombatLogX plugin = this.expansion.getPlugin();
ICombatManager combatManager = plugin.getCombatManager();
LivingEntity enemy = combatManager.getEnemy(player);
if (enemy instanceof Player) {
Player playerEnemy = (Player) enemy;
String placeholder = String.format(Locale.US, "{%s}", enemyPlaceholder);
return PlaceholderAPI.replacePlaceholders(playerEnemy, placeholder);
}
return getUnknownEnemy(plugin, player);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager 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.manager.ICombatManager 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);
}
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerUntag method onKick.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onKick(PlayerKickEvent e) {
Player player = e.getPlayer();
if (!isInCombat(player)) {
return;
}
String kickReason = e.getReason();
UntagReason untagReason = (isKickReasonIgnored(kickReason) ? UntagReason.EXPIRE : UntagReason.KICK);
ICombatManager combatManager = getCombatManager();
combatManager.untag(player, untagReason);
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerUntag method onQuit.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onQuit(PlayerQuitEvent e) {
Player player = e.getPlayer();
if (!isInCombat(player)) {
return;
}
ICombatManager combatManager = getCombatManager();
combatManager.untag(player, UntagReason.QUIT);
}
Aggregations