use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerDamage method getDamager.
@Contract("null -> null")
private Entity getDamager(Entity entity) {
if (entity == null) {
return null;
}
ICombatLogX plugin = getCombatLogX();
YamlConfiguration configuration = getConfiguration();
if (configuration.getBoolean("link-projectiles")) {
entity = EntityHelper.linkProjectile(plugin, entity);
}
if (configuration.getBoolean("link-pets")) {
entity = EntityHelper.linkPet(entity);
}
if (configuration.getBoolean("link-tnt")) {
entity = EntityHelper.linkTNT(entity);
}
return entity;
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerDamage method getName.
private String getName(Entity entity) {
ICombatLogX plugin = getCombatLogX();
if (entity == null) {
CommandSender console = Bukkit.getConsoleSender();
LanguageManager languageManager = plugin.getLanguageManager();
return languageManager.getMessage(console, "placeholder.unknown-enemy", null, true);
}
MultiVersionHandler multiVersionHandler = plugin.getMultiVersionHandler();
EntityHandler entityHandler = multiVersionHandler.getEntityHandler();
return entityHandler.getName(entity);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class ListenerUntag method onUntag.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onUntag(PlayerUntagEvent e) {
Player player = e.getPlayer();
LivingEntity previousEnemy = e.getPreviousEnemy();
UntagReason untagReason = e.getUntagReason();
ICombatLogX plugin = getCombatLogX();
IPunishManager punishManager = plugin.getPunishManager();
punishManager.punish(player, untagReason, previousEnemy);
sendUntagMessage(player, untagReason);
runUntagCommands(player, previousEnemy);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class CustomScoreboard method replacePlaceholders.
private String replacePlaceholders(String string) {
ScoreboardExpansion expansion = getExpansion();
ICombatLogX plugin = expansion.getPlugin();
ICombatManager combatManager = plugin.getCombatManager();
Player player = getPlayer();
LivingEntity enemy = combatManager.getEnemy(player);
String color = MessageUtility.color(string);
return combatManager.replaceVariables(player, enemy, color);
}
use of com.github.sirblobman.combatlogx.api.ICombatLogX in project CombatLogX by SirBlobman.
the class CommandCombatTimer method checkOther.
private void checkOther(Player player, Player target) {
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
LanguageManager languageManager = getLanguageManager();
if (combatManager.isInCombat(target)) {
double timeLeftMillis = combatManager.getTimerLeftMillis(target);
double timeLeftSeconds = (timeLeftMillis / 1_000.0D);
String decimalFormatString = languageManager.getMessage(player, "decimal-format", null, false);
DecimalFormat decimalFormat = new DecimalFormat(decimalFormatString);
String timeLeftString = decimalFormat.format(timeLeftSeconds);
Replacer replacer = message -> message.replace("{time_left}", timeLeftString);
sendMessageWithPrefix(player, "command.combat-timer.time-left-other", replacer, true);
return;
}
sendMessageWithPrefix(player, "error.target-not-in-combat", null, true);
}
Aggregations