Search in sources :

Example 11 with Replacer

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;
}
Also used : Player(org.bukkit.entity.Player) Region(br.net.fabiozumbi12.RedProtect.Bukkit.Region) Replacer(br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender)

Aggregations

Replacer (br.net.fabiozumbi12.RedProtect.Core.helpers.Replacer)11 Player (org.bukkit.entity.Player)7 Region (br.net.fabiozumbi12.RedProtect.Bukkit.Region)4 Region (br.net.fabiozumbi12.RedProtect.Sponge.Region)3 Player (org.spongepowered.api.entity.living.player.Player)3 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 ClanPlayer (net.sacredlabyrinth.phaed.simpleclans.ClanPlayer)2 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)2 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.API.events.DeleteRegionEvent)1 RenameRegionEvent (br.net.fabiozumbi12.RedProtect.Bukkit.API.events.RenameRegionEvent)1 RedProtect (br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect)1 ItemFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.ItemFlagGui)1 MobFlagGui (br.net.fabiozumbi12.RedProtect.Bukkit.guis.MobFlagGui)1 PlayerRegion (br.net.fabiozumbi12.RedProtect.Core.region.PlayerRegion)1 RedProtect (br.net.fabiozumbi12.RedProtect.Sponge.RedProtect)1 DeleteRegionEvent (br.net.fabiozumbi12.RedProtect.Sponge.events.DeleteRegionEvent)1 RenameRegionEvent (br.net.fabiozumbi12.RedProtect.Sponge.events.RenameRegionEvent)1 ItemFlagGui (br.net.fabiozumbi12.RedProtect.Sponge.guis.ItemFlagGui)1 UltimateFancy (br.net.fabiozumbi12.UltimateFancy.UltimateFancy)1