Change PlayerChatEvent to AsyncPlayerChatEvent
This commit is contained in:
ementalo 2012-08-04 09:25:54 +01:00
parent 1a07815f4b
commit af73c11638
13 changed files with 32 additions and 32 deletions

View File

@ -67,7 +67,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials public class Essentials extends JavaPlugin implements IEssentials
{ {
public static final int BUKKIT_VERSION = 2267; public static final int BUKKIT_VERSION = 2289;
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings; private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View File

@ -50,7 +50,7 @@ public class EssentialsPlayerListener implements Listener
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if (user.isMuted()) if (user.isMuted())

View File

@ -8,7 +8,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -34,7 +34,7 @@ public class EssentialsChat extends JavaPlugin
} }
chatListener = new ConcurrentSkipListMap<String, IEssentialsChatListener>(); chatListener = new ConcurrentSkipListMap<String, IEssentialsChatListener>();
final Map<PlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<PlayerChatEvent, ChatStore>()); final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<AsyncPlayerChatEvent, ChatStore>());
final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatListener, chatStore); final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatListener, chatStore);

View File

@ -12,7 +12,7 @@ import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
//TODO: Translate the local/spy tags //TODO: Translate the local/spy tags
public abstract class EssentialsChatPlayer implements Listener public abstract class EssentialsChatPlayer implements Listener
@ -21,12 +21,12 @@ public abstract class EssentialsChatPlayer implements Listener
protected final static Logger logger = Logger.getLogger("Minecraft"); protected final static Logger logger = Logger.getLogger("Minecraft");
protected final transient Map<String, IEssentialsChatListener> listeners; protected final transient Map<String, IEssentialsChatListener> listeners;
protected final transient Server server; protected final transient Server server;
protected final transient Map<PlayerChatEvent, ChatStore> chatStorage; protected final transient Map<AsyncPlayerChatEvent, ChatStore> chatStorage;
public EssentialsChatPlayer(final Server server, public EssentialsChatPlayer(final Server server,
final IEssentials ess, final IEssentials ess,
final Map<String, IEssentialsChatListener> listeners, final Map<String, IEssentialsChatListener> listeners,
final Map<PlayerChatEvent, ChatStore> chatStorage) final Map<AsyncPlayerChatEvent, ChatStore> chatStorage)
{ {
this.ess = ess; this.ess = ess;
this.listeners = listeners; this.listeners = listeners;
@ -34,11 +34,11 @@ public abstract class EssentialsChatPlayer implements Listener
this.chatStorage = chatStorage; this.chatStorage = chatStorage;
} }
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
} }
public boolean isAborted(final PlayerChatEvent event) public boolean isAborted(final AsyncPlayerChatEvent event)
{ {
if (event.isCancelled()) if (event.isCancelled())
{ {
@ -69,17 +69,17 @@ public abstract class EssentialsChatPlayer implements Listener
} }
} }
public ChatStore getChatStore(final PlayerChatEvent event) public ChatStore getChatStore(final AsyncPlayerChatEvent event)
{ {
return chatStorage.get(event); return chatStorage.get(event);
} }
public void setChatStore(final PlayerChatEvent event, final ChatStore chatStore) public void setChatStore(final AsyncPlayerChatEvent event, final ChatStore chatStore)
{ {
chatStorage.put(event, chatStore); chatStorage.put(event, chatStore);
} }
public ChatStore delChatStore(final PlayerChatEvent event) public ChatStore delChatStore(final AsyncPlayerChatEvent event)
{ {
return chatStorage.remove(event); return chatStorage.remove(event);
} }
@ -89,7 +89,7 @@ public abstract class EssentialsChatPlayer implements Listener
charge.charge(user); charge.charge(user);
} }
protected boolean charge(final PlayerChatEvent event, final ChatStore chatStore) protected boolean charge(final AsyncPlayerChatEvent event, final ChatStore chatStore)
{ {
try try
{ {
@ -104,7 +104,7 @@ public abstract class EssentialsChatPlayer implements Listener
return true; return true;
} }
protected void sendLocalChat(final PlayerChatEvent event, final ChatStore chatStore) protected void sendLocalChat(final AsyncPlayerChatEvent event, final ChatStore chatStore)
{ {
event.setCancelled(true); event.setCancelled(true);
final User sender = chatStore.getUser(); final User sender = chatStore.getUser();

View File

@ -5,7 +5,7 @@ import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
@ -13,14 +13,14 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
public EssentialsChatPlayerListenerHighest(final Server server, public EssentialsChatPlayerListenerHighest(final Server server,
final IEssentials ess, final IEssentials ess,
final Map<String, IEssentialsChatListener> listeners, final Map<String, IEssentialsChatListener> listeners,
final Map<PlayerChatEvent, ChatStore> chatStorage) final Map<AsyncPlayerChatEvent, ChatStore> chatStorage)
{ {
super(server, ess, listeners, chatStorage); super(server, ess, listeners, chatStorage);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@Override @Override
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
final ChatStore chatStore = delChatStore(event); final ChatStore chatStore = delChatStore(event);
if (isAborted(event)) if (isAborted(event))

View File

@ -9,7 +9,7 @@ import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
@ -17,14 +17,14 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
public EssentialsChatPlayerListenerLowest(final Server server, public EssentialsChatPlayerListenerLowest(final Server server,
final IEssentials ess, final IEssentials ess,
final Map<String, IEssentialsChatListener> listeners, final Map<String, IEssentialsChatListener> listeners,
final Map<PlayerChatEvent, ChatStore> chatStorage) final Map<AsyncPlayerChatEvent, ChatStore> chatStorage)
{ {
super(server, ess, listeners, chatStorage); super(server, ess, listeners, chatStorage);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
@Override @Override
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
if (isAborted(event)) if (isAborted(event))
{ {

View File

@ -8,7 +8,7 @@ import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
@ -16,14 +16,14 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
public EssentialsChatPlayerListenerNormal(final Server server, public EssentialsChatPlayerListenerNormal(final Server server,
final IEssentials ess, final IEssentials ess,
final Map<String, IEssentialsChatListener> listeners, final Map<String, IEssentialsChatListener> listeners,
final Map<PlayerChatEvent, ChatStore> chatStorage) final Map<AsyncPlayerChatEvent, ChatStore> chatStorage)
{ {
super(server, ess, listeners, chatStorage); super(server, ess, listeners, chatStorage);
} }
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
@Override @Override
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
if (isAborted(event)) if (isAborted(event))
{ {

View File

@ -1,12 +1,12 @@
package com.earth2me.essentials.chat; package com.earth2me.essentials.chat;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
public interface IEssentialsChatListener public interface IEssentialsChatListener
{ {
boolean shouldHandleThisChat(PlayerChatEvent event); boolean shouldHandleThisChat(AsyncPlayerChatEvent event);
String modifyMessage(PlayerChatEvent event, Player target, String message); String modifyMessage(AsyncPlayerChatEvent event, Player target, String message);
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -154,7 +154,7 @@ public class EssentialsHelp implements Listener
} }
@EventHandler @EventHandler
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
if (event.getPlayer() == chatUser) if (event.getPlayer() == chatUser)
{ {

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -100,7 +100,7 @@ public class UpdateProcess implements Listener
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
if (event.getPlayer() == currentPlayer) if (event.getPlayer() == currentPlayer)
{ {

View File

@ -5,7 +5,7 @@ import com.earth2me.essentials.User;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -28,7 +28,7 @@ class EssentialsXMPPPlayerListener implements Listener
} }
@EventHandler(priority= EventPriority.MONITOR) @EventHandler(priority= EventPriority.MONITOR)
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final AsyncPlayerChatEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage())); sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage()));

Binary file not shown.

Binary file not shown.