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;
|
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
@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)
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
if (args.length == 0)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +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
|
|
|
{
|
2012-11-24 01:22:52 +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
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
for (Player p : server.getOnlinePlayers())
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
|
|
|
playerdata.setFrozen(false);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
|
|
|
TFM_Util.adminAction(sender.getName(), "Lifting all global and player freezes", false);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
Player p;
|
|
|
|
try
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
p = getPlayer(args[0]);
|
2011-10-19 00:37:00 +00:00
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
catch (CantFindPlayerException ex)
|
2011-10-19 00:37:00 +00:00
|
|
|
{
|
2012-11-24 01:22:52 +00:00
|
|
|
sender.sendMessage(ex.getMessage());
|
|
|
|
return true;
|
|
|
|
}
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +00:00
|
|
|
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
|
|
|
|
playerdata.setFrozen(!playerdata.isFrozen());
|
2011-10-19 00:37:00 +00:00
|
|
|
|
2012-11-24 01:22:52 +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;
|
|
|
|
}
|
|
|
|
}
|