From 5234f3c807ecc7c71a4c7ad44641911c86e6409c Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Tue, 18 Sep 2012 12:13:06 +0200 Subject: [PATCH] added /halt --- .../Commands/Command_glist.java | 1 + .../Commands/Command_halt.java | 74 +++++++++++++++++++ .../Commands/Command_whitelist.java | 3 +- .../TotalFreedomMod/TFM_UserInfo.java | 11 +++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java index c54b6b3..57847e4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_glist.java @@ -26,6 +26,7 @@ public class Command_glist extends TFM_Command { if (args[0].equalsIgnoreCase("purge")) { + TFM_Util.adminAction(sender.getName(), "Purging the banlist", true); TFM_UserList.getInstance(plugin).purge(); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java new file mode 100644 index 0000000..1ea92dd --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java @@ -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; + } + + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java index 17711b8..8c89fd4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java @@ -170,7 +170,8 @@ public class Command_whitelist extends TFM_Command //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.playerMsg(sender, "Removed " + whitelisted.size() + " players from the whitelist."); whitelisted.clear(); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java index 76cd93c..52f298f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java @@ -17,6 +17,7 @@ public class TFM_UserInfo private Player player; private boolean user_frozen = false; private boolean is_muted = false; + private boolean is_halted = false; private int msg_count = 0; private int block_destroy_total = 0; private int block_place_total = 0; @@ -338,4 +339,14 @@ public class TFM_UserInfo { this.is_muted = is_muted; } + + public boolean isHalted() + { + return this.is_halted; + } + + public void setHalted(boolean is_halted) + { + this.is_halted = is_halted; + } }