From 89cfbbcef8b051e1a14d99602255cbee4363e86e Mon Sep 17 00:00:00 2001 From: Jerome van der Sar Date: Sun, 16 Sep 2012 14:11:33 +0200 Subject: [PATCH] Added /ops list --- .gitignore | 15 ++++++++ .../Commands/CantFindPlayerException.java | 5 ++- .../TotalFreedomMod/Commands/Command_ops.java | 34 ++++++++++++++++--- .../Commands/Command_stfu.java | 1 - .../Listener/TFM_BlockListener.java | 6 ---- .../Listener/TFM_EntityListener.java | 6 ---- .../Listener/TFM_PlayerListener.java | 18 ++++------ .../Listener/TFM_WeatherListener.java | 8 +---- .../TotalFreedomMod/TotalFreedomMod.java | 8 ++--- 9 files changed, 61 insertions(+), 40 deletions(-) diff --git a/.gitignore b/.gitignore index abf4a5b0..3910da63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,20 @@ +# netbeans excludes (StevenLawson) /nbproject/private/ /dist/ /build/ appinfo.properties buildnumber.properties + +# eclipse excludes (JeromSar) +.project +.classpath +/bin/ +/.settings/ + +# OS generated files +.DS_Store +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db \ No newline at end of file diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java b/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java index a68bb13d..8eb4d945 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/CantFindPlayerException.java @@ -4,7 +4,10 @@ import org.bukkit.ChatColor; public class CantFindPlayerException extends Exception { - public CantFindPlayerException() + // apparently, java needs this + private static final long serialVersionUID = 1L; + + public CantFindPlayerException() { super(ChatColor.GRAY + "Can't find player."); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java index fa4505b1..f71b35f6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java @@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -15,12 +14,34 @@ public class Command_ops extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (args.length > 1) + if (!(senderIsConsole || sender.isOp())) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + if (args.length < 1 || args.length > 1) { return false; } + + + if (args[0].equalsIgnoreCase("list")) + { + String ops = ""; + String delim = ""; + for (OfflinePlayer p : server.getOperators()) { + ops += delim; + ops += p.getName(); + delim = ","; + } + + TFM_Util.playerMsg(sender, "Operators: " + ops); - if (args.length == 0 || args[0].equalsIgnoreCase("list")) + return true; + } + + if (args[0].equalsIgnoreCase("count")) { int onlineOPs = 0; int offlineOPs = 0; @@ -42,8 +63,11 @@ public class Command_ops extends TFM_Command sender.sendMessage(ChatColor.GRAY + "Online OPs: " + onlineOPs); sender.sendMessage(ChatColor.GRAY + "Offline OPs: " + offlineOPs); sender.sendMessage(ChatColor.GRAY + "Total OPs: " + totalOPs); + + return true; } - else if (args[0].equalsIgnoreCase("purge")) + + if (args[0].equalsIgnoreCase("purge")) { if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) { @@ -62,6 +86,8 @@ public class Command_ops extends TFM_Command p.getPlayer().sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } } + + return true; } return true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java index 98f900ce..7579657b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java @@ -3,7 +3,6 @@ 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.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java index 25abb746..77966bb4 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java @@ -16,12 +16,6 @@ import org.bukkit.inventory.ItemStack; public class TFM_BlockListener implements Listener { - private final TotalFreedomMod plugin; - - public TFM_BlockListener(TotalFreedomMod instance) - { - this.plugin = instance; - } @EventHandler(priority = EventPriority.HIGH) public void onBlockBurn(BlockBurnEvent event) diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java index 82b3d195..bfe92095 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java @@ -9,12 +9,6 @@ import org.bukkit.event.entity.*; public class TFM_EntityListener implements Listener { - private final TotalFreedomMod plugin; - - public TFM_EntityListener(TotalFreedomMod instance) - { - this.plugin = instance; - } @EventHandler(priority = EventPriority.HIGH) public void onEntityExplode(EntityExplodeEvent event) diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index a1809fa2..fbd42530 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -25,13 +25,8 @@ import org.bukkit.util.Vector; public class TFM_PlayerListener implements Listener { - private final TotalFreedomMod plugin; private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z"); - public TFM_PlayerListener(TotalFreedomMod instance) - { - this.plugin = instance; - } @EventHandler(priority = EventPriority.HIGH) public void onPlayerInteract(PlayerInteractEvent event) @@ -91,7 +86,7 @@ public class TFM_PlayerListener implements Listener { if (playerdata.toggleMP44Firing()) { - playerdata.startArrowShooter(plugin); + playerdata.startArrowShooter(TotalFreedomMod.plugin); } else { @@ -494,7 +489,7 @@ public class TFM_PlayerListener implements Listener { final Player p = event.getPlayer(); - TFM_UserList.getInstance(plugin).addUser(p); + TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(p); boolean superadmin_impostor = TFM_Util.isSuperadminImpostor(p); @@ -516,7 +511,7 @@ public class TFM_PlayerListener implements Listener if (TotalFreedomMod.adminOnlyMode) { - plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() + TotalFreedomMod.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(TotalFreedomMod.plugin, new Runnable() { @Override public void run() @@ -534,10 +529,10 @@ public class TFM_PlayerListener implements Listener @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerLogin(PlayerLoginEvent event) { - //This should supercede all other onPlayerLogin authentication on the TFM server. + //This should supersede all other onPlayerLogin authentication on the TFM server. //When using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication. - final Server server = plugin.getServer(); + final Server server = TotalFreedomMod.plugin.getServer(); final ServerConfigurationManagerAbstract scm = MinecraftServer.getServer().getServerConfigurationManager(); final BanList banByIP = scm.getIPBans(); @@ -595,7 +590,8 @@ public class TFM_PlayerListener implements Listener boolean is_ip_banned = false; - Iterator ip_bans = banByIP.getEntries().keySet().iterator(); + @SuppressWarnings("rawtypes") + Iterator ip_bans = banByIP.getEntries().keySet().iterator(); while (ip_bans.hasNext()) { String test_ip = (String) ip_bans.next(); diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java index d80fd255..29c8c9ec 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java @@ -9,13 +9,7 @@ import org.bukkit.event.weather.WeatherChangeEvent; public class TFM_WeatherListener implements Listener { - private final TotalFreedomMod plugin; - - public TFM_WeatherListener(TotalFreedomMod instance) - { - this.plugin = instance; - } - + @EventHandler(priority = EventPriority.HIGH) public void onThunderChange(ThunderChangeEvent event) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 5b97ae9d..193abf0f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -236,10 +236,10 @@ public class TotalFreedomMod extends JavaPlugin { PluginManager pm = server.getPluginManager(); - pm.registerEvents(new TFM_EntityListener(this), this); - pm.registerEvents(new TFM_BlockListener(this), this); - pm.registerEvents(new TFM_PlayerListener(this), this); - pm.registerEvents(new TFM_WeatherListener(this), this); + pm.registerEvents(new TFM_EntityListener(), plugin); + pm.registerEvents(new TFM_BlockListener(), plugin); + pm.registerEvents(new TFM_PlayerListener(), plugin); + pm.registerEvents(new TFM_WeatherListener(), plugin); } private void setAppProperties()