From 3104b73682943dc5b760d0278c6b499e00dcd619 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Thu, 14 Jun 2012 10:49:38 -0700 Subject: [PATCH] Fix WECUI not working for players when rejoining the server. Closes #196. --- .../worldedit/bukkit/CUIChannelListener.java | 2 +- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java b/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java index c4e729fdf..95da2a978 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/CUIChannelListener.java @@ -39,7 +39,7 @@ public class CUIChannelListener implements PluginMessageListener { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { LocalSession session = plugin.getSession(player); - if (session.hasCUISupport()) { // Already initialized + if (session.hasCUISupport() && plugin.hasPluginChannelCUI(player.getName())) { // Already initialized return; } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 3254f46ea..9e0d587cb 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -25,7 +25,9 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.jar.JarFile; import java.util.zip.ZipEntry; @@ -73,7 +75,7 @@ public class WorldEditPlugin extends JavaPlugin { /** * Stores players who are using plugin channels for the cui */ - private final Map pluginChannelCui = new HashMap(); + private final Set pluginChannelCui = new HashSet(); /** * Called on plugin enable. @@ -391,15 +393,14 @@ public class WorldEditPlugin extends JavaPlugin { } public void setPluginChannelCUI(String name, boolean value) { - pluginChannelCui.put(name, value); + if (value) { + pluginChannelCui.add(name); + } else { + pluginChannelCui.remove(name); + } } public boolean hasPluginChannelCUI(String name) { - Boolean val = pluginChannelCui.get(name); - if (val == null) { - return false; - } else { - return val; - } + return pluginChannelCui.contains(name); } }