From 8c38344c99ddfca4b26547848a55fcd819e3252d Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 17 Sep 2012 16:06:27 +0200 Subject: [PATCH 1/5] added /doom --- .../Commands/Command_doom.java | 108 ++++++++++++++++++ src/plugin.yml | 5 +- 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java new file mode 100644 index 0000000..85702ff --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java @@ -0,0 +1,108 @@ +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.GameMode; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_doom extends TFM_Command +{ + @Override + public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if(!(TFM_Util.isUserSuperadmin(sender))) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + if(args.length != 1) + { + return false; + } + + final Player p; + try + { + p = getPlayer(args[0]); + } + catch(CantFindPlayerException ex) + { + sender.sendMessage(ex.getMessage()); + return true; + } + + + TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true); + TFM_Util.bcastMsg(p.getName() + " will be completely obliveriated!", ChatColor.RED); + + final String IP = p.getAddress().getAddress().getHostAddress().trim(); + + // remove from superadmin + if(TFM_Util.isUserSuperadmin(p)) + { + server.dispatchCommand(sender, "saconfig delete " + p.getName()); + } + + // remove from whitelist + p.setWhitelisted(false); + + // deop + p.setOp(false); + + // ban IP + Bukkit.banIP(IP); + + // ban name + p.setBanned(true); + + // set gamemode to survival + p.setGameMode(GameMode.SURVIVAL); + + // clear inventory + p.closeInventory(); + p.getInventory().clear(); + + // ignite player + p.setFireTicks(10000); + + // generate explosion + p.getWorld().createExplosion(p.getLocation(), 4F); + + server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() + { + @Override + public void run() { + // strike lightning + p.getWorld().strikeLightning(p.getLocation()); + + // kill (if not done already) + p.setHealth(0); + } + + }, 40L); // 2 seconds + + server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() + { + @Override + public void run() { + // message + TFM_Util.adminAction(sender.getName(), "Banning " + p.getName() + ", IP: " + IP, true); + + // generate explosion + p.getWorld().createExplosion(p.getLocation(), 4F); + + // kick player + p.kickPlayer(ChatColor.RED + "You, my dear friend must FUCKOFF!"); + } + + }, 60L); // 3 seconds + + return true; + } +} diff --git a/src/plugin.yml b/src/plugin.yml index 1e7bf4b..3f964e7 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -24,13 +24,16 @@ commands: usage: / [partialname] csay: description: Telnet command - Send a chat message with chat formatting over telnet. - usage: / [partialname] + usage: / deop: description: Superadmin command - Deop a player usage: / deopall: description: Superadmin command - Deop everyone on the server. usage: / + doom: + description: Owner command - For the worst of the worst, completely remove a player. + usage: / enchant: description: Enchant items. usage: / | remove > From 92110f78c4d80094a302034f9ee19555cf2fb74f Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 17 Sep 2012 18:29:43 +0200 Subject: [PATCH 2/5] General stuff & whitelist (work in progress) --- .../Commands/Command_adminmode.java | 4 +- .../Commands/Command_doom.java | 21 ++++- .../TotalFreedomMod/Commands/Command_ops.java | 14 +-- .../Commands/Command_qdeop.java | 4 +- .../TotalFreedomMod/Commands/Command_qop.java | 4 +- .../Commands/Command_saconfig.java | 5 + .../Commands/Command_stfu.java | 27 +++++- .../Commands/Command_whitelist.java | 93 +++++++++++++++++++ .../Listener/TFM_PlayerListener.java | 33 ++++--- .../TotalFreedomMod/TFM_Util.java | 27 +++++- .../TotalFreedomMod/TFM_message.java | 26 ++++++ .../TotalFreedomMod/TotalFreedomMod.java | 1 + src/plugin.yml | 9 +- 13 files changed, 221 insertions(+), 47 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/TFM_message.java diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java index 37eee7e..3995bbe 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_adminmode.java @@ -21,13 +21,13 @@ public class Command_adminmode extends TFM_Command if (args[0].equalsIgnoreCase("off")) { TotalFreedomMod.adminOnlyMode = false; - TFM_Util.bcastMsg("Server is now open to all players.", ChatColor.RED); + TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true); return true; } else if (args[0].equalsIgnoreCase("on")) { TotalFreedomMod.adminOnlyMode = true; - TFM_Util.bcastMsg("Server is now closed to non-superadmins.", ChatColor.RED); + TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true); for (Player p : server.getOnlinePlayers()) { if (!TFM_Util.isUserSuperadmin(p)) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java index 85702ff..e5924bf 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java @@ -1,5 +1,8 @@ package me.StevenLawson.TotalFreedomMod.Commands; +import java.util.Arrays; +import java.util.List; + import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; @@ -12,10 +15,22 @@ import org.bukkit.entity.Player; public class Command_doom extends TFM_Command { + public String[] p = + { + "madgeek", + "darth", + "madgeek1450", + "mark", + "markbyron", + "darthsalamon" + }; + + public List players = Arrays.asList(p); + @Override public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if(!(TFM_Util.isUserSuperadmin(sender))) + if(!(senderIsConsole && players.contains(sender.getName().toLowerCase()))) { sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); return true; @@ -39,7 +54,7 @@ public class Command_doom extends TFM_Command TFM_Util.adminAction(sender.getName(), "Casting oblivion over " + p.getName(), true); - TFM_Util.bcastMsg(p.getName() + " will be completely obliveriated!", ChatColor.RED); + TFM_Util.bcastMsg(p.getName() + " will be completely obliviated!", ChatColor.RED); final String IP = p.getAddress().getAddress().getHostAddress().trim(); @@ -98,7 +113,7 @@ public class Command_doom extends TFM_Command p.getWorld().createExplosion(p.getLocation(), 4F); // kick player - p.kickPlayer(ChatColor.RED + "You, my dear friend must FUCKOFF!"); + p.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!"); } }, 60L); // 3 seconds diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java index af6baa4..dabae05 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_ops.java @@ -26,16 +26,10 @@ public class Command_ops extends TFM_Command if (args[0].equalsIgnoreCase("list")) { - String ops = ""; - String delim = ""; - for (OfflinePlayer p : server.getOperators()) - { - ops += delim; - ops += p.getName(); - delim = ","; - } + String ops = TFM_Util.arrayToString(server.getOperators()); - TFM_Util.playerMsg(sender, "Operators: " + ops); + TFM_Util.playerMsg(sender, "Operators:"); + TFM_Util.playerMsg(sender, ops); return true; } @@ -68,7 +62,7 @@ public class Command_ops extends TFM_Command if (args[0].equalsIgnoreCase("purge")) { - if (!(TFM_Util.isUserSuperadmin(sender) || senderIsConsole)) + if (!senderIsConsole) { sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); return true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java index b5ad769..b03d1f9 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java @@ -24,11 +24,11 @@ public class Command_qdeop extends TFM_Command boolean matched_player = false; - String target_name = args[0].toLowerCase(); + String target = args[0].toLowerCase(); for (Player p : server.getOnlinePlayers()) { - if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0) + if (p.getName().toLowerCase().contains(target)) { matched_player = true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java index 57d09a1..f8a5f99 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java @@ -24,11 +24,11 @@ public class Command_qop extends TFM_Command boolean matched_player = false; - String target_name = args[0].toLowerCase(); + String target = args[0].toLowerCase(); for (Player p : server.getOnlinePlayers()) { - if (p.getName().toLowerCase().indexOf(target_name) > 0 || p.getDisplayName().toLowerCase().indexOf(target_name) > 0) + if (p.getName().toLowerCase().contains(target)) { matched_player = true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index 49adf4a..db01fe8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -36,6 +36,11 @@ public class Command_saconfig extends TFM_Command return true; } + if (sender.getName().equalsIgnoreCase("remotebukkit")) + { + sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); + } + if (args.length < 2) { return false; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stfu.java index 7579657..096a6c0 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.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -15,7 +14,7 @@ public class Command_stfu extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (args.length < 1 || args.length > 1) + if (args.length != 1) { return false; } @@ -49,7 +48,7 @@ public class Command_stfu extends TFM_Command if (args[0].equalsIgnoreCase("purge")) { - TFM_Util.bcastMsg(ChatColor.RED + sender.getName() + " - Unmuting all players."); + TFM_Util.adminAction(sender.getName(), "Unmuting all players.", true); TFM_UserInfo info; int count = 0; for (Player mp : server.getOnlinePlayers()) @@ -64,7 +63,27 @@ public class Command_stfu extends TFM_Command TFM_Util.playerMsg(sender, "Unmuted " + count + " players."); return true; } - + + if(args[0].equalsIgnoreCase("all")) + { + TFM_Util.adminAction(sender.getName(), "Muting all non-Superadmins", true); + + TFM_UserInfo playerdata; + int counter = 0; + for(Player p : server.getOnlinePlayers()) + { + if(!TFM_Util.isUserSuperadmin(p)) + { + playerdata = TFM_UserInfo.getPlayerData(p); + playerdata.setMuted(true); + counter++; + } + } + + TFM_Util.playerMsg(sender, "Muted " + counter + " players."); + + } + Player p; try { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java new file mode 100644 index 0000000..bc6dea5 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java @@ -0,0 +1,93 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; + +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_whitelist extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if(args.length < 1) + { + return false; + } + + if(!sender.isOp()) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + // list + if(args[0].equalsIgnoreCase("list")) + { + String players = TFM_Util.arrayToString(server.getWhitelistedPlayers()); + + TFM_Util.playerMsg(sender, "Whitelisted players:"); + TFM_Util.playerMsg(sender, players); + return true; + } + + // count + if(args[0].equalsIgnoreCase("count")) + { + int onlineWPs = 0; + int offlineWPs = 0; + int totalWPs = 0; + + for (OfflinePlayer p : server.getWhitelistedPlayers()) + { + if (p.isOnline()) + { + onlineWPs++; + } + else + { + offlineWPs++; + } + totalWPs++; + } + + sender.sendMessage(ChatColor.GRAY + "Online whitelisted players: " + onlineWPs); + sender.sendMessage(ChatColor.GRAY + "Offline whitelisted players: " + offlineWPs); + sender.sendMessage(ChatColor.GRAY + "Total whitelisted players: " + totalWPs); + + return true; + } + + // all commands past this line are superadmin-only + if(!(senderIsConsole || TFM_Util.isUserSuperadmin(sender))) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + + // addall + if(args[0].equalsIgnoreCase("addall")) + { + TFM_Util.adminAction(sender.getName(), "Adding all online players to the whitelist", false); + int counter = 0; + for(Player p : server.getOnlinePlayers()) + { + if(!p.isWhitelisted()) + { + p.setWhitelisted(true); + counter++; + } + } + + TFM_Util.playerMsg(sender, "Whitelisted " + counter + " players."); + } + + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index aa17137..6b0f7b8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -231,25 +231,24 @@ public class TFM_PlayerListener implements Listener p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0)); } } + /* + if (p.getItemInHand().getType() == Material.SPECKLED_MELON) + { + if (TFM_Util.isUserSuperadmin(p)) + { + Location from_pos = event.getFrom().clone(); + Location to_pos = event.getTo().clone(); -// if (p.getItemInHand().getType() == Material.SPECKLED_MELON) -// { -// if (TFM_Util.isUserSuperadmin(p)) -// { -// Location from_pos = event.getFrom().clone(); -// Location to_pos = event.getTo().clone(); -// -// /* -// Block block_pos = user_pos.clone().add(user_pos.getDirection().multiply(-2.0)).getBlock(); -// -// if ((block_pos.isEmpty() || block_pos.isLiquid())) -// { -// block_pos.setTypeIdAndData(Material.WOOL.getId(), DyeColor.values()[randomGenerator.nextInt(DyeColor.values().length)].getData(), false); -// } -// */ -// } -// } + + Block block_pos = user_pos.clone().add(user_pos.getDirection().multiply(-2.0)).getBlock(); + if ((block_pos.isEmpty() || block_pos.isLiquid())) + { + block_pos.setTypeIdAndData(Material.WOOL.getId(), DyeColor.values()[randomGenerator.nextInt(DyeColor.values().length)].getData(), false); + } + } + } + */ if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions) { Iterator landmines = TFM_LandmineData.landmines.iterator(); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index d20e030..ccbc178 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -712,16 +712,20 @@ public class TFM_Util if (sender.getName().equalsIgnoreCase("markbyron")) { - return "the " + ChatColor.LIGHT_PURPLE + "server owner" + ChatColor.AQUA + "."; + return "the " + ChatColor.LIGHT_PURPLE + "owner" + ChatColor.AQUA + "."; } if (sender.getName().equalsIgnoreCase("madgeek1450")) { - return "the " + ChatColor.DARK_PURPLE + "server chief-developer" + ChatColor.AQUA + "."; + return "the " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + "."; } if (sender.getName().equalsIgnoreCase("darthsalamon")) { - return "a " + ChatColor.DARK_PURPLE + "server developer" + ChatColor.AQUA + "!"; + return "a " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + "!"; + } + if (sender.getName().equalsIgnoreCase("miwojedk")) + { + return "a " + ChatColor.DARK_RED+ "master-builder" + ChatColor.AQUA + "!"; } if (TFM_Util.isUserSuperadmin(sender)) @@ -734,7 +738,7 @@ public class TFM_Util return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + "."; } - return "a " + ChatColor.GREEN + "standard player" + ChatColor.AQUA + "."; + return "a " + ChatColor.GREEN + "non-OP" + ChatColor.AQUA + "."; } public static void banUsername(String name, String reason, String source, Date expire_date) @@ -921,6 +925,21 @@ public class TFM_Util return c.getTime(); } + + public static String arrayToString(Set set) + { + String players = ""; + String delim = ""; + + for (OfflinePlayer p : set) + { + players += delim; + players += p.getName(); + delim = ", "; + } + + return players; + } // I wrote all this before i discovered getTargetBlock >.> - might come in handy some day... // public static final double LOOKAT_VIEW_HEIGHT = 1.65; // public static final double LOOKAT_STEP_DISTANCE = 0.2; diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_message.java b/src/me/StevenLawson/TotalFreedomMod/TFM_message.java new file mode 100644 index 0000000..ba79493 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_message.java @@ -0,0 +1,26 @@ +package me.StevenLawson.TotalFreedomMod; + +import org.bukkit.ChatColor; + +// Work in progress +@Deprecated +public enum TFM_message { + NO_PERMS(ChatColor.YELLOW + "You do not have permission to use this command."), + YOU_ARE_OP(ChatColor.YELLOW + "You are now op!"), + YOU_ARE_NOT_OP(ChatColor.YELLOW + "You are no longer op!"), + CAKE_LYRICS("But there's no sense crying over every mistake. You just keep on trying till you run out of cake."), + NOT_FROM_CONSOLE("This command may not be used from the console.") + ; + private final String message; + + TFM_message(String message) + { + this.message = message; + } + + @Override + public String toString() + { + return message; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 193abf0..12c9b10 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -29,6 +29,7 @@ public class TotalFreedomMod extends JavaPlugin public static final String SUPERADMIN_FILE = "superadmin.yml"; public static final String COMMAND_PATH = "me.StevenLawson.TotalFreedomMod.Commands"; public static final String COMMAND_PREFIX = "Command_"; + public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command."; public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!"; public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!"; diff --git a/src/plugin.yml b/src/plugin.yml index 40024c6..bb5dc72 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -32,7 +32,7 @@ commands: description: Superadmin command - Deop everyone on the server. usage: / doom: - description: Owner command - For the worst of the worst, completely remove a player. + description: Owner command - For the bad Superadmins. usage: / enchant: description: Enchant items. @@ -165,7 +165,7 @@ commands: usage: / stfu: description: Superadmin Command - Mutes a player with brute force. - usage: / [list | purge | ] + usage: / [ | list | purge | all] aliases: [mute] stop: description: Superadmin command - Kicks everyone and stops the server. @@ -194,11 +194,14 @@ commands: waterplace: description: Superadmin command - Enable/disable water placement. usage: / + whitelist: + description: Superadmin command - Manage the whitelist. + usage: / | remove | addall | purge> wildcard: description: Superadmin command - Run any command on all users, username placeholder = ?. usage: / [fluff] ? [fluff] ? # wipeflatlands: -# description: Console Command - Wipe the flatlands map. +# description: Owner command - Wipe the flatlands map. # usage: / ziptool: description: Owner command - Zip and unzip files. From 013dd1d2ccf99b7cec213def09035c66b233a75b Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 17 Sep 2012 21:57:52 +0200 Subject: [PATCH 3/5] Made /rd simpler --- .../TotalFreedomMod/Commands/Command_rd.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java index 3a5e66e..0478d78 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java @@ -13,27 +13,14 @@ public class Command_rd extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - if (senderIsConsole || sender.isOp()) + if (!(senderIsConsole || TFM_Util.isUserSuperadmin(sender))) { - if (args.length == 1) - { - if (Arrays.asList("minecart", "minecarts", "cart", "carts").contains(args[0].toLowerCase())) - { - sender.sendMessage(ChatColor.GRAY + "Removing all projectiles, dropped items, exp. orbs, primed explosives, and minecarts."); - sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed."); - } - } - else - { - sender.sendMessage(ChatColor.GRAY + "Removing all projectiles, dropped items, exp. orbs and primed explosives."); - sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true)) + " enties removed."); - } + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; } - else - { - sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); - } - + TFM_Util.adminAction(sender.getName(), "Removing all server entities", false); + sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeEntities(true, true)) + " enties removed."); + return true; } } From 2e32eec3b669a69d2382a93aae5add9377a8ae79 Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 17 Sep 2012 22:27:31 +0200 Subject: [PATCH 4/5] Finished /whitelist --- .../TotalFreedomMod/Commands/Command_rd.java | 1 - .../Commands/Command_whitelist.java | 105 +++++++++++++++++- 2 files changed, 103 insertions(+), 3 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java index 0478d78..9581b46 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java @@ -1,6 +1,5 @@ package me.StevenLawson.TotalFreedomMod.Commands; -import java.util.Arrays; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java index bc6dea5..8e0a180 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java @@ -69,6 +69,84 @@ public class Command_whitelist extends TFM_Command return true; } + // on + if(args[0].equalsIgnoreCase("on")) + { + TFM_Util.adminAction(sender.getName(), "Turning the whitelist on", false); + server.setWhitelist(true); + return true; + } + + // off + if(args[0].equalsIgnoreCase("off")) + { + TFM_Util.adminAction(sender.getName(), "Turning the whitelist off", false); + server.setWhitelist(false); + return true; + } + + // add + if(args[0].equalsIgnoreCase("add")) + { + if(args.length < 2) + { + return false; + } + + OfflinePlayer p; + try + { + p = getPlayer(args[0]); + } + catch(CantFindPlayerException ex) + { + if(!senderIsConsole) + { + sender.sendMessage(ex.getMessage()); + sender.sendMessage(ChatColor.YELLOW + "You don't have permissions to whitelist offline players"); + return true; + } + else + { + p = server.getOfflinePlayer(args[0]); + } + } + TFM_Util.adminAction(sender.getName(), "Adding " + p.getName() + " to the whitelist", false); + p.setWhitelisted(true); + return true; + } + + // remove + if(args[0].equalsIgnoreCase("remove")) + { + if(args.length < 2) + { + return false; + } + + OfflinePlayer p; + try + { + p = getPlayer(args[0]); + } + catch(CantFindPlayerException ex) + { + p = server.getOfflinePlayer(args[0]); + } + + if(p.isWhitelisted()) + { + TFM_Util.adminAction(sender.getName(), "Removing " + p.getName() + "from the whitelist", false); + p.setWhitelisted(false); + return true; + } + else + { + TFM_Util.playerMsg(sender, "That player is not whitelisted"); + return true; + } + + } // addall if(args[0].equalsIgnoreCase("addall")) @@ -85,9 +163,32 @@ public class Command_whitelist extends TFM_Command } TFM_Util.playerMsg(sender, "Whitelisted " + counter + " players."); + return true; } - - return true; + // all commands past this line are console/telnet only + if(!senderIsConsole) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + //purge + if(args[0].equalsIgnoreCase("purge")) + { + TFM_Util.adminAction(sender.getName(), "Removing all players from the whitelist", true); + int counter = 0; + for(OfflinePlayer p : server.getWhitelistedPlayers()) + { + p.setWhitelisted(false); + counter++; + } + TFM_Util.playerMsg(sender, "Removed " + counter + " players from the whitelist"); + + return true; + } + + // none of the commands were executed + return false; } } From 4d505c3025b77a93cd1933ab42a1290e09e70b11 Mon Sep 17 00:00:00 2001 From: Jerom van der Sar Date: Mon, 17 Sep 2012 22:37:28 +0200 Subject: [PATCH 5/5] oops --- .../TotalFreedomMod/Commands/Command_whitelist.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java index 8e0a180..91b6c62 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whitelist.java @@ -96,7 +96,7 @@ public class Command_whitelist extends TFM_Command OfflinePlayer p; try { - p = getPlayer(args[0]); + p = getPlayer(args[1]); } catch(CantFindPlayerException ex) { @@ -127,7 +127,7 @@ public class Command_whitelist extends TFM_Command OfflinePlayer p; try { - p = getPlayer(args[0]); + p = getPlayer(args[1]); } catch(CantFindPlayerException ex) {