diff --git a/buildnumber.properties b/buildnumber.properties index b4614b9..d296377 100644 --- a/buildnumber.properties +++ b/buildnumber.properties @@ -1,3 +1,3 @@ #Build Number for ANT. Do not edit! -#Sun Apr 26 22:23:22 CEST 2015 -build.number=990 +#Mon Apr 27 00:31:14 CEST 2015 +build.number=991 diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uuid.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uuid.java index c91351b..2f88c55 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uuid.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_uuid.java @@ -27,7 +27,8 @@ public class Command_uuid extends TFM_Command return false; } - if ("purge".equals(args[0])) { + if ("purge".equals(args[0])) + { playerMsg("Purged " + TFM_UuidManager.purge() + " cached UUIDs."); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index 84260f3..5af7d94 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -23,6 +23,7 @@ import me.StevenLawson.TotalFreedomMod.TFM_PlayerRank; import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager; import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry; import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface; +import me.StevenLawson.TotalFreedomMod.TFM_Sync; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_UuidManager; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; @@ -558,7 +559,7 @@ public class TFM_PlayerListener implements Listener final Player player = event.getPlayer(); String message = event.getMessage().trim(); - final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); + final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerDataSync(player); // Check for spam final Long lastRan = TFM_Heartbeat.getLastRan(); @@ -570,8 +571,8 @@ public class TFM_PlayerListener implements Listener { if (playerdata.incrementAndGetMsgCount() > MSG_PER_HEARTBEAT) { - TFM_Util.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); - TFM_Util.autoEject(player, "Kicked for spamming chat."); + TFM_Sync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); + TFM_Sync.autoEject(player, "Kicked for spamming chat."); playerdata.resetMsgCount(); @@ -583,7 +584,7 @@ public class TFM_PlayerListener implements Listener // Check for message repeat if (playerdata.getLastMessage().equalsIgnoreCase(message)) { - TFM_Util.playerMsg(player, "Please do not repeat messages."); + TFM_Sync.playerMsg(player, "Please do not repeat messages."); event.setCancelled(true); return; } @@ -593,9 +594,9 @@ public class TFM_PlayerListener implements Listener // Check for muted if (playerdata.isMuted()) { - if (!TFM_AdminList.isSuperAdmin(player)) + if (!TFM_AdminList.isSuperAdminSync(player)) { - player.sendMessage(ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes."); + TFM_Sync.playerMsg(player, ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes."); event.setCancelled(true); return; } @@ -610,7 +611,7 @@ public class TFM_PlayerListener implements Listener if (message.length() > 100) { message = message.substring(0, 100); - TFM_Util.playerMsg(player, "Message was shortened because it was too long to send."); + TFM_Sync.playerMsg(player, "Message was shortened because it was too long to send."); } // Check for caps @@ -633,7 +634,7 @@ public class TFM_PlayerListener implements Listener // Check for adminchat if (playerdata.inAdminChat()) { - TFM_Util.adminChatMessage(player, message, false); + TFM_Sync.adminChatMessage(player, message, false); event.setCancelled(true); return; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java index 05d8343..70d2d3e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_AdminList.java @@ -43,7 +43,8 @@ public class TFM_AdminList seniorConsoleNames = new HashSet(); superIps = new HashSet(); - SUPERADMIN_SERVICE = new Function() { + SUPERADMIN_SERVICE = new Function() + { @Override public Boolean apply(Player f) @@ -414,6 +415,10 @@ public class TFM_AdminList return admin != null && admin.isActivated(); } + public static synchronized boolean isSuperAdminSync(CommandSender sender) { + return isSuperAdmin(sender); + } + public static boolean isSuperAdmin(CommandSender sender) { if (!(sender instanceof Player)) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java index dff9403..a3e5dac 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_PlayerData.java @@ -29,6 +29,14 @@ public class TFM_PlayerData return PLAYER_DATA.containsKey(TFM_Util.getIp(player)); } + public static TFM_PlayerData getPlayerDataSync(Player player) + { + synchronized (PLAYER_DATA) + { + return getPlayerData(player); + } + } + public static TFM_PlayerData getPlayerData(Player player) { final String ip = TFM_Util.getIp(player); diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java index 5cce391..4b46c4b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_ServerInterface.java @@ -30,7 +30,8 @@ public class TFM_ServerInterface { String[] whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted(); int size = whitelisted.length; - for (EntityPlayer player : MinecraftServer.getServer().getPlayerList().players) { + for (EntityPlayer player : MinecraftServer.getServer().getPlayerList().players) + { MinecraftServer.getServer().getPlayerList().getWhitelist().remove(player.getProfile()); } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Sync.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Sync.java new file mode 100644 index 0000000..0852250 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Sync.java @@ -0,0 +1,80 @@ +package me.StevenLawson.TotalFreedomMod; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; + +public class TFM_Sync +{ + + public static void playerMsg(final Player player, final String message) + { + new BukkitRunnable() + { + + @Override + public void run() + { + TFM_Util.playerMsg(player, message); + } + + }.runTask(TotalFreedomMod.plugin); + } + + public static void playerKick(final Player player, final String reason) + { + new BukkitRunnable() + { + + @Override + public void run() + { + player.kickPlayer(reason); + } + + }.runTask(TotalFreedomMod.plugin); + } + + public static void adminChatMessage(final CommandSender sender, final String message, final boolean isRed) + { + new BukkitRunnable() + { + + @Override + public void run() + { + TFM_Util.adminChatMessage(sender, message, isRed); + } + + }.runTask(TotalFreedomMod.plugin); + } + + public static void autoEject(final Player player, final String kickMessage) + { + new BukkitRunnable() + { + + @Override + public void run() + { + TFM_Util.autoEject(player, kickMessage); + } + + }.runTask(TotalFreedomMod.plugin); + } + + public static void bcastMsg(final String message, final ChatColor color) + { + new BukkitRunnable() + { + + @Override + public void run() + { + TFM_Util.bcastMsg(message, color); + } + + }.runTask(TotalFreedomMod.plugin); + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UuidManager.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UuidManager.java index 37d4127..086f02b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UuidManager.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UuidManager.java @@ -122,8 +122,10 @@ public class TFM_UuidManager return generateSpoofUuid(username); } - public static void rawSetUUID(String name, UUID uuid) { - if (name == null || uuid == null || name.isEmpty()) { + public static void rawSetUUID(String name, UUID uuid) + { + if (name == null || uuid == null || name.isEmpty()) + { TFM_Log.warning("Not setting raw UUID: name and uuid may not be null!"); return; }