From 5dd36a9f2659e96db7984f3f66e5e68dc8920483 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Sun, 22 Jul 2012 14:06:01 -0400 Subject: [PATCH] A few old fixes i forgot to commit. --- appinfo.properties | 6 +-- buildnumber.properties | 4 +- .../TotalFreedomMod/Commands/Command_rd.java | 16 ++++++- .../Commands/Command_saconfig.java | 4 +- .../Listener/TFM_PlayerListener.java | 2 +- .../TotalFreedomMod/TFM_Heartbeat.java | 2 +- .../TotalFreedomMod/TFM_Util.java | 46 ++++++++++++------- src/plugin.yml | 4 +- 8 files changed, 56 insertions(+), 28 deletions(-) diff --git a/appinfo.properties b/appinfo.properties index 92eebb49..1860a418 100644 --- a/appinfo.properties +++ b/appinfo.properties @@ -1,5 +1,5 @@ -#Sun, 11 Mar 2012 23:38:55 -0500 +#Sun, 22 Jul 2012 12:53:52 -0400 program.VERSION=2.5 -program.BUILDNUM=59 -program.BUILDDATE=03/11/2012 11\:38 PM +program.BUILDNUM=62 +program.BUILDDATE=07/22/2012 12\:53 PM diff --git a/buildnumber.properties b/buildnumber.properties index 5e9f9c35..911db1a3 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Mar 11 23:38:55 EDT 2012 -build.number=60 +#Sun Jul 22 12:53:52 EDT 2012 +build.number=63 diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java index 37c5d7d8..3a5e66ed 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_rd.java @@ -1,5 +1,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; +import java.util.Arrays; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; @@ -14,8 +15,19 @@ public class Command_rd extends TFM_Command { if (senderIsConsole || sender.isOp()) { - sender.sendMessage(ChatColor.GRAY + "Removing all dropped items, arrows, exp. orbs and TNT..."); - sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeDropEntities(true)) + " dropped enties removed."); + 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."); + } } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index 139bcccc..a8c2ff3b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -127,7 +127,8 @@ public class Command_saconfig extends TFM_Command sender.sendMessage("Superadmin not found: " + user_name); return true; } - + + sender.sendMessage("Removing superadmin: " + user_name); TotalFreedomMod.superadmins.remove(user_name); if (config.contains(user_name)) @@ -135,6 +136,7 @@ public class Command_saconfig extends TFM_Command List user_ips = (List) config.getStringList(user_name); for (String ip : user_ips) { + sender.sendMessage("Removing superadmin IP: " + ip); TotalFreedomMod.superadmin_ips.remove(ip); } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 9ee56954..41950e7f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -335,7 +335,7 @@ public class TFM_PlayerListener implements Listener playerdata.resetMsgCount(); - TFM_Util.wipeDropEntities(true); + TFM_Util.wipeEntities(true); event.setCancelled(true); return; diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java index ec134e6e..631a379c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java @@ -28,7 +28,7 @@ public class TFM_Heartbeat implements Runnable if (TotalFreedomMod.autoEntityWipe) { - TFM_Util.wipeDropEntities(!TotalFreedomMod.allowExplosions); + TFM_Util.wipeEntities(!TotalFreedomMod.allowExplosions); } if (TotalFreedomMod.disableNight) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 2278137b..f74ab3fe 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -50,7 +50,7 @@ public class TFM_Util mobtypes.put("villager", EntityType.VILLAGER); mobtypes.put("wolf", EntityType.WOLF); mobtypes.put("zombie", EntityType.ZOMBIE); - + stop_commands.add("stop"); stop_commands.add("off"); stop_commands.add("end"); @@ -115,7 +115,7 @@ public class TFM_Util if (sender_p.getWorld().getName().equalsIgnoreCase(targetworld)) { sender.sendMessage(ChatColor.GRAY + "Going to main world."); - sender_p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()); + sender_p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation()); return; } @@ -128,7 +128,7 @@ public class TFM_Util return; } } - + sender.sendMessage(ChatColor.GRAY + "World " + targetworld + " not found."); } else @@ -355,14 +355,23 @@ public class TFM_Util } } - public static int wipeDropEntities(boolean wipe_tnt) + public static int wipeEntities(boolean wipe_explosives) + { + return wipeEntities(wipe_explosives, false); + } + + public static int wipeEntities(boolean wipe_explosives, boolean wipe_carts) { int removed = 0; for (World world : Bukkit.getWorlds()) { for (Entity ent : world.getEntities()) { - if (ent instanceof Arrow || (ent instanceof TNTPrimed && wipe_tnt) || ent instanceof Item || ent instanceof ExperienceOrb) + if (ent instanceof Projectile + || ent instanceof Item + || ent instanceof ExperienceOrb + || (ent instanceof Explosive && wipe_explosives) + || (ent instanceof Minecart && wipe_carts)) { ent.remove(); removed++; @@ -398,12 +407,12 @@ public class TFM_Util public static EntityType getEntityType(String mobname) throws Exception { mobname = mobname.toLowerCase().trim(); - + if (!TFM_Util.mobtypes.containsKey(mobname)) { throw new Exception(); } - + return TFM_Util.mobtypes.get(mobname); } @@ -532,11 +541,11 @@ public class TFM_Util { EjectMethod method = EjectMethod.STRIKE_ONE; String player_ip = null; - + try { player_ip = p.getAddress().getAddress().getHostAddress(); - + Integer num_kicks = TFM_Util.eject_tracker.get(player_ip); if (num_kicks == null) { @@ -544,7 +553,7 @@ public class TFM_Util } num_kicks = new Integer(num_kicks.intValue() + 1); - + TFM_Util.eject_tracker.put(player_ip, num_kicks); if (num_kicks.intValue() <= 1) @@ -563,35 +572,42 @@ public class TFM_Util catch (Exception ex) { } - + log.info("autoEject -> name: " + p.getName() + " - player_ip: " + player_ip + " - method: " + method.toString()); p.setOp(false); p.setGameMode(GameMode.SURVIVAL); p.getInventory().clear(); - p.kickPlayer(kickMessage); switch (method) { case STRIKE_ONE: { + p.kickPlayer(kickMessage); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName())); break; } case STRIKE_TWO: { + p.kickPlayer(kickMessage); Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 3m", p.getName())); break; } case STRIKE_THREE: { Bukkit.banIP(player_ip); - Bukkit.getOfflinePlayer(p.getName()).setBanned(true); + String[] ip_address_parts = player_ip.split("\\."); + Bukkit.banIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*"); + + p.setBanned(true); + + p.kickPlayer(kickMessage); + break; } } } - + public static void generateFlatlands() { generateFlatlands(TotalFreedomMod.flatlandsGenerationParams); @@ -606,9 +622,7 @@ public class TFM_Util flatlands.generator(new CleanroomChunkGenerator(genParams)); Bukkit.getServer().createWorld(flatlands); } - // 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/plugin.yml b/src/plugin.yml index adcd33dd..a4e9d259 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -119,8 +119,8 @@ commands: 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: / + description: Remove all projectiles, dropped items, experience orbs, primed explosives, and minecarts. Minecarts are optional, based on if "carts" is included after the command. + usage: / saconfig: description: Owner command - Manage superadmins. usage: / >