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

68 lines
2.3 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
2011-10-19 00:37:00 +00:00
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
import org.bukkit.ChatColor;
2011-10-19 00:37:00 +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 = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]", aliases = "fr")
public class Command_freeze extends FreedomCommand
2011-10-19 00:37:00 +00:00
{
2011-10-19 00:37:00 +00:00
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
2011-10-19 00:37:00 +00:00
{
if (args.length == 0)
2011-10-19 00:37:00 +00:00
{
boolean allFrozen = plugin.fm.isGlobalFreeze();
plugin.fm.setGlobalFreeze(!allFrozen);
if (!allFrozen)
{
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
playerMsg("Players are now free to move.");
return true;
}
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true);
playerMsg("Players are now unfrozen.");
for (Player player : server.getOnlinePlayers())
{
if (!isAdmin(player))
2014-01-15 21:38:35 +00:00
{
playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
2014-01-15 21:38:35 +00:00
}
}
return true;
}
if (args[0].equals("purge"))
{
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
plugin.fm.purge();
return true;
2011-10-19 00:37:00 +00:00
}
final Player player = getPlayer(args[0]);
if (player == null)
{
playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
fd.setFrozen(!fd.isFrozen());
playerMsg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
return true;
}
2011-10-19 00:37:00 +00:00
}