From bfa0324af9482df0da3517f0552d1e774fc5554e Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Fri, 21 Dec 2012 22:22:08 -0500 Subject: [PATCH] Removing tests. Since we don't do those. Added /lastcmd. Added /tfupdate, mainly for my own use. --- nbproject/build-impl.xml | 37 +++------- nbproject/genfiles.properties | 4 +- nbproject/project.properties | 1 - nbproject/project.xml | 4 +- .../Commands/Command_lastcmd.java | 46 +++++++++++++ .../Commands/Command_tfupdate.java | 67 +++++++++++++++++++ .../Listener/TFM_PlayerListener.java | 2 + .../TotalFreedomMod/TFM_UserInfo.java | 11 +++ .../TotalFreedomMod/TFM_Util.java | 12 +++- src/plugin.yml | 8 ++- 10 files changed, 156 insertions(+), 36 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfupdate.java diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index b37e8838..48e87333 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -134,9 +134,7 @@ is divided into following sections: - - - + @@ -229,7 +227,6 @@ is divided into following sections: Must set src.dir - Must set test.src.dir Must set build.dir Must set dist.dir Must set build.classes.dir @@ -403,11 +400,7 @@ is divided into following sections: - - - - - + @@ -432,11 +425,7 @@ is divided into following sections: - - - - - + @@ -544,11 +533,7 @@ is divided into following sections: - - - - - + @@ -1231,13 +1216,11 @@ is divided into following sections: - + - - - - + + @@ -1251,10 +1234,8 @@ is divided into following sections: Must select some files in the IDE or set javac.includes - - - - + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 947ef47f..94091872 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=b1031e10 build.xml.stylesheet.CRC32=28e38971@1.44.1.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=7bf70ec5 -nbproject/build-impl.xml.script.CRC32=8511de95 +nbproject/build-impl.xml.data.CRC32=0753327a +nbproject/build-impl.xml.script.CRC32=fe17df45 nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/nbproject/project.properties b/nbproject/project.properties index 276473c3..08662639 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -82,4 +82,3 @@ run.test.classpath=\ ${build.test.classes.dir} source.encoding=UTF-8 src.dir=src -test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 1f0261bf..b1406fe3 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -7,9 +7,7 @@ - - - + diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java new file mode 100644 index 00000000..819a68c0 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_lastcmd.java @@ -0,0 +1,46 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; +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; + +@CommandPermissions(level = ADMIN_LEVEL.SUPER, source = SOURCE_TYPE_ALLOWED.BOTH, ignore_permissions = false) +public class Command_lastcmd extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (args.length == 0) + { + 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 != null) + { + String last_command = playerdata.getLastCommand(); + if (last_command.isEmpty()) + { + last_command = "(none)"; + } + TFM_Util.playerMsg(sender, p.getName() + " - Last Command: " + last_command, ChatColor.GRAY); + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfupdate.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfupdate.java new file mode 100644 index 00000000..e3af55e4 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfupdate.java @@ -0,0 +1,67 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import java.io.File; +import me.StevenLawson.TotalFreedomMod.TFM_Log; +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = ADMIN_LEVEL.SENIOR, source = SOURCE_TYPE_ALLOWED.ONLY_CONSOLE, block_host_console = true, ignore_permissions = false) +public class Command_tfupdate extends TFM_Command +{ + public static final String[] FILES = + { + "http://s3.madgeekonline.com/totalfreedom/BukkitHttpd.jar", + "http://s3.madgeekonline.com/totalfreedom/BukkitTelnet.jar", + "http://s3.madgeekonline.com/totalfreedom/Essentials.jar", + "http://s3.madgeekonline.com/totalfreedom/EssentialsSpawn.jar", + "http://s3.madgeekonline.com/totalfreedom/TotalFreedomMod.jar", + "http://s3.madgeekonline.com/totalfreedom/craftbukkit.jar", + "http://s3.madgeekonline.com/totalfreedom/worldedit.jar" + }; + + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!sender.getName().equalsIgnoreCase("madgeek1450")) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + for (final String url : FILES) + { + server.getScheduler().runTaskAsynchronously(plugin, new Runnable() + { + @Override + public void run() + { + try + { + TFM_Log.info("Downloading: " + url); + + File file = new File("./updates/" + url.substring(url.lastIndexOf("/") + 1)); + if (file.exists()) + { + file.delete(); + } + if (!file.getParentFile().exists()) + { + file.getParentFile().mkdirs(); + } + + TFM_Util.downloadFile(url, file, true); + } + catch (Exception ex) + { + TFM_Log.severe(ex); + } + } + }); + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index c7cce67f..69f81a21 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -468,6 +468,8 @@ public class TFM_PlayerListener implements Listener TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", p.getName(), ChatColor.stripColor(p.getDisplayName()), command), true); } + playerdata.setLastCommand(command); + command = command.toLowerCase().trim(); boolean block_command = false; diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java index 499c0913..a54e0e99 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java @@ -48,6 +48,7 @@ public class TFM_UserInfo private boolean in_adminchat = false; private boolean all_commands_blocked = false; private Boolean superadmin_id_verified = null; + private String last_command = ""; public TFM_UserInfo(Player player) { @@ -453,4 +454,14 @@ public class TFM_UserInfo { this.superadmin_id_verified = superadmin_id_verified; } + + public String getLastCommand() + { + return last_command; + } + + public void setLastCommand(String last_command) + { + this.last_command = last_command; + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 110181ca..bf1d27c0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -937,13 +937,23 @@ public class TFM_Util return affected; } - public static void downloadFile(String url, File output_file) throws Exception + public static void downloadFile(String url, File output_file) throws java.lang.Exception + { + downloadFile(url, output_file, false); + } + + public static void downloadFile(String url, File output_file, boolean verbose) throws java.lang.Exception { URL website = new URL(url); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(output_file); fos.getChannel().transferFrom(rbc, 0, 1 << 24); fos.close(); + + if (verbose) + { + TFM_Log.info("Downloaded " + url + " to " + output_file.toString() + "."); + } } public static void adminChatMessage(CommandSender sender, String message, boolean senderIsConsole) diff --git a/src/plugin.yml b/src/plugin.yml index 4aae6011..a64f2fa7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -98,6 +98,9 @@ commands: landmine: description: Set a landmine trap. usage: / + lastcmd: + description: Superadmin command - Show the last command that someone used. + usage: / lavadmg: description: Superadmin command - Enable/disable lava damage. usage: / @@ -186,7 +189,7 @@ commands: usage: / [radius (default=50)] [player] saconfig: description: Senior Command - Manage superadmins. - usage: / > + usage: / > say: description: Broadcasts the given message as the console, includes sender name. usage: / @@ -227,6 +230,9 @@ commands: tfipbanlist: description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list. usage: / [purge] + tfupdate: + description: Madgeek command - Update server files. + usave: / tossmob: description: Throw a mob in the direction you are facing when you left click with a stick. usage: /