From 84dbc63f865e0462f34b7c8252bb9b22a4732680 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Mon, 3 Oct 2011 17:41:09 -0400 Subject: [PATCH] Added umd, qual, and gcmd --- nbproject/project.properties | 4 +- .../TotalFreedomMod/TFM_Cmds_Admin.java | 146 +++++++++++++++++- .../TotalFreedomMod/TFM_Cmds_General.java | 7 +- .../TotalFreedomMod/TotalFreedomMod.java | 3 + src/plugin.yml | 13 +- 5 files changed, 165 insertions(+), 8 deletions(-) diff --git a/nbproject/project.properties b/nbproject/project.properties index b57fb2c6..fe5247fc 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -27,10 +27,12 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\github\\Bukkit\\target\\bukkit-0.0.1-SNAPSHOT.jar +file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar includes=** jar.compress=false javac.classpath=\ - ${file.reference.bukkit-0.0.1-SNAPSHOT.jar} + ${file.reference.bukkit-0.0.1-SNAPSHOT.jar}:\ + ${file.reference.MobDisguise.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java index 773c69ea..bca8178f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import java.util.Random; import java.util.logging.Logger; +import me.desmin88.mobdisguise.api.MobDisguiseAPI; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -132,7 +133,10 @@ public class TFM_Cmds_Admin implements CommandExecutor p = matches.get(0); } - plugin.tfm_broadcastMessage(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED); + plugin.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); + + //Undo WorldEdits: + Bukkit.getServer().dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName())); //Deop p.setOp(false); @@ -154,9 +158,6 @@ public class TFM_Cmds_Admin implements CommandExecutor } } - //Attempt to kill: - p.setHealth(0); - //Ban IP Address: String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim(); plugin.tfm_broadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); @@ -405,6 +406,143 @@ public class TFM_Cmds_Admin implements CommandExecutor sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); } + return true; + } + else if (cmd.getName().equalsIgnoreCase("gcmd")) + { + if (senderIsConsole || plugin.isUserSuperadmin(sender)) + { + if (args.length < 2) + { + return false; + } + + Player p; + List matches = Bukkit.matchPlayer(args[0]); + if (matches.isEmpty()) + { + sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]); + return true; + } + else + { + p = matches.get(0); + } + + String outcommand = ""; + try + { + StringBuilder outcommand_bldr = new StringBuilder(); + for (int i = 1; i < args.length; i++) + { + outcommand_bldr.append(args[i]).append(" "); + } + outcommand = outcommand_bldr.toString().trim(); + } + catch (Exception cmdex) + { + sender.sendMessage(ChatColor.GRAY + "Error building command: " + cmdex.getMessage()); + } + + try + { + sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand); + if (Bukkit.getServer().dispatchCommand(p, outcommand)) + { + sender.sendMessage(ChatColor.GRAY + "Command sent."); + } + else + { + sender.sendMessage(ChatColor.GRAY + "Unknown error sending command."); + } + } + catch (Exception cmdex) + { + sender.sendMessage(ChatColor.GRAY + "Error sending command: " + cmdex.getMessage()); + } + } + else + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + } + + return true; + } + else if (cmd.getName().equalsIgnoreCase("qjail")) + { + if (senderIsConsole || plugin.isUserSuperadmin(sender)) + { + if (args.length < 1) + { + return false; + } + + Player p; + List matches = Bukkit.matchPlayer(args[0]); + if (matches.isEmpty()) + { + sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]); + return true; + } + else + { + p = matches.get(0); + } + + //Deop + p.setOp(false); + + //Set gamemode to survival: + p.setGameMode(GameMode.SURVIVAL); + + //Clear inventory: + p.getInventory().clear(); + + //Strike with lightning effect: + final Location target_pos = p.getLocation(); + for (int x = -1; x <= 1; x++) + { + for (int z = -1; z <= 1; z++) + { + final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z); + target_pos.getWorld().strikeLightning(strike_pos); + } + } + + //Send to jail "mgjail": + Bukkit.getServer().dispatchCommand(sender, String.format("tjail %s mgjail", p.getName())); + + plugin.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED); + } + else + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + } + + return true; + } + else if (cmd.getName().equalsIgnoreCase("umd")) + { + if (senderIsConsole || plugin.isUserSuperadmin(sender)) + { + 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/TFM_Cmds_General.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java index c19399b1..cf6ac137 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.logging.Logger; +import me.desmin88.mobdisguise.api.MobDisguiseAPI; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -186,7 +187,11 @@ public class TFM_Cmds_General implements CommandExecutor break; } - sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d blocks away @ %s.", i.player.getName(), Math.round(i.distance), plugin.formatLocation(i.location))); + sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s", + i.player.getName(), + Math.round(i.distance), + MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No" + )); } return true; diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index d30ab1e2..88c460d0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -300,6 +300,9 @@ public class TotalFreedomMod extends JavaPlugin this.getCommand("nonuke").setExecutor(AdminCommands); this.getCommand("prelog").setExecutor(AdminCommands); this.getCommand("cake").setExecutor(AdminCommands); + this.getCommand("gcmd").setExecutor(AdminCommands); + this.getCommand("qjail").setExecutor(AdminCommands); + this.getCommand("umd").setExecutor(AdminCommands); this.getCommand("explosives").setExecutor(AntiblockCommands); this.getCommand("lavadmg").setExecutor(AntiblockCommands); diff --git a/src/plugin.yml b/src/plugin.yml index b6b5ab8e..d52137ec 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -5,7 +5,7 @@ description: Plugin for the Total Freedom server author: StevenLawson / Madgeek1450 commands: cake: - description: For the people that are still alive. + description: Superadmin command - For the people that are still alive. usage: / creative: description: Quickly change your own gamemode to creative, or define someone's username to change theirs. @@ -31,9 +31,12 @@ commands: gadmin: description: Superadmin command - Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci usage: / [list | ] + gcmd: + description: Superadmin command - Send a command as someone else. + usage: / gtfo: description: Superadmin command - Makes someone GTFO (deop and ip ban by username). - usage: / [partialname] + usage: / lavadmg: description: Superadmin command - Enable/disable lava damage. usage: / @@ -61,6 +64,9 @@ commands: prelog: description: Superadmin command - Enable/disable the command prelogger. When this is on, logs will be filled with many duplicate messages. usage: / + qjail: + description: Quick Jail - Quickly jail someone (mgjail must be set as a jail!) + usage: / qdeop: description: Quick De-Op - deop someone based on a partial name. usage: / @@ -88,6 +94,9 @@ commands: survival: description: Quickly change your own gamemode to survival, or define someone's username to change theirs. usage: / [partialname] + umd: + description: Superadmin command - Undisguse all players. + usage: / waterplace: description: Superadmin command - Enable/disable water placement. usage: /