TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/commands/Command_blockcmd.java

63 lines
2.2 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
2012-12-06 09:32:08 +00:00
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
2012-12-06 09:32:08 +00:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <purge | <partialname>>", aliases = "blockcommands,blockcommand")
public class Command_blockcmd extends FreedomCommand
2012-12-06 09:32:08 +00:00
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
2012-12-06 09:32:08 +00:00
return false;
}
if (args[0].equalsIgnoreCase("purge"))
{
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
int counter = 0;
2013-08-14 14:01:42 +00:00
for (Player player : server.getOnlinePlayers())
{
FPlayer playerdata = plugin.pl.getPlayer(player);
if (playerdata.allCommandsBlocked())
{
counter += 1;
playerdata.setCommandsBlocked(false);
}
}
2013-01-16 14:48:56 +00:00
playerMsg("Unblocked commands for " + counter + " players.");
return true;
}
final Player player = getPlayer(args[0]);
if (player == null)
2012-12-06 09:32:08 +00:00
{
playerMsg(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
if (isAdmin(sender))
{
2013-08-14 14:01:42 +00:00
playerMsg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
2012-12-06 09:32:08 +00:00
return true;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
2012-12-06 09:32:08 +00:00
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
2012-12-06 09:32:08 +00:00
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
playerMsg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
2012-12-06 09:32:08 +00:00
return true;
}
}