use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class CommandCombatLogXUntag method execute.
@Override
protected boolean execute(CommandSender sender, String[] args) {
if (!checkPermission(sender, "combatlogx.command.combatlogx.untag", true)) {
return true;
}
if (args.length < 1) {
return false;
}
Player target = findTarget(sender, args[0]);
if (target == null) {
return true;
}
String targetName = target.getName();
Replacer replacer = message -> message.replace("{target}", targetName);
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = plugin.getCombatManager();
if (!combatManager.isInCombat(target)) {
sendMessageWithPrefix(sender, "error.target-not-in-combat", replacer, true);
return true;
}
combatManager.untag(target, UntagReason.EXPIRE);
sendMessageWithPrefix(sender, "command.combatlogx.untag-player", replacer, true);
return true;
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class ListenerConfiguration method runTagCommands.
private void runTagCommands(Player player, LivingEntity enemy) {
ConfigurationManager configurationManager = getPluginConfigurationManager();
YamlConfiguration configuration = configurationManager.get("commands.yml");
ICombatLogX plugin = getCombatLogX();
ICombatManager combatManager = getCombatManager();
List<String> tagCommandList = configuration.getStringList("tag-command-list");
if (tagCommandList.isEmpty())
return;
for (String tagCommand : tagCommandList) {
String replacedCommand = combatManager.replaceVariables(player, enemy, tagCommand);
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 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.manager.ICombatManager in project CombatLogX by SirBlobman.
the class PunishManager method runPunishCommands.
private void runPunishCommands(Player player, LivingEntity previousEnemy, List<String> punishCommandList) {
if (punishCommandList.isEmpty()) {
return;
}
ICombatManager combatManager = this.plugin.getCombatManager();
for (String punishCommand : punishCommandList) {
String replacedCommand = combatManager.replaceVariables(player, previousEnemy, punishCommand);
if (replacedCommand.startsWith("[PLAYER]")) {
String command = replacedCommand.substring("[PLAYER]".length());
CommandHelper.runAsPlayer(this.plugin, player, command);
continue;
}
if (replacedCommand.startsWith("[OP]")) {
String command = replacedCommand.substring("[OP]".length());
CommandHelper.runAsOperator(this.plugin, player, command);
continue;
}
CommandHelper.runAsConsole(this.plugin, replacedCommand);
}
}
use of com.github.sirblobman.combatlogx.api.manager.ICombatManager in project CombatLogX by SirBlobman.
the class TimerUpdateTask method update.
private void update(Player player) {
ICombatManager combatManager = this.plugin.getCombatManager();
long timeLeftMillis = combatManager.getTimerLeftMillis(player);
if (timeLeftMillis <= 0L) {
return;
}
Set<TimerUpdater> timerUpdaterSet = getTimerUpdaters();
for (TimerUpdater timerUpdater : timerUpdaterSet) {
timerUpdater.update(player, timeLeftMillis);
}
}
Aggregations