mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 05:05:16 +01:00
Add support for AsyncPlayerChatEvent - make silly nagging STFU - still support 1.2.5
This commit is contained in:
parent
905802e558
commit
38a4d869f6
@ -41,6 +41,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
|||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
@ -51,6 +52,8 @@ import org.bukkit.event.world.SpawnChangeEvent;
|
|||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.event.world.WorldUnloadEvent;
|
import org.bukkit.event.world.WorldUnloadEvent;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.material.Tree;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -197,16 +200,36 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
}, DynmapPlugin.this);
|
}, DynmapPlugin.this);
|
||||||
break;
|
break;
|
||||||
case PLAYER_CHAT:
|
case PLAYER_CHAT:
|
||||||
pm.registerEvents(new Listener() {
|
try {
|
||||||
@EventHandler(priority=EventPriority.MONITOR)
|
Class.forName("org.bukkit.event.player.AsyncPlayerChatEvent");
|
||||||
public void onPlayerChat(PlayerChatEvent evt) {
|
pm.registerEvents(new Listener() {
|
||||||
if(evt.isCancelled()) return;
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
DynmapPlayer p = null;
|
public void onPlayerChat(AsyncPlayerChatEvent evt) {
|
||||||
if(evt.getPlayer() != null)
|
if(evt.isCancelled()) return;
|
||||||
p = new BukkitPlayer(evt.getPlayer());
|
final Player p = evt.getPlayer();
|
||||||
core.listenerManager.processChatEvent(EventType.PLAYER_CHAT, p, evt.getMessage());
|
final String msg = evt.getMessage();
|
||||||
}
|
getServer().getScheduler().scheduleSyncDelayedTask(DynmapPlugin.this, new Runnable() {
|
||||||
}, DynmapPlugin.this);
|
public void run() {
|
||||||
|
DynmapPlayer dp = null;
|
||||||
|
if(p != null)
|
||||||
|
dp = new BukkitPlayer(p);
|
||||||
|
core.listenerManager.processChatEvent(EventType.PLAYER_CHAT, dp, msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, DynmapPlugin.this);
|
||||||
|
} catch (ClassNotFoundException cnfx) {
|
||||||
|
pm.registerEvents(new Listener() {
|
||||||
|
@EventHandler(priority=EventPriority.MONITOR)
|
||||||
|
public void onPlayerChat(PlayerChatEvent evt) {
|
||||||
|
if(evt.isCancelled()) return;
|
||||||
|
DynmapPlayer p = null;
|
||||||
|
if(evt.getPlayer() != null)
|
||||||
|
p = new BukkitPlayer(evt.getPlayer());
|
||||||
|
core.listenerManager.processChatEvent(EventType.PLAYER_CHAT, p, evt.getMessage());
|
||||||
|
}
|
||||||
|
}, DynmapPlugin.this);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case BLOCK_BREAK:
|
case BLOCK_BREAK:
|
||||||
pm.registerEvents(new Listener() {
|
pm.registerEvents(new Listener() {
|
||||||
|
Loading…
Reference in New Issue
Block a user