From 7b0977d58f0d160f7aa902d8efd8348b21ae0180 Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Wed, 20 Mar 2013 20:19:07 -0400 Subject: [PATCH] Fixing some things that weren't thread safe. More import / formatting cleanup. --- appinfo.properties | 6 +++--- buildnumber.properties | 4 ++-- .../TotalFreedomMod/Commands/Command_doom.java | 4 ++-- .../Listener/TFM_PlayerListener.java | 4 ++-- .../TotalFreedomMod/TFM_LandmineData.java | 1 - .../StevenLawson/TotalFreedomMod/TFM_UserList.java | 2 -- src/me/StevenLawson/TotalFreedomMod/TFM_Util.java | 13 ++++++++++++- .../TotalFreedomMod/TotalFreedomMod.java | 4 ++-- 8 files changed, 23 insertions(+), 15 deletions(-) diff --git a/appinfo.properties b/appinfo.properties index 189d3b9..f72a389 100644 --- a/appinfo.properties +++ b/appinfo.properties @@ -1,5 +1,5 @@ -#Tue, 19 Mar 2013 18:03:45 -0400 +#Wed, 20 Mar 2013 20:15:15 -0400 program.VERSION=2.11 -program.BUILDNUM=96 -program.BUILDDATE=03/19/2013 06\:03 PM +program.BUILDNUM=103 +program.BUILDDATE=03/20/2013 08\:15 PM diff --git a/buildnumber.properties b/buildnumber.properties index cebf671..b61f683 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Tue Mar 19 18:03:45 EDT 2013 -build.number=97 +#Wed Mar 20 20:15:15 EDT 2013 +build.number=104 diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java index 16124a5..33eefb2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_doom.java @@ -68,7 +68,7 @@ public class Command_doom extends TFM_Command // generate explosion p.getWorld().createExplosion(p.getLocation(), 4F); - server.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() + server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() @@ -81,7 +81,7 @@ public class Command_doom extends TFM_Command } }, 40L); // 2 seconds - server.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() + server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 7ede8a6..11e07bc 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -176,7 +176,7 @@ public class TFM_PlayerListener implements Listener last_block = test_block; } - Bukkit.getScheduler().runTaskLaterAsynchronously(TotalFreedomMod.plugin, new Runnable() + Bukkit.getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable() { @Override public void run() @@ -695,7 +695,7 @@ public class TFM_PlayerListener implements Listener if (TotalFreedomMod.adminOnlyMode) { - TotalFreedomMod.plugin.getServer().getScheduler().runTaskLaterAsynchronously(TotalFreedomMod.plugin, new Runnable() + TotalFreedomMod.plugin.getServer().getScheduler().scheduleSyncDelayedTask(TotalFreedomMod.plugin, new Runnable() { @Override public void run() diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java b/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java index 240ce61..d70d350 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java @@ -8,7 +8,6 @@ import org.bukkit.entity.Player; public class TFM_LandmineData { public static List landmines = new ArrayList(); - public Location landmine_pos; public Player player; public double radius; diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserList.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserList.java index ec177fd..e2fba73 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserList.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserList.java @@ -13,9 +13,7 @@ import org.bukkit.entity.Player; public class TFM_UserList { private static final String USERLIST_FILENAME = "userlist.yml"; - private static TFM_UserList instance = null; - private Map _userlist = new HashMap(); private final TotalFreedomMod _plugin; diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index d62cdb9..b76d760 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -18,7 +18,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.*; import org.bukkit.block.Block; -import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.*; @@ -973,4 +972,16 @@ public class TFM_Util } } } + + public static String inputStreamToString(InputStream is, boolean preserveNewlines) throws IOException + { + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + StringBuilder sb = new StringBuilder(); + String line; + while ((line = br.readLine()) != null) + { + sb.append(line).append(preserveNewlines ? System.lineSeparator() : ""); + } + return sb.toString(); + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index c998d34..6b95d0c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -101,7 +101,7 @@ public class TotalFreedomMod extends JavaPlugin TFM_Util.deleteFolder(new File("./_deleteme")); - server.getScheduler().runTaskTimerAsynchronously(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); + server.getScheduler().scheduleSyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); // metrics @ http://mcstats.org/plugin/TotalFreedomMod try @@ -298,7 +298,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();