From cdcc1e666a51b97573dc19aacc22006ad81c9117 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Mon, 21 Nov 2011 01:47:19 -0500 Subject: [PATCH] Forgot to commit this... --- nbproject/project.properties | 4 +- .../Commands/Command_cmdlist.java | 49 +++++++++++++++++++ .../Commands/Command_radar.java | 7 ++- .../Commands/Command_rawsay.java | 30 ++++++++++++ .../Commands/Command_saconfig.java | 16 +++--- .../TotalFreedomMod/Commands/Command_umd.java | 39 --------------- .../Listener/TFM_PlayerListener.java | 4 +- .../TotalFreedomMod/TFM_Util.java | 12 ++--- .../TotalFreedomMod/TotalFreedomMod.java | 2 +- src/plugin.yml | 9 ++-- 10 files changed, 106 insertions(+), 66 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_rawsay.java delete mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_umd.java diff --git a/nbproject/project.properties b/nbproject/project.properties index f78dd2d..760660d 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -26,12 +26,10 @@ dist.jar=${dist.dir}/TotalFreedomMod.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= -file.reference.MobDisguise.jar=../MobDisguise/dist/MobDisguise.jar includes=** jar.compress=false javac.classpath=\ - ${libs.Bukkit.classpath}:\ - ${file.reference.MobDisguise.jar} + ${libs.Bukkit.classpath} # Space-separated list of extra javac options javac.compilerargs=-Xlint:unchecked javac.deprecation=false diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java new file mode 100644 index 0000000..889da32 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java @@ -0,0 +1,49 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; + +public class Command_cmdlist extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + List commands = new ArrayList(); + + for (Plugin p : plugin.getServer().getPluginManager().getPlugins()) + { + try + { + PluginDescriptionFile desc = p.getDescription(); + Map> map = (Map>) desc.getCommands(); + + if (map != null) + { + for (Entry> entry : map.entrySet()) + { + String command_name = (String) entry.getKey(); + commands.add(command_name); + } + } + } + catch (Throwable ex) + { + } + } + + Collections.sort(commands); + + sender.sendMessage(TFM_Util.implodeStringList(",", commands)); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_radar.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_radar.java index ad83fd3..68d267e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_radar.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_radar.java @@ -5,7 +5,6 @@ import java.util.Collections; import java.util.List; import me.StevenLawson.TotalFreedomMod.TFM_RadarData; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import me.desmin88.mobdisguise.api.MobDisguiseAPI; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.Command; @@ -65,10 +64,10 @@ public class Command_radar extends TFM_Command for (TFM_RadarData i : radar_data) { - sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s", + sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d", i.player.getName(), - Math.round(i.distance), - MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No")); + Math.round(i.distance) + )); if (--countmax <= 0) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rawsay.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rawsay.java new file mode 100644 index 0000000..82ce19d --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rawsay.java @@ -0,0 +1,30 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import java.util.Arrays; +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_rawsay extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit")) + { + sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console."); + return true; + } + + if (args.length == 0) + { + return false; + } + + TFM_Util.bcastMsg(TFM_Util.implodeStringList(" ", Arrays.asList(args))); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index 7a28ad5..063f4d3 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -47,16 +47,16 @@ public class Command_saconfig extends TFM_Command boolean something_changed = false; - if (!plugin.superadmins.contains(user_name)) + if (!TotalFreedomMod.superadmins.contains(user_name)) { - plugin.superadmins.add(user_name); + TotalFreedomMod.superadmins.add(user_name); sender.sendMessage("Adding new superadmin: " + user_name); something_changed = true; } - if (!plugin.superadmin_ips.contains(new_ip)) + if (!TotalFreedomMod.superadmin_ips.contains(new_ip)) { - plugin.superadmin_ips.add(new_ip); + TotalFreedomMod.superadmin_ips.add(new_ip); sender.sendMessage("Adding new superadmin IP: " + new_ip); something_changed = true; } @@ -71,7 +71,7 @@ public class Command_saconfig extends TFM_Command List user_ips = new ArrayList(); if (config.contains(user_name)) { - user_ips = config.getStringList(user_name); + user_ips = config.getStringListFixed(user_name); } if (!user_ips.contains(new_ip)) @@ -118,14 +118,14 @@ public class Command_saconfig extends TFM_Command return true; } - plugin.superadmins.remove(user_name); + TotalFreedomMod.superadmins.remove(user_name); if (config.contains(user_name)) { - List user_ips = config.getStringList(user_name); + List user_ips = config.getStringListFixed(user_name); for (String ip : user_ips) { - plugin.superadmin_ips.remove(ip); + TotalFreedomMod.superadmin_ips.remove(ip); } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_umd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_umd.java deleted file mode 100644 index ed69b50..0000000 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_umd.java +++ /dev/null @@ -1,39 +0,0 @@ -package me.StevenLawson.TotalFreedomMod.Commands; - -import me.StevenLawson.TotalFreedomMod.TFM_Util; -import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import me.desmin88.mobdisguise.api.MobDisguiseAPI; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public class Command_umd extends TFM_Command -{ - @Override - public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) - { - for (Player p : Bukkit.getOnlinePlayers()) - { - if (MobDisguiseAPI.isDisguised(p)) - { - p.sendMessage(ChatColor.GRAY + "You have been undisguised by an administrator."); - } - - MobDisguiseAPI.undisguisePlayer(p); - MobDisguiseAPI.undisguisePlayerAsPlayer(p, ""); - } - - sender.sendMessage(ChatColor.GRAY + "All players have been undisguised."); - } - else - { - sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); - } - - return true; - } -} diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 218d25c..7c7797b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -339,14 +339,14 @@ public class TFM_PlayerListener extends PlayerListener if (!Bukkit.getOnlineMode()) { Player p = event.getPlayer(); - if (plugin.superadmins.contains(p.getName().toLowerCase())) + if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase())) { String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); if (user_ip != null && !user_ip.isEmpty()) { TFM_Util.checkPartialSuperadminIP(user_ip, plugin); - if (!plugin.superadmin_ips.contains(user_ip)) + if (!TotalFreedomMod.superadmin_ips.contains(user_ip)) { TFM_Util.bcastMsg(p.getName() + " might be a fake! IP: " + user_ip, ChatColor.RED); p.setOp(false); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 5214ad1..e193fdc 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -257,7 +257,7 @@ public class TFM_Util if (Bukkit.getOnlineMode()) { - if (tfm.superadmins.contains(user.getName().toLowerCase())) + if (TotalFreedomMod.superadmins.contains(user.getName().toLowerCase())) { return true; } @@ -272,7 +272,7 @@ public class TFM_Util String user_ip = ip_address_obj.getAddress().toString().replaceAll("/", "").trim(); if (user_ip != null && !user_ip.isEmpty()) { - if (tfm.superadmin_ips.contains(user_ip)) + if (TotalFreedomMod.superadmin_ips.contains(user_ip)) { return true; } @@ -292,7 +292,7 @@ public class TFM_Util { user_ip = user_ip.trim(); - if (tfm.superadmin_ips.contains(user_ip)) + if (TotalFreedomMod.superadmin_ips.contains(user_ip)) { return true; } @@ -305,7 +305,7 @@ public class TFM_Util } String match_ip = null; - for (String test_ip : tfm.superadmin_ips) + for (String test_ip : TotalFreedomMod.superadmin_ips) { String[] test_octets = test_ip.split("\\."); if (test_octets.length == 4) @@ -320,14 +320,14 @@ public class TFM_Util if (match_ip != null) { - tfm.superadmin_ips.add(user_ip); + TotalFreedomMod.superadmin_ips.add(user_ip); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(tfm.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE)); fileloop: for (String user : config.getKeys(false)) { - List user_ips = config.getStringList(user); + List user_ips = config.getStringListFixed(user); for (String ip : user_ips) { ip = ip.toLowerCase().trim(); diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index e3366da..56bfacc 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -176,7 +176,7 @@ public class TotalFreedomMod extends JavaPlugin { superadmins.add(user.toLowerCase().trim()); - List user_ips = config.getStringList(user); + List user_ips = config.getStringListFixed(user); for (String ip : user_ips) { ip = ip.toLowerCase().trim(); diff --git a/src/plugin.yml b/src/plugin.yml index c36137d..ec9b720 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -10,6 +10,9 @@ commands: cake: description: Superadmin command - For the people that are still alive. usage: / + cmdlist: + description: Show all commands for all server plugins. + usage: / creative: description: Quickly change your own gamemode to creative, or define someone's username to change theirs. usage: / [partialname] @@ -92,6 +95,9 @@ commands: radar: description: Shows nearby people sorted by distance. usage: / [range] + rawsay: + description: Owner Command - Broadcasts the given message with no extra formatting. + usage: / rd: description: Remove drops, arrows, primed TNT, and expierence orbs in all worlds. usage: / @@ -131,9 +137,6 @@ commands: tossmob: description: Throw a mob in the direction you are facing when you left click with a stick. usage: / [mobtype | off] [speed] - umd: - description: Superadmin command - Undisguse all players. - usage: / waterplace: description: Superadmin command - Enable/disable water placement. usage: /