From e2d772bc4f5336946d9ff517117bf2f916442483 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Fri, 14 Oct 2011 19:29:09 -0400 Subject: [PATCH] Misc --- .../TotalFreedomMod/TFM_Cmds_Admin.java | 4 +- .../TotalFreedomMod/TFM_Cmds_General.java | 4 +- .../TotalFreedomMod/TFM_Cmds_OP.java | 15 ++++++ .../TotalFreedomMod/TFM_EntityListener.java | 4 +- .../TotalFreedomMod/TFM_PlayerListener.java | 20 ++++---- .../TotalFreedomMod/TFM_UserInfo.java | 51 +++++++++---------- .../TotalFreedomMod/TotalFreedomMod.java | 4 +- src/plugin.yml | 16 +++--- 8 files changed, 68 insertions(+), 50 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java index bb579de..baad8dd 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_Admin.java @@ -699,8 +699,8 @@ public class TFM_Cmds_Admin implements CommandExecutor playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(target_pos, 2, playerdata); - TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); - TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); + TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); + TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); p.setGameMode(GameMode.SURVIVAL); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java index 85c427c..4e6a8ba 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_General.java @@ -246,7 +246,7 @@ public class TFM_Cmds_General implements CommandExecutor TFM_Util.gotoWorld(sender, "nether"); return true; } - else if (cmd.getName().equalsIgnoreCase("banlist")) + else if (cmd.getName().equalsIgnoreCase("tfbanlist")) { if (args.length > 0) { @@ -287,7 +287,7 @@ public class TFM_Cmds_General implements CommandExecutor return true; } - else if (cmd.getName().equalsIgnoreCase("ipbanlist")) + else if (cmd.getName().equalsIgnoreCase("tfipbanlist")) { if (args.length > 0) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java index 88a5ef2..e230c94 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Cmds_OP.java @@ -1,10 +1,12 @@ package me.StevenLawson.TotalFreedomMod; import java.util.Arrays; +import java.util.Set; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; +import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -112,6 +114,19 @@ public class TFM_Cmds_OP implements CommandExecutor p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); } + + if (args.length >= 1) + { + if (args[0].equalsIgnoreCase("purge")) + { + sender.sendMessage(ChatColor.GRAY + "Purging ops.txt."); + + for (OfflinePlayer p : Bukkit.getOperators()) + { + p.setOp(false); + } + } + } } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/TFM_EntityListener.java index 438350a..86dc18b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_EntityListener.java @@ -59,7 +59,9 @@ public class TFM_EntityListener extends EntityListener if (playerdata.getForcedDeath()) { event.setCancelled(false); - event.setDamage(p.getHealth() + 1); + p.setFoodLevel(0); + p.setHealth(0); + event.setDamage(100); playerdata.setForcedDeath(false); return; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java index c44a548..c3b28ee 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerListener.java @@ -90,7 +90,7 @@ class TFM_PlayerListener extends PlayerListener event.setTo(to); } - + if (playerdata != null) { if (playerdata.isCaged()) @@ -99,12 +99,12 @@ class TFM_PlayerListener extends PlayerListener if (target_pos.distance(playerdata.getCagePos()) > 2.5) { - playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(0), playerdata.getCageMaterial(1)); + playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(target_pos, 2, playerdata); - TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(0)); - TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(1)); + TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER)); + TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); } } } @@ -136,8 +136,10 @@ class TFM_PlayerListener extends PlayerListener playerdata.incrementMsgCount(); plugin.userinfo.put(p, playerdata); } - - if (Pattern.compile("\\sbe\\s.*admin").matcher(event.getMessage().toLowerCase()).find()) + + String message = event.getMessage().toLowerCase(); + if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find() + || Pattern.compile("\\shave\\s.*admin").matcher(message).find()) { log.info("Kicked " + p.getName() + " for being annoying."); p.kickPlayer("No, bitch."); @@ -161,21 +163,21 @@ class TFM_PlayerListener extends PlayerListener boolean block_command = false; - if (command.matches("^/stop.*")) + if (Pattern.compile("^/stop").matcher(command).find()) { if (!TFM_Util.isUserSuperadmin(player, plugin)) { block_command = true; } } - else if (command.matches("^/reload.*")) + else if (Pattern.compile("^/reload").matcher(command).find()) { if (!TFM_Util.isUserSuperadmin(player, plugin)) { block_command = true; } } - + if (block_command) { player.sendMessage(ChatColor.RED + "That command is prohibited."); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java index cd12c3f..4d834b0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java @@ -10,14 +10,9 @@ public class TFM_UserInfo private boolean user_frozen = false; private int msg_count = 0; private int block_destroy_total = 0; - private int freecam_destroy_count = 0; private int freecam_place_count = 0; - private boolean forced_death = false; - - // -- Start Cage - private boolean user_caged = false; private Location user_cage_pos; private List user_cage_history = new ArrayList(); @@ -27,12 +22,12 @@ public class TFM_UserInfo public TFM_UserInfo() { } - + public void setCaged(boolean state) { this.user_caged = state; } - + public void setCaged(boolean state, Location location, Material material_outer, Material material_inner) { this.user_caged = state; @@ -40,39 +35,45 @@ public class TFM_UserInfo this.cage_material_outer = material_outer; this.cage_material_inner = material_inner; } - + public boolean isCaged() { return this.user_caged; } - - public Material getCageMaterial(int layer) + + public enum CageLayer { - if (layer == 1) + INNER, OUTER + } + + public Material getCageMaterial(CageLayer layer) + { + switch (layer) { - return this.cage_material_inner; - } - else - { - return this.cage_material_outer; + case OUTER: + return this.cage_material_outer; + case INNER: + return this.cage_material_inner; + default: + return this.cage_material_outer; } } - + public Location getCagePos() { return this.user_cage_pos; } - + public void clearHistory() { this.user_cage_history.clear(); } - + public void insertHistoryBlock(Location location, Material material) { this.user_cage_history.add(new TFM_BlockData(location, material)); } - + public void regenerateHistory() { for (TFM_BlockData blockdata : this.user_cage_history) @@ -80,7 +81,7 @@ public class TFM_UserInfo blockdata.location.getBlock().setType(blockdata.material); } } - + class TFM_BlockData { public Material material; @@ -92,9 +93,7 @@ public class TFM_UserInfo this.material = material; } } - - // -- End Cage - + public boolean getForcedDeath() { return this.forced_death; @@ -144,7 +143,7 @@ public class TFM_UserInfo { this.block_destroy_total = 0; } - + public void incrementFreecamDestroyCount() { this.freecam_destroy_count++; @@ -159,7 +158,7 @@ public class TFM_UserInfo { this.freecam_destroy_count = 0; } - + public void incrementFreecamPlaceCount() { this.freecam_place_count++; diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index c05e0e3..c97c720 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -150,10 +150,10 @@ public class TotalFreedomMod extends JavaPlugin this.getCommand("qdeop").setExecutor(OPCommands); this.getCommand("qop").setExecutor(OPCommands); - this.getCommand("banlist").setExecutor(GeneralCommands); + this.getCommand("tfbanlist").setExecutor(GeneralCommands); this.getCommand("creative").setExecutor(GeneralCommands); this.getCommand("flatlands").setExecutor(GeneralCommands); - this.getCommand("ipbanlist").setExecutor(GeneralCommands); + this.getCommand("tfipbanlist").setExecutor(GeneralCommands); this.getCommand("mp").setExecutor(GeneralCommands); this.getCommand("nether").setExecutor(GeneralCommands); this.getCommand("radar").setExecutor(GeneralCommands); diff --git a/src/plugin.yml b/src/plugin.yml index 94199e6..031b449 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -4,9 +4,6 @@ version: 1.7 description: Plugin for the Total Freedom server. author: StevenLawson / Madgeek1450 commands: - banlist: - description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list. - usage: / [purge] cage: description: Superadmin command - Place a cage around someone. usage: / [off|outermaterial] [water|lava] @@ -20,8 +17,8 @@ commands: description: Telnet command - Send a chat message with chat formatting over telnet. usage: / [partialname] deopall: - description: Superadmin command - Deop everyone on the server. - usage: / + description: Superadmin command - Deop everyone on the server. Use 'purge' to clear ops.txt as well. + usage: / [purge] explosives: description: Superadmin command - Enable/disable explosives and set effect radius. usage: / [radius] @@ -46,9 +43,6 @@ commands: gtfo: description: Superadmin command - Makes someone GTFO (deop and ip ban by username). usage: / - ipbanlist: - description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list. - usage: / [purge] lavadmg: description: Superadmin command - Enable/disable lava damage. usage: / @@ -112,6 +106,12 @@ commands: survival: description: Quickly change your own gamemode to survival, or define someone's username to change theirs. usage: / [partialname] + tfbanlist: + description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list. + usage: / [purge] + tfipbanlist: + description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list. + usage: / [purge] tfsmite: description: De-op, inventory clear, de-godmode, lightning, and kill your target. For naughty people only (or the entire server). usage: / [playername|all]