diff --git a/pom.xml b/pom.xml
index 70425c4eb..df978711a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
org.bukkit
bukkit
- 1.0.1-R1
+ 1.1-R1-SNAPSHOT
diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java
deleted file mode 100644
index d8fcb3261..000000000
--- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// $Id$
-/*
- * WorldEdit
- * Copyright (C) 2010 sk89q
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
-*/
-
-package com.sk89q.worldedit.bukkit;
-
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event.Priority;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerListener;
-
-/**
- * Handles all events thrown in relation to a Player
- */
-public class WorldEditCriticalPlayerListener extends PlayerListener {
- /**
- * Plugin.
- */
- private WorldEditPlugin plugin;
-
- /**
- * Construct the object;
- *
- * @param plugin
- */
- public WorldEditCriticalPlayerListener(WorldEditPlugin plugin) {
- this.plugin = plugin;
-
- plugin.registerEvent("PLAYER_JOIN", this, Priority.Lowest);
- }
-
- /**
- * Called when a player joins a server
- *
- * @param event Relevant event details
- */
- @Override
- public void onPlayerJoin(PlayerJoinEvent event) {
- wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
- }
-
- private BukkitPlayer wrapPlayer(Player player) {
- return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
- }
-}
diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java
similarity index 83%
rename from src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java
rename to src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java
index e4b7b2e8f..87e7d1e7f 100644
--- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java
+++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditListener.java
@@ -1,7 +1,7 @@
// $Id$
/*
* WorldEdit
- * Copyright (C) 2010 sk89q
+ * Copyright (C) 2012 sk89q
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,19 +15,21 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
-*/
-
+ */
package com.sk89q.worldedit.bukkit;
import com.sk89q.util.StringUtil;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
-import org.bukkit.event.Event;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerListener;
+import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalWorld;
@@ -39,7 +41,7 @@ import java.util.regex.Pattern;
/**
* Handles all events thrown in relation to a Player
*/
-public class WorldEditPlayerListener extends PlayerListener {
+public class WorldEditListener implements Listener {
private WorldEditPlugin plugin;
private boolean ignoreLeftClickAir = false;
@@ -56,13 +58,13 @@ public class WorldEditPlayerListener extends PlayerListener {
*
* @param plugin
*/
- public WorldEditPlayerListener(WorldEditPlugin plugin) {
+ public WorldEditListener(WorldEditPlugin plugin) {
this.plugin = plugin;
+ }
- plugin.registerEvent("PLAYER_QUIT", this);
- plugin.registerEvent("PLAYER_INTERACT", this);
- plugin.registerEvent("PLAYER_COMMAND_PREPROCESS", this, Event.Priority.Low);
- plugin.registerEvent("PLAYER_CHAT", this);
+ @EventHandler(event = PlayerJoinEvent.class, priority = EventPriority.LOWEST)
+ public void onPlayerJoin(PlayerJoinEvent event) {
+ plugin.wrapPlayer(event.getPlayer()).dispatchCUIHandshake();
}
/**
@@ -70,7 +72,7 @@ public class WorldEditPlayerListener extends PlayerListener {
*
* @param event Relevant event details
*/
- @Override
+ @EventHandler(event = PlayerQuitEvent.class)
public void onPlayerQuit(PlayerQuitEvent event) {
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
}
@@ -80,7 +82,7 @@ public class WorldEditPlayerListener extends PlayerListener {
*
* @param event Relevant event details
*/
- @Override
+ @EventHandler(event = PlayerCommandPreprocessEvent.class, priority = EventPriority.LOW)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) {
return;
@@ -101,9 +103,9 @@ public class WorldEditPlayerListener extends PlayerListener {
*
* @param event Relevant event details
*/
- @Override
+ @EventHandler(event = PlayerInteractEvent.class)
public void onPlayerInteract(PlayerInteractEvent event) {
- if (event.useItemInHand() == Event.Result.DENY) {
+ if (event.useItemInHand() == Result.DENY) {
return;
}
@@ -165,7 +167,7 @@ public class WorldEditPlayerListener extends PlayerListener {
}
}
- @Override
+ @EventHandler(event = PlayerChatEvent.class)
public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) {
return;
diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
index 7278bdcd6..c4f4302e6 100644
--- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
+++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
@@ -103,7 +103,7 @@ public class WorldEditPlugin extends JavaPlugin {
api = new WorldEditAPI(this);
// Now we can register events!
- registerEvents();
+ getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);
getServer().getScheduler().scheduleAsyncRepeatingTask(this,
new SessionTimer(controller, getServer()), 120, 120);
@@ -134,40 +134,6 @@ public class WorldEditPlugin extends JavaPlugin {
getPermissionsResolver().load();
}
- /**
- * Register the events used by WorldEdit.
- */
- protected void registerEvents() {
- new WorldEditPlayerListener(this);
- new WorldEditCriticalPlayerListener(this);
- }
-
- /**
- * Register an event.
- *
- * @param typeName
- * @param listener
- * @param priority
- */
- public void registerEvent(String typeName, Listener listener, Priority priority) {
- try {
- Event.Type type = Event.Type.valueOf(typeName);
- getServer().getPluginManager().registerEvent(type, listener, priority, this);
- } catch (IllegalArgumentException e) {
- logger.info("WorldEdit: Unable to register missing event type " + typeName);
- }
- }
-
- /**
- * Register an event at normal priority.
- *
- * @param typeName
- * @param listener
- */
- public void registerEvent(String typeName, Listener listener) {
- registerEvent(typeName, listener, Event.Priority.Normal);
- }
-
/**
* Create a default configuration file from the .jar.
*