Updated for latest Bukkit thingy.

This commit is contained in:
sk89q 2011-04-01 16:18:40 -07:00
parent 63beba8cba
commit 5173e953b4
6 changed files with 44 additions and 34 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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.
*