From f63805cca2942d7d21ac22056cfac50f9ae0590c Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 7 Jul 2013 23:39:02 +0100 Subject: [PATCH 1/9] Removed some ziptool stuff Well as it was removed from here, it may aswell just be removed from this file too :) --- .../TotalFreedomMod/TFM_Util.java | 71 +------------------ 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 0a3e60ec..9ac1bd3f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -305,76 +305,7 @@ public class TFM_Util return TFM_Util.mobtypes.get(mobname); } - public static void zip(File directory, File zipfile, boolean verbose, CommandSender sender) throws IOException - { - URI base = directory.toURI(); - Deque queue = new LinkedList(); - queue.push(directory); - OutputStream out = new FileOutputStream(zipfile); - Closeable res = out; - try - { - ZipOutputStream zout = new ZipOutputStream(out); - res = zout; - while (!queue.isEmpty()) - { - directory = queue.pop(); - for (File kid : directory.listFiles()) - { - String name = base.relativize(kid.toURI()).getPath(); - if (kid.isDirectory()) - { - queue.push(kid); - name = name.endsWith("/") ? name : name + "/"; - zout.putNextEntry(new ZipEntry(name)); - } - else - { - zout.putNextEntry(new ZipEntry(name)); - copy(kid, zout); - zout.closeEntry(); - } - - if (verbose) - { - sender.sendMessage("Zipping: " + name); - } - } - } - } - finally - { - res.close(); - } - } - - public static void unzip(File zipfile, File directory) throws IOException - { - ZipFile zfile = new ZipFile(zipfile); - Enumeration entries = zfile.entries(); - while (entries.hasMoreElements()) - { - ZipEntry entry = entries.nextElement(); - File file = new File(directory, entry.getName()); - if (entry.isDirectory()) - { - file.mkdirs(); - } - else - { - file.getParentFile().mkdirs(); - InputStream in = zfile.getInputStream(entry); - try - { - copy(in, file); - } - finally - { - in.close(); - } - } - } - } + private static void copy(InputStream in, OutputStream out) throws IOException { From 22bf0c2f627bf2264bd874a7e7577e039037970e Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Wed, 10 Jul 2013 21:46:29 -0400 Subject: [PATCH 2/9] Removed Command_minecraft and TFM_ServiceChecker. Restored old Mojang status checker in /status. Owner of xpaw.ru requested that 3rd party applications not use his API. Batch formatting fix. --- appinfo.properties | 6 +- buildnumber.properties | 4 +- .../Commands/Command_halt.java | 1 - .../Commands/Command_minecraft.java | 24 -- .../Commands/Command_status.java | 79 +++++++ .../Commands/Command_whohas.java | 9 +- .../Listener/TFM_PlayerListener.java | 5 +- .../TotalFreedomMod/TFM_CommandBlocker.java | 9 +- .../TotalFreedomMod/TFM_PlayerData.java | 2 +- .../TotalFreedomMod/TFM_ServerInterface.java | 12 +- .../TotalFreedomMod/TFM_ServiceChecker.java | 207 ------------------ .../TotalFreedomMod/TFM_Util.java | 6 +- .../TotalFreedomMod/TotalFreedomMod.java | 28 +-- 13 files changed, 108 insertions(+), 284 deletions(-) delete mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_minecraft.java delete mode 100644 src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java diff --git a/appinfo.properties b/appinfo.properties index 39e971f4..9a06d039 100644 --- a/appinfo.properties +++ b/appinfo.properties @@ -1,5 +1,5 @@ -#Wed, 10 Jul 2013 23:43:28 +0200 +#Wed, 10 Jul 2013 21:43:33 -0400 program.VERSION=2.21 -program.BUILDNUM=297 -program.BUILDDATE=07/10/2013 11\:43 PM +program.BUILDNUM=300 +program.BUILDDATE=07/10/2013 09\:43 PM diff --git a/buildnumber.properties b/buildnumber.properties index c232fcf2..3291c3a3 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Wed Jul 10 23:43:28 CEST 2013 -build.number=298 +#Wed Jul 10 21:43:33 EDT 2013 +build.number=301 diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java index 5d93c823..2066d04f 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_halt.java @@ -102,5 +102,4 @@ public class Command_halt extends TFM_Command return true; } } - } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_minecraft.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_minecraft.java deleted file mode 100644 index 0e279ebb..00000000 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_minecraft.java +++ /dev/null @@ -1,24 +0,0 @@ -package me.StevenLawson.TotalFreedomMod.Commands; - -import me.StevenLawson.TotalFreedomMod.TFM_ServiceChecker; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) -@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/") -public class Command_minecraft extends TFM_Command -{ - @Override - public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) - { - playerMsg("Status of Mojang services:", ChatColor.BLUE); - for (String service : TFM_ServiceChecker.getAllStatuses()) - { - playerMsg(service); - } - playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE); - return true; - } -} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java index 8f426ebf..83ec0ff6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java @@ -1,16 +1,42 @@ package me.StevenLawson.TotalFreedomMod.Commands; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import me.StevenLawson.TotalFreedomMod.TFM_Log; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.apache.commons.lang.StringUtils; import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; @CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) @CommandParameters(description = "Show misc. server info.", usage = "/") public class Command_status extends TFM_Command { + public static final Map SERVICE_MAP = new HashMap(); + + static + { + SERVICE_MAP.put("minecraft.net", "Minecraft.net"); + SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins"); + SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions"); + SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website"); + SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login"); + SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins"); + } + @Override public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { @@ -26,6 +52,59 @@ public class Command_status extends TFM_Command playerMsg(String.format("World %d: %s - %d players.", i++, world.getName(), world.getPlayers().size()), ChatColor.BLUE); } + server.getScheduler().runTaskAsynchronously(plugin, new Runnable() + { + @SuppressWarnings("unchecked") + @Override + public void run() + { + try + { + URL mojang_status = new URL("http://status.mojang.com/check"); + BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream())); + JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine()); + in.close(); + + Map service_status = new HashMap(); + + Iterator status_it = status_json.iterator(); + while (status_it.hasNext()) + { + JSONObject service = (JSONObject) status_it.next(); + Iterator service_it = service.entrySet().iterator(); + while (service_it.hasNext()) + { + Entry pair = (Entry) service_it.next(); + service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE)); + } + } + + List status_output = new ArrayList(); + + Iterator> output_it = service_status.entrySet().iterator(); + while (output_it.hasNext()) + { + Entry pair = output_it.next(); + String service_name = pair.getKey(); + boolean service_online = pair.getValue().booleanValue(); + + if (SERVICE_MAP.containsKey(service_name)) + { + service_name = SERVICE_MAP.get(service_name); + } + + status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY))); + } + + playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY); + } + catch (Exception ex) + { + TFM_Log.severe(ex); + } + } + }); + return true; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java index e4eb338e..e617309d 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_whohas.java @@ -10,9 +10,8 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; - @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) -@CommandParameters(description = "See who has a block and optionally smite", usage = "/ [smite]", aliases="wh") +@CommandParameters(description = "See who has a block and optionally smite", usage = "/ [smite]", aliases = "wh") public class Command_whohas extends TFM_Command { @Override @@ -33,7 +32,7 @@ public class Command_whohas extends TFM_Command } Material material = Material.matchMaterial(args[0]); - + if (material == null) { try @@ -67,11 +66,11 @@ public class Command_whohas extends TFM_Command if (players.isEmpty()) { - playerMsg("There are no players with that item"); + playerMsg("There are no players with that item"); } else { - playerMsg("Players with item " + material.name() + ": "+ StringUtils.join(players, ", ")); + playerMsg("Players with item " + material.name() + ": " + StringUtils.join(players, ", ")); } return true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 23a841b8..ba0c2885 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -679,10 +679,7 @@ public class TFM_PlayerListener implements Listener @EventHandler(priority = EventPriority.HIGHEST) public void onServerPing(ServerListPingEvent event) { - //event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd())); - - event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY - + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion()); + event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY + "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion()); if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress())) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java index 8bb5892b..f9d3891b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_CommandBlocker.java @@ -9,13 +9,12 @@ import org.bukkit.entity.Player; public class TFM_CommandBlocker { - public static boolean isCommandBlocked(String usedcommand, CommandSender sender) { String name = sender.getName(); usedcommand = usedcommand.toLowerCase().trim(); - + for (String blocked_command : TotalFreedomMod.blockedCommands) { String[] parts = blocked_command.split(":"); @@ -109,7 +108,6 @@ public class TFM_CommandBlocker TELNET("t", 3), SENIOR("c", 4), NOBODY("n", 5); - private String letter = "n"; private int rank = 5; @@ -162,10 +160,5 @@ public class TFM_CommandBlocker } return SenderRank.NOBODY; } - } - - - - } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java index 813f1d17..054afe05 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java @@ -427,7 +427,7 @@ public class TFM_PlayerData player.sendMessage(ChatColor.GRAY + "You are no longer halted."); } - + } public BukkitTask getLockupScheduleID() diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java index b3c45ccc..92301fe3 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java @@ -171,8 +171,7 @@ public class TFM_ServerInterface kick_message = kick_message + "\nReason: " + ban_entry.getReason(); if (ban_entry.getExpires() != null) { - kick_message = kick_message + "\nYour ban will be removed on " - + date_format.format(ban_entry.getExpires()); + kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires()); } } @@ -216,8 +215,7 @@ public class TFM_ServerInterface kick_message = kick_message + "\nReason: " + ban_entry.getReason(); if (ban_entry.getExpires() != null) { - kick_message = kick_message + "\nYour ban will be removed on " - + date_format.format(ban_entry.getExpires()); + kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires()); } } @@ -229,8 +227,7 @@ public class TFM_ServerInterface { if (test_player.equalsIgnoreCase(player_name)) { - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED - + "Your username is permanently banned from this server."); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server."); return; } } @@ -239,8 +236,7 @@ public class TFM_ServerInterface { if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4)) { - event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED - + "Your IP address is permanently banned from this server."); + event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server."); return; } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java deleted file mode 100644 index 0b06114c..00000000 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServiceChecker.java +++ /dev/null @@ -1,207 +0,0 @@ -package me.StevenLawson.TotalFreedomMod; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang.WordUtils; -import org.bukkit.ChatColor; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; - -public class TFM_ServiceChecker -{ - private static final Map SERVICE_MAP = new HashMap(); - public static String check_url = "http://xpaw.ru/mcstatus/status.json"; - public static String version = "1.0"; - public static String last_updated = ""; // On xpaw.ru - - static - { - // <"up", "down", "problem">, <"Online", "Quite Slow", "Error 505", etc>, - SERVICE_MAP.put("website", new String[] - { - "up", "Online", "100.00" - }); - SERVICE_MAP.put("session", new String[] - { - "up", "Online", "100.00" - }); - SERVICE_MAP.put("login", new String[] - { - "up", "Online", "100.00" - }); - SERVICE_MAP.put("account", new String[] - { - "up", "Online", "100.00" - }); - SERVICE_MAP.put("skins", new String[] - { - "up", "Online", "100.00" - }); - SERVICE_MAP.put("realms", new String[] - { - "up", "Online", "100.00" - }); - } - public static Runnable checker = new Runnable() - { - @Override - public void run() - { - runCheck(); - } - }; - - public static void runCheck() - { - TotalFreedomMod.server.getScheduler().runTaskAsynchronously(TotalFreedomMod.plugin, new Runnable() - { - @Override - public void run() - { - try - { - - /* // Nubcakes be 403'ing us >;o - BufferedReader in = new BufferedReader(new InputStreamReader(new URL(check_url).openStream())); - JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine()); - in.close(); - */ - - // Well, lets bypass that! >:D - HttpURLConnection connection = (HttpURLConnection) new URL(check_url).openConnection(); - connection.setRequestMethod("GET"); - connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36"); - connection.setRequestProperty("Host", "xpaw.ru"); - connection.setRequestProperty("Accept", "*/*"); - connection.setUseCaches(false); - connection.setDoInput(true); - connection.setDoOutput(false); - InputStream is = connection.getInputStream(); - BufferedReader in = new BufferedReader(new InputStreamReader(is)); - JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine()); - in.close(); - connection.disconnect(); - - - - version = String.valueOf(service_json.get("v")); - last_updated = (String) service_json.get("last_updated"); - - JSONObject services = (JSONObject) service_json.get("report"); - for (String service : SERVICE_MAP.keySet()) - { - JSONObject service_info = (JSONObject) services.get(service); - SERVICE_MAP.put(service, new String[] - { - (String) service_info.get("status"), - (String) service_info.get("title"), - (String) service_info.get("uptime") - }); - } - } - catch (Exception ex) - { - } - } - }); - } - - public static String getFormattedStatus(String service_name) - { - String[] service = SERVICE_MAP.get(service_name); - String status = ("up".equals(service[0]) ? ChatColor.GREEN - : ("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString(); - - status += service[1] + ChatColor.GRAY + " ("; - - status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN - : (Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED)); - - status += service[2] + "%" + ChatColor.GRAY + ")"; - - return ChatColor.GRAY + WordUtils.capitalize(service_name) + ChatColor.WHITE + ": " + status; - } - - public static List getAllStatuses() - { - List statuses = new ArrayList(); - for (String status : SERVICE_MAP.keySet()) - { - statuses.add(getFormattedStatus(status)); - } - return statuses; - } -} - -/* // Mojang status - public static final Map SERVICE_MAP = new HashMap(); - - static - { - SERVICE_MAP.put("minecraft.net", "Minecraft.net"); - SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins"); - SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions"); - SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website"); - SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login"); - SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins"); - } - server.getScheduler().runTaskAsynchronously(plugin, new Runnable() - { - @SuppressWarnings("unchecked") - @Override - public void run() - { - try - { - URL mojang_status = new URL("http://status.mojang.com/check"); - BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream())); - JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine()); - in.close(); - - Map service_status = new HashMap(); - - Iterator status_it = status_json.iterator(); - while (status_it.hasNext()) - { - JSONObject service = (JSONObject) status_it.next(); - Iterator service_it = service.entrySet().iterator(); - while (service_it.hasNext()) - { - Entry pair = (Entry) service_it.next(); - service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE)); - } - } - - List status_output = new ArrayList(); - - Iterator> output_it = service_status.entrySet().iterator(); - while (output_it.hasNext()) - { - Entry pair = output_it.next(); - String service_name = pair.getKey(); - boolean service_online = pair.getValue().booleanValue(); - - if (SERVICE_MAP.containsKey(service_name)) - { - service_name = SERVICE_MAP.get(service_name); - } - - status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY))); - } - - playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY); - } - catch (Exception ex) - { - TFM_Log.severe(ex); - } - } - }); - */ diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 0a3e60ec..06f94d84 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -969,8 +969,7 @@ public class TFM_Util { if (TFM_SuperadminList.isUserSuperadmin(p)) { - p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED - + name + ": " + ChatColor.AQUA + message); + p.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.AQUA + message); } } } @@ -1035,7 +1034,6 @@ public class TFM_Util while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null)); return null; } - public static final List COLOR_POOL = Arrays.asList( ChatColor.DARK_BLUE, ChatColor.DARK_GREEN, @@ -1049,8 +1047,8 @@ public class TFM_Util ChatColor.RED, ChatColor.LIGHT_PURPLE, ChatColor.YELLOW); - private static final Random RANDOM = new Random(); + public static ChatColor randomChatColor() { return COLOR_POOL.get(RANDOM.nextInt(COLOR_POOL.size())); diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index c49a3724..39c63581 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -28,35 +28,35 @@ import org.mcstats.Metrics; public class TotalFreedomMod extends JavaPlugin { public static final Server server = Bukkit.getServer(); - + // public static final long HEARTBEAT_RATE = 5L; //Seconds public static final long SERVICE_CHECKER_RATE = 30L; - + // public static final String CONFIG_FILE = "config.yml"; public static final String SUPERADMIN_FILE = "superadmin.yml"; public static final String PERMBAN_FILE = "permban.yml"; public static final String PROTECTED_AREA_FILE = "protectedareas.dat"; public static final String SAVED_FLAGS_FILE = "savedflags.dat"; - + // 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!"; public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake."; public static final String NOT_FROM_CONSOLE = "This command may not be used from the console."; - + // public static boolean allPlayersFrozen = false; public static int freezePurgeEventId = 0; public static int mutePurgeEventId = 0; public static Map fuckoffEnabledFor = new HashMap(); - + // public static String pluginVersion = ""; public static String buildNumber = ""; public static String buildDate = ""; public static String pluginName = ""; - + // public static TotalFreedomMod plugin = null; public static File plugin_file = null; @@ -106,13 +106,8 @@ public class TotalFreedomMod extends JavaPlugin // Heartbeat server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); - // Service uptime checker - server.getScheduler().scheduleSyncRepeatingTask(this, TFM_ServiceChecker.checker, SERVICE_CHECKER_RATE * 20L, 1 * 20L); - TFM_CommandLoader.getInstance().scan(); - - // metrics @ http://mcstats.org/plugin/TotalFreedomMod try { @@ -124,8 +119,7 @@ public class TotalFreedomMod extends JavaPlugin TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage()); } - TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." - + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon"); + TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon"); } @Override @@ -201,7 +195,7 @@ public class TotalFreedomMod extends JavaPlugin return true; } - + // public static boolean allowFirePlace = false; public static Boolean allowFireSpread = false; public static Boolean allowLavaDamage = false; @@ -292,7 +286,7 @@ public class TotalFreedomMod extends JavaPlugin TFM_Log.severe("Error loading main config: " + ex.getMessage()); } } - + // @Deprecated public static List superadmins = new ArrayList(); @Deprecated @@ -313,7 +307,7 @@ public class TotalFreedomMod extends JavaPlugin TFM_Log.severe("Error loading superadmin list: " + ex.getMessage()); } } - + // public static List permbanned_players = new ArrayList(); public static List permbanned_ips = new ArrayList(); From 3c80aaa7c4309bf38be9d5cc9bdf3e179d3b3bb2 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 08:18:10 -0400 Subject: [PATCH 3/9] Update CONTRIBUTING.md --- CONTRIBUTING.md | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 22960fd7..2cdc3d1c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,63 +1,50 @@ -# How to contribute +# Contributing to TotalFreedomMod # +TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss. -TotalFreedomMod aims to be a fully functional all-op server mod which works in -a large range of configurations. In order to be as flexible as possible on the -server-end, we encourage contributing to TotalFreedomMod by making 'pull-requests' -to this repository. - -## Getting Started +For those who wish to contribute, we encourage you to fork the repository and submit pull requests. Below you will find guidelines that will explain this process in further detail. +## Getting Started ## * Make sure you have a [GitHub account](https://github.com/signup/free) * If the issue is a bug, submit a ticket for it, assuming one does not already exist. * Clearly describe the issue including steps to reproduce it. * Make sure you fill in the earliest version that you know has the issue. * Fork the repository on GitHub -## Making Changes - +## Making Changes ## * Create a topic branch from where you want to base your work. * This is usually the master branch. - * Only target release branches if you are certain your addition must be on that - branch. - * To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch. + * Only target release branches if you are certain your addition must be on that branch. + * To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch. * Make changes and commit where necessary. * Check for unnecessary whitespace with `git diff --check` before committing. * Make sure your commit messages are in line with those which are already made. -* Make sure your changes build (*and work!*). +* Make sure your changes build (and work!). -## Tips on getting your pull request accepted +## Tips - How To Get Your Pull Request Accepted ## * Make sure your changes work and compile without difficulty. -* Make sure your change adds something useful, do not add commands to micromanage - the server. (ie: Shorthands for a collection of commands) +* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands) + * __Commands that make use of `org.bukkit.Server.dispatchCommand()` will probably be rejected.__ * Features must be in line the general idea of "Total Freedom". -* Changes must be directed towards the main "TotalFreedom" server. Adding names such - as the name of your own TotalFreedom-like server will get your pull request denied. +* Changes must be directed towards the main "TotalFreedom" server. Adding names such as the name of your own TotalFreedom-like server will get your pull request denied. * Do not add yourself to the developer list. * Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation. -* Please make sure your changes are written such as other features would be. Eg: commands - have their own class and extend TFM_Command. -* Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style). +* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command. +* __Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).__ * Do not increment the version number. -* If you want to add multiple changes, please make one pull request per change. This - way, it's easier to accept your changes faster and won't block the other changes if there - is an issue with a specific line of code. +* If you want to add multiple changes, please make one pull request per change. This way, it's easier to accept your changes faster and won't block the other changes if there is an issue with a specific line of code. * Please make sure there are no bugs in your code. * Please avoid having to add files in the main namespace where possible. -* Make sure all changes work before you commit these, this avoids having multiple - unnecessary commits. +* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits. * Please refrain from using an excessive amount of commits. As few as possible is generally the best. * Please do not spread your addition over several pull-requests. -## Submitting Changes - +## Submitting Your Changes ## * Push your changes to a topic branch in your fork of the repository. * Submit a pull request to this repository. * Explain in detail what each one of your commits changes and point out any big changes. * Wait as a developer evaluates your changes. -# Additional Resources - +## Additional Resources ## * [TotalFreedom information](http://totalfreedom.me) * [TotalFreedom forums](http://totalfreedom.boards.net) * [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues) From fa1c9a255c1953f6c86a4c06e8c7b9486f55bc3f Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 08:43:48 -0400 Subject: [PATCH 4/9] Update and rename LICENCE.md to LICENSE.md --- LICENCE.md | 16 ---------------- LICENSE.md | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 LICENCE.md create mode 100644 LICENSE.md diff --git a/LICENCE.md b/LICENCE.md deleted file mode 100644 index d1cdfc16..00000000 --- a/LICENCE.md +++ /dev/null @@ -1,16 +0,0 @@ -# Legal - -TotalFreedomMod by Madgeek1450 and DarthSalamon is an effort to create an opensource plugin to effectively run a "Total Freedom" like all-Op server. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together with the main server "TotalFreedom" (http://totalfreedom.me) TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feel of openness towards the administrators and the players themselves. - -## License - -TotalFreedomMod sourcecode is freely available under the GNU GPLv3 License with a few restrictions in place. The license is available here: http://www.gnu.org/licenses/gpl.txt - -The few restrictions are in place to make sure that credit is given to the original authors who remain the maintainers of the plugin and it's sourcecode. - -These are the restrictions under which the sourcecode is licensed: - * A un-edited copy of this license must always be included with this sourcecode. - * TotalFreedomMod sourcecode and its derrivations are freely distributable between anyone who choses to download it. - * You may not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" and "jeromsar" from any part of the sourcecode. - * However, compiled binaries (*.jar's) are not to be distributed. If you wish to obtain a copy of TotalFreedomMod you must compile the original sourcecode or it's derivations yourself using an IDE like netbeans. Official superadmins and above of the TotalFreedom (totalfreedom.me) server may obtain a compiled libary with the same limitations as described in this document. - * Any conditions on this license may be waived by any of the official developers. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..6c3d12e9 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,14 @@ +# Legal Overview # +TotalFreedomMod, by StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), is an effort to create an open source plugin to effectively run a "Total Freedom" like all-OP Minecraft server. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main [TotalFreedom](http://totalfreedom.me) server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves. + +## License ## +TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt + +We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code. +* A un-edited copy of this LICENSE.md shall always be included with this source code. +* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it. +* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "jeromsar" from any part of the source code. +* Compiled binaries (*.jar's) shall not to be distributed. + * If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself. + * The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis. +* Any restrictions listed here may be waived by any of the above mentioned primary developers. From f2aaba17de1c00f32906c98733939ddb173cbc68 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 12:48:25 -0400 Subject: [PATCH 5/9] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index be8f2247..19cdc7a4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -TotalFreedomMod -=============== +# TotalFreedomMod # -TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server. +TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server. -Information about the TotalFreedom server can be found at http://totalfreedom.me/ +This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (DarthSalamon) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves. + +Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md). From 3dc51715c5e48d363d656b185ce61e05c7a74214 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 12:50:23 -0400 Subject: [PATCH 6/9] Update LICENSE.md --- LICENSE.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 6c3d12e9..8d652832 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,4 @@ -# Legal Overview # -TotalFreedomMod, by StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), is an effort to create an open source plugin to effectively run a "Total Freedom" like all-OP Minecraft server. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main [TotalFreedom](http://totalfreedom.me) server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves. - -## License ## +# TotalFreedomMod License # TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code. From 4903f009b38d347ce910db58f52467607e5a3d28 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jul 2013 14:51:08 -0400 Subject: [PATCH 7/9] Add Pet Protection. Cleaned up config file a bit. --- src/config.yml | 41 ++++++++++--------- .../Commands/Command_petprotect.java | 30 ++++++++++++++ .../Listener/TFM_EntityListener.java | 13 ++++++ .../Listener/TFM_PlayerListener.java | 1 - .../TotalFreedomMod/TFM_Util.java | 5 --- .../TotalFreedomMod/TotalFreedomMod.java | 7 ++-- 6 files changed, 68 insertions(+), 29 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java diff --git a/src/config.yml b/src/config.yml index 2325753f..a582ff69 100644 --- a/src/config.yml +++ b/src/config.yml @@ -50,26 +50,24 @@ explosiveRadius: 4.0 # blocked_commands: # Disabled commands - - 'n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.' - - 'n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.' - - 'n:b:/gamemode:Use /creative and /survival to set your gamemode.' - - 'n:b:/ban:_' - - 'n:b:/pardon:_' - - 'n:b:/toggledownfall:_' + - n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time. + - n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise. + - n:b:/gamemode:Use /creative and /survival to set your gamemode. + - n:b:/ban:_ + - n:b:/pardon:_ + - n:b:/toggledownfall:_ # Superadmin commands - - 's:b:/kick:_' - - 's:b:/socialspy:_' - - 's:b:/kill:_' - - 's:a:/stop' - - 's:a:/reload' - - 's:a:/nuke' - - 's:a:/save-all' - - 's:a:/save-on' - - 's:a:/save-off' - - 's:a:/clearhistory' - - 's:a:/butcher' - - 's:a://butcher' + - s:b:/kick:_ + - s:b:/socialspy:_ + - s:b:/kill:_ + - s:b:/clearhistory:_ + - s:a:/stop + - s:a:/reload + - s:a:/nuke + - s:a:/save-all + - s:a:/save-on + - s:a:/save-off # Automatically wipe dropped objects: auto_wipe: true @@ -125,5 +123,8 @@ host_sender_names: # TwitterBot - Used to allow superadmins to verify themselves using twitter twitterbot_enabled: false -twitterbot_url: 'http://tftwitter.darthcraft.net/' -twitterbot_secret: '' +twitterbot_url: +twitterbot_secret: + +# Pet Protect - Prevent tamed pets from being killed. +pet_protect_enabled: true diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java new file mode 100644 index 00000000..31851dab --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_petprotect.java @@ -0,0 +1,30 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +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 = AdminLevel.SUPER, source = SourceType.BOTH) +@CommandParameters(description = "Enable/disable tamed pet protection.", usage = "/ ") +public class Command_petprotect 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; + } + + TotalFreedomMod.petProtectEnabled = !TFM_Util.isStopCommand(args[0]); + + TFM_Util.adminAction( + sender.getName(), + "Tamed pet protection is now " + (TotalFreedomMod.petProtectEnabled ? "enabled" : "disabled") + ".", + false); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java index d8e909a9..737fe8b7 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java @@ -50,6 +50,19 @@ public class TFM_EntityListener implements Listener case LAVA: { if (!TotalFreedomMod.allowLavaDamage) + { + event.setCancelled(true); + return; + } + } + } + + if (TotalFreedomMod.petProtectEnabled) + { + Entity entity = event.getEntity(); + if (entity instanceof Tameable) + { + if (((Tameable) entity).isTamed()) { event.setCancelled(true); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index ba0c2885..1b1f90f6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -90,7 +90,6 @@ public class TFM_PlayerListener implements Listener event.setCancelled(true); } } - } break; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 6762e356..17716b77 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod; import java.io.*; import java.lang.reflect.Field; -import java.net.URI; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; @@ -13,8 +12,6 @@ import java.util.jar.JarFile; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipOutputStream; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.*; @@ -305,8 +302,6 @@ public class TFM_Util return TFM_Util.mobtypes.get(mobname); } - - private static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 39c63581..0d066446 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -158,8 +158,7 @@ public class TotalFreedomMod extends JavaPlugin try { ClassLoader classLoader = TotalFreedomMod.class.getClassLoader(); - dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, - cmd.getName().toLowerCase())).newInstance(); + dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance(); dispatcher.setup(this, sender, dispatcher.getClass()); } catch (Throwable ex) @@ -232,8 +231,9 @@ public class TotalFreedomMod extends JavaPlugin public static double autoProtectRadius = 25.0D; public static List host_sender_names = Arrays.asList("rcon", "remotebukkit"); public static boolean twitterbotEnabled = false; - public static String twitterbotUrl = "http://tftwitter.darthcraft.net/"; + public static String twitterbotUrl = ""; public static String twitterbotSecret = ""; + public static boolean petProtectEnabled = true; public static void loadMainConfig() { @@ -280,6 +280,7 @@ public class TotalFreedomMod extends JavaPlugin twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled); twitterbotUrl = config.getString("twitterbot_url", twitterbotUrl); twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret); + petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled); } catch (Exception ex) { From aaf96d00a9a1712b3097502350ec92c29266cbf0 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 18:21:23 -0400 Subject: [PATCH 8/9] Revert to old login logic. Ban messages weren't working right. --- .../TotalFreedomMod/TFM_ServerInterface.java | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java index 92301fe3..75e89b50 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java @@ -121,6 +121,8 @@ public class TFM_ServerInterface public static void handlePlayerLogin(PlayerLoginEvent event) { + // this should supersede all other onPlayerLogin authentication on the TFM server. + // when using the TFM CraftBukkit, CraftBukkit itself should not do any of its own authentication. final Server server = TotalFreedomMod.plugin.getServer(); @@ -135,8 +137,7 @@ public class TFM_ServerInterface if (player_name.trim().length() <= 2) { - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, - "Your username is too short (must be at least 3 characters long)."); + event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long)."); return; } else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find()) @@ -145,8 +146,7 @@ public class TFM_ServerInterface return; } - // not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() - // will return a null until after player login. + // not safe to use TFM_Util.isUserSuperadmin for player logging in because p.getAddress() will return a null until after player login. boolean is_superadmin; if (server.getOnlineMode()) { @@ -271,21 +271,8 @@ public class TFM_ServerInterface } } } - else // if user is superadmin + else { - // force-allow superadmins to log in - event.allow(); - - if (isIPBanned(player_ip)) - { - unbanIP(player_ip); - } - - if (isNameBanned(player_name)) - { - unbanUsername(player_name); - } - for (Player test_player : server.getOnlinePlayers()) { if (test_player.getName().equalsIgnoreCase(player_name)) @@ -294,22 +281,19 @@ public class TFM_ServerInterface } } - if (server.getOnlinePlayers().length >= server.getMaxPlayers()) + boolean can_kick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop. + while (server.getOnlinePlayers().length >= server.getMaxPlayers() && can_kick) { - for (Player op : server.getOnlinePlayers()) + can_kick = false; + for (Player test_player : server.getOnlinePlayers()) { - if (!TFM_SuperadminList.isUserSuperadmin(op)) + if (!TFM_SuperadminList.isUserSuperadmin(test_player)) { - op.kickPlayer("You have been kicked to free up space for an admin"); - return; + can_kick = true; + test_player.kickPlayer("You have been kicked to free up room for an admin."); + break; } } - - // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop. - if (server.getOnlinePlayers().length >= server.getMaxPlayers()) - { - event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, this server is full"); - } } } } From b9bd0461057bad8623fcb7f40f97f99a8e57dfb8 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Thu, 11 Jul 2013 20:35:09 -0400 Subject: [PATCH 9/9] Changed WorldEdit API access method. --- appinfo.properties | 6 +- buildnumber.properties | 4 +- .../TotalFreedomMod/TFM_WorldEditBridge.java | 98 +++++++++---------- 3 files changed, 49 insertions(+), 59 deletions(-) diff --git a/appinfo.properties b/appinfo.properties index 9a06d039..f444ea55 100644 --- a/appinfo.properties +++ b/appinfo.properties @@ -1,5 +1,5 @@ -#Wed, 10 Jul 2013 21:43:33 -0400 +#Thu, 11 Jul 2013 20:20:19 -0400 program.VERSION=2.21 -program.BUILDNUM=300 -program.BUILDDATE=07/10/2013 09\:43 PM +program.BUILDNUM=301 +program.BUILDDATE=07/11/2013 08\:20 PM diff --git a/buildnumber.properties b/buildnumber.properties index 3291c3a3..a6b191af 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Wed Jul 10 21:43:33 EDT 2013 -build.number=301 +#Thu Jul 11 20:20:19 EDT 2013 +build.number=302 diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java b/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java index 722d29c2..b52baef0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java @@ -2,8 +2,6 @@ package me.StevenLawson.TotalFreedomMod; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.bukkit.BukkitPlayer; -import com.sk89q.worldedit.bukkit.BukkitServerInterface; -import com.sk89q.worldedit.bukkit.WorldEditAPI; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -12,8 +10,6 @@ import org.bukkit.plugin.Plugin; public class TFM_WorldEditBridge { private WorldEditPlugin worldEditPlugin = null; - private WorldEditAPI worldEditAPI = null; - private BukkitServerInterface bukkitServerInterface = null; private TFM_WorldEditBridge() { @@ -23,57 +19,56 @@ public class TFM_WorldEditBridge { if (this.worldEditPlugin == null) { - Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (we != null) + try { - if (we instanceof WorldEditPlugin) + Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + if (we != null) { - this.worldEditPlugin = (WorldEditPlugin) we; + if (we instanceof WorldEditPlugin) + { + this.worldEditPlugin = (WorldEditPlugin) we; + } } } + catch (Exception ex) + { + TFM_Log.severe(ex); + } } - return this.worldEditPlugin; } - public WorldEditAPI getWorldEditAPI() - { - if (this.worldEditAPI == null) - { - WorldEditPlugin wep = getWorldEditPlugin(); - if (wep != null) - { - this.worldEditAPI = new WorldEditAPI(wep); - } - } - - return this.worldEditAPI; - } - - public BukkitServerInterface getBukkitServerInterface() - { - if (this.bukkitServerInterface == null) - { - WorldEditPlugin wep = this.getWorldEditPlugin(); - if (wep != null) - { - this.bukkitServerInterface = new BukkitServerInterface(wep, Bukkit.getServer()); - } - } - - return this.bukkitServerInterface; - } - public BukkitPlayer getBukkitPlayer(Player p) { - WorldEditPlugin wep = this.getWorldEditPlugin(); - BukkitServerInterface bsi = this.getBukkitServerInterface(); - - if (wep != null && bsi != null) + try { - return new BukkitPlayer(wep, bsi, p); + WorldEditPlugin wep = this.getWorldEditPlugin(); + if (wep != null) + { + return wep.wrapPlayer(p); + } } + catch (Exception ex) + { + TFM_Log.severe(ex); + } + return null; + } + public LocalSession getPlayerSession(Player p) + { + try + { + WorldEditPlugin wep = this.getWorldEditPlugin(); + if (wep != null) + { + return wep.getSession(p); + } + } + catch (Exception ex) + { + TFM_Log.severe(ex); + } return null; } @@ -81,13 +76,12 @@ public class TFM_WorldEditBridge { try { - WorldEditAPI api = this.getWorldEditAPI(); - if (api != null) + LocalSession session = getPlayerSession(p); + if (session != null) { - LocalSession session = api.getSession(p); - if (session != null) + BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p); + if (bukkitPlayer != null) { - BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p); for (int i = 0; i < count; i++) { session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer); @@ -105,14 +99,10 @@ public class TFM_WorldEditBridge { try { - WorldEditAPI api = this.getWorldEditAPI(); - if (api != null) + LocalSession session = getPlayerSession(p); + if (session != null) { - LocalSession session = api.getSession(p); - if (session != null) - { - session.setBlockChangeLimit(limit); - } + session.setBlockChangeLimit(limit); } } catch (Exception ex)