From 5173e953b4b4929ffe629cf6f8e2a940ad3e0bfb Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 1 Apr 2011 16:18:40 -0700 Subject: [PATCH] Updated for latest Bukkit thingy. --- .../PermissionsResolverServerListener.java | 7 ++-- src/com/sk89q/worldedit/EditSession.java | 2 +- .../sk89q/worldedit/bukkit/WorldEditAPI.java | 3 +- .../WorldEditCriticalPlayerListener.java | 6 ++-- .../bukkit/WorldEditPlayerListener.java | 26 +++++++------- .../worldedit/bukkit/WorldEditPlugin.java | 34 ++++++++++++------- 6 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java b/src/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java index ecb5dca24..92890e662 100644 --- a/src/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java +++ b/src/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java @@ -21,7 +21,8 @@ package com.sk89q.bukkit.migration; import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; -import org.bukkit.event.server.PluginEvent; +import org.bukkit.event.server.PluginDisableEvent; +import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; import org.bukkit.plugin.Plugin; @@ -38,7 +39,7 @@ public class PermissionsResolverServerListener extends ServerListener { * @param event Relevant event details */ @Override - public void onPluginEnable(PluginEvent event) { + public void onPluginEnable(PluginEnableEvent event) { Plugin plugin = event.getPlugin(); String name = plugin.getDescription().getName(); @@ -56,7 +57,7 @@ public class PermissionsResolverServerListener extends ServerListener { * @param event Relevant event details */ @Override - public void onPluginDisable(PluginEvent event) { + public void onPluginDisable(PluginDisableEvent event) { Plugin plugin = event.getPlugin(); String name = plugin.getDescription().getName(); diff --git a/src/com/sk89q/worldedit/EditSession.java b/src/com/sk89q/worldedit/EditSession.java index eeecc8f30..5f2ee4f8c 100755 --- a/src/com/sk89q/worldedit/EditSession.java +++ b/src/com/sk89q/worldedit/EditSession.java @@ -138,7 +138,7 @@ public class EditSession { * Sets a block without changing history. * * @param pt - * @param blockType + * @param block * @return Whether the block changed */ public boolean rawSetBlock(Vector pt, BaseBlock block) { diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditAPI.java b/src/com/sk89q/worldedit/bukkit/WorldEditAPI.java index b0b9484f5..41cd07fe4 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditAPI.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditAPI.java @@ -36,6 +36,7 @@ public class WorldEditAPI { * @return */ public LocalSession getSession(Player player) { - return plugin.controller.getSession(new BukkitPlayer(plugin, plugin.server, player)); + return plugin.getWorldEdit().getSession( + new BukkitPlayer(plugin, plugin.getServerInterface(), player)); } } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java b/src/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java index 29f1dcf6a..b7b59f573 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditCriticalPlayerListener.java @@ -20,7 +20,7 @@ package com.sk89q.worldedit.bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; /** @@ -47,11 +47,11 @@ public class WorldEditCriticalPlayerListener extends PlayerListener { * @param event Relevant event details */ @Override - public void onPlayerJoin(PlayerEvent event) { + public void onPlayerJoin(PlayerJoinEvent event) { wrapPlayer(event.getPlayer()).dispatchCUIHandshake(); } private BukkitPlayer wrapPlayer(Player player) { - return new BukkitPlayer(plugin, plugin.server, player); + return new BukkitPlayer(plugin, plugin.getServerInterface(), player); } } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java index 9d9457b24..b78a651d7 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java @@ -23,10 +23,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationType; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerQuitEvent; import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.WorldVector; @@ -51,14 +51,14 @@ public class WorldEditPlayerListener extends PlayerListener { LocalPlayer localPlayer = wrapPlayer(event.getPlayer()); if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) { - plugin.controller.handleArmSwing(localPlayer); + plugin.getWorldEdit().handleArmSwing(localPlayer); } // As of Minecraft 1.3, a block dig packet is no longer sent for // bedrock, so we have to do an (inaccurate) detection ourself WorldVector pt = localPlayer.getBlockTrace(5); if (pt != null && pt.getWorld().getBlockType(pt) == BlockID.BEDROCK) { - if (plugin.controller.handleBlockLeftClick(localPlayer, pt)) { + if (plugin.getWorldEdit().handleBlockLeftClick(localPlayer, pt)) { } } } @@ -78,8 +78,8 @@ public class WorldEditPlayerListener extends PlayerListener { * @param event Relevant event details */ @Override - public void onPlayerQuit(PlayerEvent event) { - plugin.controller.handleDisconnect(wrapPlayer(event.getPlayer())); + public void onPlayerQuit(PlayerQuitEvent event) { + plugin.getWorldEdit().handleDisconnect(wrapPlayer(event.getPlayer())); } /** @@ -88,10 +88,10 @@ public class WorldEditPlayerListener extends PlayerListener { * @param event Relevant event details */ @Override - public void onPlayerCommandPreprocess(PlayerChatEvent event) { + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { String[] split = event.getMessage().split(" "); - if (plugin.controller.handleCommand(wrapPlayer(event.getPlayer()), split)) { + if (plugin.getWorldEdit().handleCommand(wrapPlayer(event.getPlayer()), split)) { event.setCancelled(true); } } @@ -109,7 +109,7 @@ public class WorldEditPlayerListener extends PlayerListener { event.getClickedBlock().getY(), event.getClickedBlock().getZ()); LocalPlayer player = wrapPlayer(event.getPlayer()); - if (plugin.controller.handleBlockLeftClick(player, pos)) { + if (plugin.getWorldEdit().handleBlockLeftClick(player, pos)) { event.setCancelled(true); } } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { @@ -118,21 +118,21 @@ public class WorldEditPlayerListener extends PlayerListener { event.getClickedBlock().getY(), event.getClickedBlock().getZ()); LocalPlayer player = wrapPlayer(event.getPlayer()); - if (plugin.controller.handleBlockRightClick(player, pos)) { + if (plugin.getWorldEdit().handleBlockRightClick(player, pos)) { event.setCancelled(true); } - if (plugin.controller.handleRightClick(wrapPlayer(event.getPlayer()))) { + if (plugin.getWorldEdit().handleRightClick(wrapPlayer(event.getPlayer()))) { event.setCancelled(true); } } else if (event.getAction() == Action.RIGHT_CLICK_AIR) { - if (plugin.controller.handleRightClick(wrapPlayer(event.getPlayer()))) { + if (plugin.getWorldEdit().handleRightClick(wrapPlayer(event.getPlayer()))) { event.setCancelled(true); } } } private BukkitPlayer wrapPlayer(Player player) { - return new BukkitPlayer(plugin, plugin.server, player); + return new BukkitPlayer(plugin, plugin.getServerInterface(), player); } } diff --git a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 56260de20..3babb5e84 100644 --- a/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -31,7 +31,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockListener; import org.bukkit.event.player.PlayerListener; import org.bukkit.plugin.java.JavaPlugin; import com.sk89q.bukkit.migration.PermissionsResolverManager; @@ -55,15 +54,15 @@ public class WorldEditPlugin extends JavaPlugin { /** * The server interface that all server-related API goes through. */ - protected ServerInterface server; + private ServerInterface server; /** * Main WorldEdit instance. */ - protected WorldEdit controller; + private WorldEdit controller; /** * Deprecated API. */ - protected WorldEditAPI api; + private WorldEditAPI api; /** * Holds the configuration for WorldEdit. @@ -226,15 +225,6 @@ public class WorldEditPlugin extends JavaPlugin { return true; } - /** - * Get a reference to the WorldEdit object. - * - * @return - */ - public WorldEdit getWorldEdit() { - return controller; - } - /** * Gets the session for the player. * @@ -338,6 +328,24 @@ public class WorldEditPlugin extends JavaPlugin { return new BukkitPlayer(this, this.server, player); } + /** + * Get the server interface. + * + * @return + */ + public ServerInterface getServerInterface() { + return server; + } + + /** + * Get WorldEdit. + * + * @return + */ + public WorldEdit getWorldEdit() { + return controller; + } + /** * Gets the region selection for the player. *