Updated for latest Bukkit thingy.

Dieser Commit ist enthalten in:
sk89q 2011-04-01 16:18:40 -07:00
Ursprung 63beba8cba
Commit 5173e953b4
6 geänderte Dateien mit 44 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,8 @@ package com.sk89q.bukkit.migration;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority; 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.event.server.ServerListener;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -38,7 +39,7 @@ public class PermissionsResolverServerListener extends ServerListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
@Override @Override
public void onPluginEnable(PluginEvent event) { public void onPluginEnable(PluginEnableEvent event) {
Plugin plugin = event.getPlugin(); Plugin plugin = event.getPlugin();
String name = plugin.getDescription().getName(); String name = plugin.getDescription().getName();
@ -56,7 +57,7 @@ public class PermissionsResolverServerListener extends ServerListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
@Override @Override
public void onPluginDisable(PluginEvent event) { public void onPluginDisable(PluginDisableEvent event) {
Plugin plugin = event.getPlugin(); Plugin plugin = event.getPlugin();
String name = plugin.getDescription().getName(); String name = plugin.getDescription().getName();

Datei anzeigen

@ -138,7 +138,7 @@ public class EditSession {
* Sets a block without changing history. * Sets a block without changing history.
* *
* @param pt * @param pt
* @param blockType * @param block
* @return Whether the block changed * @return Whether the block changed
*/ */
public boolean rawSetBlock(Vector pt, BaseBlock block) { public boolean rawSetBlock(Vector pt, BaseBlock block) {

Datei anzeigen

@ -36,6 +36,7 @@ public class WorldEditAPI {
* @return * @return
*/ */
public LocalSession getSession(Player player) { 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));
} }
} }

Datei anzeigen

@ -20,7 +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.player.PlayerEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
/** /**
@ -47,11 +47,11 @@ public class WorldEditCriticalPlayerListener extends PlayerListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
@Override @Override
public void onPlayerJoin(PlayerEvent 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.server, player); return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
} }
} }

Datei anzeigen

@ -23,10 +23,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerAnimationEvent; import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType; import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.WorldVector; import com.sk89q.worldedit.WorldVector;
@ -51,14 +51,14 @@ public class WorldEditPlayerListener extends PlayerListener {
LocalPlayer localPlayer = wrapPlayer(event.getPlayer()); LocalPlayer localPlayer = wrapPlayer(event.getPlayer());
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) { 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 // As of Minecraft 1.3, a block dig packet is no longer sent for
// bedrock, so we have to do an (inaccurate) detection ourself // bedrock, so we have to do an (inaccurate) detection ourself
WorldVector pt = localPlayer.getBlockTrace(5); WorldVector pt = localPlayer.getBlockTrace(5);
if (pt != null && pt.getWorld().getBlockType(pt) == BlockID.BEDROCK) { 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 * @param event Relevant event details
*/ */
@Override @Override
public void onPlayerQuit(PlayerEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
plugin.controller.handleDisconnect(wrapPlayer(event.getPlayer())); plugin.getWorldEdit().handleDisconnect(wrapPlayer(event.getPlayer()));
} }
/** /**
@ -88,10 +88,10 @@ public class WorldEditPlayerListener extends PlayerListener {
* @param event Relevant event details * @param event Relevant event details
*/ */
@Override @Override
public void onPlayerCommandPreprocess(PlayerChatEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String[] split = event.getMessage().split(" "); String[] split = event.getMessage().split(" ");
if (plugin.controller.handleCommand(wrapPlayer(event.getPlayer()), split)) { if (plugin.getWorldEdit().handleCommand(wrapPlayer(event.getPlayer()), split)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -109,7 +109,7 @@ public class WorldEditPlayerListener extends PlayerListener {
event.getClickedBlock().getY(), event.getClickedBlock().getZ()); event.getClickedBlock().getY(), event.getClickedBlock().getZ());
LocalPlayer player = wrapPlayer(event.getPlayer()); LocalPlayer player = wrapPlayer(event.getPlayer());
if (plugin.controller.handleBlockLeftClick(player, pos)) { if (plugin.getWorldEdit().handleBlockLeftClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
@ -118,21 +118,21 @@ public class WorldEditPlayerListener extends PlayerListener {
event.getClickedBlock().getY(), event.getClickedBlock().getZ()); event.getClickedBlock().getY(), event.getClickedBlock().getZ());
LocalPlayer player = wrapPlayer(event.getPlayer()); LocalPlayer player = wrapPlayer(event.getPlayer());
if (plugin.controller.handleBlockRightClick(player, pos)) { if (plugin.getWorldEdit().handleBlockRightClick(player, pos)) {
event.setCancelled(true); event.setCancelled(true);
} }
if (plugin.controller.handleRightClick(wrapPlayer(event.getPlayer()))) { if (plugin.getWorldEdit().handleRightClick(wrapPlayer(event.getPlayer()))) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (event.getAction() == Action.RIGHT_CLICK_AIR) { } 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); event.setCancelled(true);
} }
} }
} }
private BukkitPlayer wrapPlayer(Player player) { private BukkitPlayer wrapPlayer(Player player) {
return new BukkitPlayer(plugin, plugin.server, player); return new BukkitPlayer(plugin, plugin.getServerInterface(), player);
} }
} }

Datei anzeigen

@ -31,7 +31,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority; 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.block.BlockListener;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.bukkit.migration.PermissionsResolverManager; 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. * The server interface that all server-related API goes through.
*/ */
protected ServerInterface server; private ServerInterface server;
/** /**
* Main WorldEdit instance. * Main WorldEdit instance.
*/ */
protected WorldEdit controller; private WorldEdit controller;
/** /**
* Deprecated API. * Deprecated API.
*/ */
protected WorldEditAPI api; private WorldEditAPI api;
/** /**
* Holds the configuration for WorldEdit. * Holds the configuration for WorldEdit.
@ -226,15 +225,6 @@ public class WorldEditPlugin extends JavaPlugin {
return true; return true;
} }
/**
* Get a reference to the WorldEdit object.
*
* @return
*/
public WorldEdit getWorldEdit() {
return controller;
}
/** /**
* Gets the session for the player. * Gets the session for the player.
* *
@ -338,6 +328,24 @@ public class WorldEditPlugin extends JavaPlugin {
return new BukkitPlayer(this, this.server, player); 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. * Gets the region selection for the player.
* *