use of com.github.sirblobman.api.language.Replacer in project CombatLogX by SirBlobman.
the class CommandCombatLogXAbout method execute.
@Override
protected boolean execute(CommandSender sender, String[] args) {
if (!checkPermission(sender, "combatlogx.command.combatlogx.about", true)) {
return true;
}
if (args.length < 1) {
return false;
}
String expansionName = args[0];
Optional<Expansion> optionalExpansion = getExpansion(expansionName);
if (!optionalExpansion.isPresent()) {
Replacer replacer = message -> message.replace("{target}", expansionName);
sendMessageWithPrefix(sender, "error.unknown-expansion", replacer, true);
return true;
}
Expansion expansion = optionalExpansion.get();
sendExpansionInformation(sender, expansion);
return true;
}
use of com.github.sirblobman.api.language.Replacer in project CombatLogX by SirBlobman.
the class ListenerCommands method checkEvent.
private void checkEvent(PlayerCommandPreprocessEvent e) {
Player player = e.getPlayer();
if (!isInCombat(player) && !isInCooldown(player))
return;
if (hasBypassPermission(player))
return;
String command = e.getMessage();
String realCommand = fixCommand(command);
if (isAllowed(realCommand) || !isBlocked(realCommand))
return;
e.setCancelled(true);
Replacer replacer = message -> message.replace("{command}", realCommand);
sendMessageIgnoreCooldown(player, "expansion.cheat-prevention.command-blocked", replacer);
}
use of com.github.sirblobman.api.language.Replacer in project CombatLogX by SirBlobman.
the class CommandCombatLogXTag method execute.
@Override
protected boolean execute(CommandSender sender, String[] args) {
if (!checkPermission(sender, "combatlogx.command.combatlogx.tag", 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();
boolean successfulTag;
if (args.length < 2) {
successfulTag = combatManager.tag(target, null, TagType.UNKNOWN, TagReason.UNKNOWN);
} else {
BigInteger bigSeconds = parseInteger(sender, args[0]);
if (bigSeconds == null) {
return true;
}
long seconds = bigSeconds.longValue();
long milliseconds = TimeUnit.SECONDS.toMillis(seconds);
long systemMillis = System.currentTimeMillis();
long combatEndTime = (systemMillis + milliseconds);
successfulTag = combatManager.tag(target, null, TagType.UNKNOWN, TagReason.UNKNOWN, combatEndTime);
}
String messagePath = ("command.combatlogx." + (successfulTag ? "tag-player" : "tag-failure"));
sendMessageWithPrefix(sender, messagePath, replacer, true);
return true;
}
use of com.github.sirblobman.api.language.Replacer in project CombatLogX by SirBlobman.
the class CommandCombatLogXToggle method toggleValue.
private void toggleValue(Player player, String value) {
ICombatLogX plugin = getCombatLogX();
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
LanguageManager languageManager = getLanguageManager();
YamlConfiguration playerData = playerDataManager.get(player);
boolean currentValue = playerData.getBoolean(value, true);
playerData.set(value, !currentValue);
playerDataManager.save(player);
boolean status = playerData.getBoolean(value, true);
String statusPath = ("placeholder.toggle." + (status ? "enabled" : "disabled"));
String statusString = languageManager.getMessage(player, statusPath, null, true);
Replacer replacer = message -> message.replace("{status}", statusString);
String messagePath = ("command.combatlogx.toggle-" + value);
sendMessageWithPrefix(player, messagePath, replacer, true);
}
use of com.github.sirblobman.api.language.Replacer 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;
}
Aggregations