added /halt

This commit is contained in:
Jerom van der Sar 2012-09-18 12:13:06 +02:00
parent 8884b478aa
commit 5234f3c807
4 changed files with 88 additions and 1 deletions

View File

@ -26,6 +26,7 @@ public class Command_glist extends TFM_Command
{ {
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
TFM_Util.adminAction(sender.getName(), "Purging the banlist", true);
TFM_UserList.getInstance(plugin).purge(); TFM_UserList.getInstance(plugin).purge();
return true; return true;
} }

View File

@ -0,0 +1,74 @@
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.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_halt extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if(!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if(args.length != 1)
{
return false;
}
Player p;
try
{
p = getPlayer(args[0]);
}
catch(CantFindPlayerException ex)
{
sender.sendMessage(ex.getMessage());
return true;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
if(!playerdata.isHalted())
{
TFM_Util.adminAction(sender.getName(), "Halting " + p.getName(), true);
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.setFlying(false);
p.setDisplayName(p.getName());
p.closeInventory();
p.setTotalExperience(0);
playerdata.stopOrbiting();
playerdata.setFrozen(true);
playerdata.setMuted(true);
TFM_Util.playerMsg(p, "You have been halted, don't move!");
return true;
}
else
{
TFM_Util.adminAction(sender.getName(), "Unhalting " + p.getName(), true);
p.setOp(true);
p.setGameMode(GameMode.CREATIVE);
playerdata.setFrozen(false);
playerdata.setMuted(false);
TFM_Util.playerMsg(p, "You are no longer halted.");
return true;
}
}
}

View File

@ -170,7 +170,8 @@ public class Command_whitelist extends TFM_Command
//purge //purge
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
Set whitelisted = MinecraftServer.getServer().getServerConfigurationManager().getWhitelisted(); @SuppressWarnings("rawtypes")
Set whitelisted = MinecraftServer.getServer().getServerConfigurationManager().getWhitelisted();
TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist.", false); TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist.", false);
TFM_Util.playerMsg(sender, "Removed " + whitelisted.size() + " players from the whitelist."); TFM_Util.playerMsg(sender, "Removed " + whitelisted.size() + " players from the whitelist.");
whitelisted.clear(); whitelisted.clear();

View File

@ -17,6 +17,7 @@ public class TFM_UserInfo
private Player player; private Player player;
private boolean user_frozen = false; private boolean user_frozen = false;
private boolean is_muted = false; private boolean is_muted = false;
private boolean is_halted = false;
private int msg_count = 0; private int msg_count = 0;
private int block_destroy_total = 0; private int block_destroy_total = 0;
private int block_place_total = 0; private int block_place_total = 0;
@ -338,4 +339,14 @@ public class TFM_UserInfo
{ {
this.is_muted = is_muted; this.is_muted = is_muted;
} }
public boolean isHalted()
{
return this.is_halted;
}
public void setHalted(boolean is_halted)
{
this.is_halted = is_halted;
}
} }