TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java

72 lines
2.6 KiB
Java
Raw Normal View History

2011-10-19 00:37:00 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = false)
2011-10-19 00:37:00 +00:00
public class Command_fr extends TFM_Command
{
@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
{
TotalFreedomMod.allPlayersFrozen = !TotalFreedomMod.allPlayersFrozen;
if (TotalFreedomMod.allPlayersFrozen)
{
TotalFreedomMod.allPlayersFrozen = true;
sender.sendMessage("Players are now frozen.");
TFM_Util.adminAction(sender.getName(), "Freezing all players", false);
}
else
2011-10-19 00:37:00 +00:00
{
TotalFreedomMod.allPlayersFrozen = false;
sender.sendMessage("Players are now free to move.");
TFM_Util.adminAction(sender.getName(), "Unfreezing all players", false);
}
}
else
{
if (args[0].toLowerCase().equals("purge"))
{
TotalFreedomMod.allPlayersFrozen = false;
2011-10-19 00:37:00 +00:00
for (Player p : server.getOnlinePlayers())
2011-10-19 00:37:00 +00:00
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(false);
2011-10-19 00:37:00 +00:00
}
TFM_Util.adminAction(sender.getName(), "Lifting all global and player freezes", false);
2011-10-19 00:37:00 +00:00
}
else
{
Player p;
try
2011-10-19 00:37:00 +00:00
{
p = getPlayer(args[0]);
2011-10-19 00:37:00 +00:00
}
catch (CantFindPlayerException ex)
2011-10-19 00:37:00 +00:00
{
sender.sendMessage(ex.getMessage());
return true;
}
2011-10-19 00:37:00 +00:00
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setFrozen(!playerdata.isFrozen());
2011-10-19 00:37:00 +00:00
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
2011-10-19 00:37:00 +00:00
}
}
return true;
}
}