use of br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer in project RedProtect by FabioZumbi12.
the class CanPurgeCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof ConsoleCommandSender || !RedProtect.get().getConfigManager().configRoot().purge.enabled) {
HandleHelpPage(sender, 1);
return true;
}
Player player = (Player) sender;
Region r = RedProtect.get().getRegionManager().getTopRegion(player.getLocation());
if (r == null) {
RedProtect.get().getLanguageManager().sendMessage(player, "cmdmanager.region.doesntexist");
return true;
}
if (!r.isLeader(player) && !r.isAdmin(player) && !RedProtect.get().getPermissionHandler().hasPerm(player, "redprotect.command.admin.canpurge")) {
RedProtect.get().getLanguageManager().sendMessage(player, "playerlistener.region.cantuse");
return true;
}
boolean value = !r.canPurge();
if (args.length == 1) {
value = Boolean.getBoolean(args[0]);
}
// Purge limit
int limit = RedProtect.get().getPermissionHandler().getPurgeLimit(player);
long amount = RedProtect.get().getRegionManager().getCanPurgePlayer(player.getUniqueId().toString(), player.getWorld().getName());
if (!value && amount >= limit) {
RedProtect.get().getLanguageManager().sendMessage(player, "playerlistener.region.purge-nolimit", new Replacer[] { new Replacer("{limit}", String.valueOf(limit)), new Replacer("{total}", String.valueOf(amount)) });
return true;
}
r.setCanPurge(value);
RedProtect.get().getLanguageManager().sendMessage(player, "cmdmanager.region.canpurge.set", new Replacer[] { new Replacer("{value}", String.valueOf(value)) });
RedProtect.get().logger.addLog("(World " + r.getWorld() + ") Player " + player.getName() + " CANPURGE " + r.getName() + " to " + value);
return true;
}
Aggregations