TotalFreedomMod/src/me/totalfreedom/totalfreedommod/commands/Command_fr.java

85 lines
2.8 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod.commands;
2011-10-19 00:37:00 +00:00
import me.totalfreedom.totalfreedommod.permission.PlayerRank;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
2014-01-15 17:51:07 +00:00
import org.bukkit.Bukkit;
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]")
public class Command_fr extends FreedomCommand
2011-10-19 00:37:00 +00:00
{
private static boolean allFrozen = false;
2011-10-19 00:37:00 +00:00
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0)
2011-10-19 00:37:00 +00:00
{
allFrozen = !allFrozen;
if (allFrozen)
{
FUtil.adminAction(sender.getName(), "Freezing all players", false);
setAllFrozen(true);
playerMsg("Players are now frozen.");
2014-01-15 21:45:28 +00:00
for (Player player : Bukkit.getOnlinePlayers())
2014-01-15 21:38:35 +00:00
{
if (!isAdmin(player))
2014-01-15 21:45:28 +00:00
{
playerMsg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
2014-01-15 21:45:28 +00:00
}
2014-01-15 21:38:35 +00:00
}
}
else
2011-10-19 00:37:00 +00:00
{
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
setAllFrozen(false);
playerMsg("Players are now free to move.");
}
}
else
{
if (args[0].toLowerCase().equals("purge"))
{
setAllFrozen(false);
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
2011-10-19 00:37:00 +00:00
}
else
{
final Player player = getPlayer(args[0]);
if (player == null)
2011-10-19 00:37:00 +00:00
{
playerMsg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
return true;
}
2011-10-19 00:37:00 +00:00
final FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.setFrozen(!playerdata.isFrozen());
2011-10-19 00:37:00 +00:00
2013-08-14 14:01:42 +00:00
playerMsg(player.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
playerMsg(player, "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
2011-10-19 00:37:00 +00:00
}
}
return true;
}
public static void setAllFrozen(boolean freeze)
{
allFrozen = freeze;
for (FPlayer data : TotalFreedomMod.plugin.pl.playerMap.values())
{
data.setFrozen(freeze);
}
}
2011-10-19 00:37:00 +00:00
}