mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-20 02:45:00 +00:00
- Moved Bukkit event registration from WorldEditPlugin into the respective listeners.
- Changed registerEvent to the string-based system WorldGuard has, which should improve compatibility with differing Bukkit versions.
This commit is contained in:
parent
d12bff993b
commit
9de9004834
@ -20,6 +20,7 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ public class WorldEditCriticalPlayerListener extends PlayerListener {
|
|||||||
*/
|
*/
|
||||||
public WorldEditCriticalPlayerListener(WorldEditPlugin plugin) {
|
public WorldEditCriticalPlayerListener(WorldEditPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
plugin.registerEvent("PLAYER_JOIN", this, Priority.Lowest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +53,7 @@ public class WorldEditCriticalPlayerListener extends PlayerListener {
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
|
wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BukkitPlayer wrapPlayer(Player player) {
|
private BukkitPlayer wrapPlayer(Player player) {
|
||||||
return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
|
return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,10 @@ public class WorldEditPlayerListener extends PlayerListener {
|
|||||||
*/
|
*/
|
||||||
public WorldEditPlayerListener(WorldEditPlugin plugin) {
|
public WorldEditPlayerListener(WorldEditPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
plugin.registerEvent("PLAYER_QUIT", this);
|
||||||
|
plugin.registerEvent("PLAYER_INTERACT", this);
|
||||||
|
plugin.registerEvent("PLAYER_COMMAND_PREPROCESS", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.event.Event.Priority;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||||
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
||||||
@ -135,14 +136,11 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
* Register the events used by WorldEdit.
|
* Register the events used by WorldEdit.
|
||||||
*/
|
*/
|
||||||
protected void registerEvents() {
|
protected void registerEvents() {
|
||||||
|
@SuppressWarnings("unused")
|
||||||
PlayerListener playerListener = new WorldEditPlayerListener(this);
|
PlayerListener playerListener = new WorldEditPlayerListener(this);
|
||||||
|
@SuppressWarnings("unused")
|
||||||
PlayerListener criticalPlayerListener = new WorldEditCriticalPlayerListener(this);
|
PlayerListener criticalPlayerListener = new WorldEditCriticalPlayerListener(this);
|
||||||
|
|
||||||
registerEvent(Event.Type.PLAYER_QUIT, playerListener);
|
|
||||||
registerEvent(Event.Type.PLAYER_INTERACT, playerListener);
|
|
||||||
registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener);
|
|
||||||
registerEvent(Event.Type.PLAYER_JOIN, criticalPlayerListener, Priority.Lowest);
|
|
||||||
|
|
||||||
// The permissions resolver has some hooks of its own
|
// The permissions resolver has some hooks of its own
|
||||||
(new PermissionsResolverServerListener(perms)).register(this);
|
(new PermissionsResolverServerListener(perms)).register(this);
|
||||||
}
|
}
|
||||||
@ -154,9 +152,16 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
* @param listener
|
* @param listener
|
||||||
* @param priority
|
* @param priority
|
||||||
*/
|
*/
|
||||||
protected void registerEvent(Event.Type type, Listener listener, Priority priority) {
|
protected void registerEvent(String typeName, Listener listener, Priority priority) {
|
||||||
getServer().getPluginManager()
|
try {
|
||||||
.registerEvent(type, listener, priority, this);
|
Event.Type type = Event.Type.valueOf(typeName);
|
||||||
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
pm.registerEvent(type, listener, priority, this);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.info("WorldGuard: Unable to register missing event type " + typeName);
|
||||||
|
}
|
||||||
|
/*getServer().getPluginManager()
|
||||||
|
.registerEvent(type, listener, priority, this);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,9 +170,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
* @param type
|
* @param type
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
protected void registerEvent(Event.Type type, Listener listener) {
|
protected void registerEvent(String typeName, Listener listener) {
|
||||||
getServer().getPluginManager()
|
registerEvent(typeName, listener, Event.Priority.Normal);
|
||||||
.registerEvent(type, listener, Priority.Normal, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user