From 88dd420d1fb19234534d6afcc3c5362e660bba7e Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Thu, 15 Dec 2011 11:27:22 +0100 Subject: [PATCH] Removed LocalCommandSender again. Didn't lead to anything. --- .../sk89q/worldedit/LocalCommandSender.java | 121 ------------------ .../java/com/sk89q/worldedit/LocalPlayer.java | 112 +++++++++++++++- .../worldedit/PlayerNeededException.java | 5 - 3 files changed, 108 insertions(+), 130 deletions(-) delete mode 100644 src/main/java/com/sk89q/worldedit/LocalCommandSender.java delete mode 100644 src/main/java/com/sk89q/worldedit/PlayerNeededException.java diff --git a/src/main/java/com/sk89q/worldedit/LocalCommandSender.java b/src/main/java/com/sk89q/worldedit/LocalCommandSender.java deleted file mode 100644 index 9f29a32fd..000000000 --- a/src/main/java/com/sk89q/worldedit/LocalCommandSender.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.sk89q.worldedit; - -import java.io.File; - -public abstract class LocalCommandSender { - /** - * Server. - */ - protected ServerInterface server; - - public LocalCommandSender(ServerInterface server) { - this.server = server; - } - - /** - * Get the name of the player. - * - * @return String - */ - public abstract String getName(); - - /** - * Print a message. - * - * @param msg - */ - public abstract void printRaw(String msg); - - /** - * Print a WorldEdit message. - * - * @param msg - */ - public abstract void printDebug(String msg); - - /** - * Print a WorldEdit message. - * - * @param msg - */ - public abstract void print(String msg); - - /** - * Print a WorldEdit error. - * - * @param msg - */ - public abstract void printError(String msg); - - /** - * Get a player's list of groups. - * - * @return - */ - public abstract String[] getGroups(); - - /** - * Checks if a player has permission. - * - * @param perm - * @return - */ - public abstract boolean hasPermission(String perm); - - public void checkPermission(String permission) throws WorldEditPermissionException { - if (!hasPermission(permission)) { - throw new WorldEditPermissionException(); - } - } - - /** - * Open a file open dialog. - * - * @param extensions null to allow all - * @return - */ - public File openFileOpenDialog(String[] extensions) { - printError("File dialogs are not supported in your environment."); - return null; - } - - /** - * Open a file save dialog. - * - * @param extensions null to allow all - * @return - */ - public File openFileSaveDialog(String[] extensions) { - printError("File dialogs are not supported in your environment."); - return null; - } - - /** - * Returns true if equal. - * - * @param other - * @return whether the other object is equivalent - */ - @Override - public boolean equals(Object other) { - if (!(other instanceof LocalCommandSender)) { - return false; - } - LocalCommandSender other2 = (LocalCommandSender) other; - return other2.getName().equals(getName()); - } - - /** - * Gets the hash code. - * - * @return hash code - */ - @Override - public int hashCode() { - return getName().hashCode(); - } - - public LocalPlayer asPlayer() throws PlayerNeededException { - throw new PlayerNeededException(); - } -} diff --git a/src/main/java/com/sk89q/worldedit/LocalPlayer.java b/src/main/java/com/sk89q/worldedit/LocalPlayer.java index 983343161..715723e67 100644 --- a/src/main/java/com/sk89q/worldedit/LocalPlayer.java +++ b/src/main/java/com/sk89q/worldedit/LocalPlayer.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit; +import java.io.File; import com.sk89q.worldedit.bags.BlockBag; import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.BlockType; @@ -30,14 +31,19 @@ import com.sk89q.worldedit.util.TargetBlock; * * @author sk89q */ -public abstract class LocalPlayer extends LocalCommandSender { +public abstract class LocalPlayer { + /** + * Server. + */ + protected ServerInterface server; + /** * Construct the object. * * @param server */ protected LocalPlayer(ServerInterface server) { - super(server); + this.server = server; } /** @@ -406,6 +412,13 @@ public abstract class LocalPlayer extends LocalCommandSender { */ public abstract int getItemInHand(); + /** + * Get the name of the player. + * + * @return String + */ + public abstract String getName(); + /** * Get the player's position. * @@ -501,6 +514,34 @@ public abstract class LocalPlayer extends LocalCommandSender { return false; } + /** + * Print a message. + * + * @param msg + */ + public abstract void printRaw(String msg); + + /** + * Print a WorldEdit message. + * + * @param msg + */ + public abstract void printDebug(String msg); + + /** + * Print a WorldEdit message. + * + * @param msg + */ + public abstract void print(String msg); + + /** + * Print a WorldEdit error. + * + * @param msg + */ + public abstract void printError(String msg); + /** * Move the player. * @@ -519,6 +560,13 @@ public abstract class LocalPlayer extends LocalCommandSender { setPosition(pos, (float) getPitch(), (float) getYaw()); } + /** + * Get a player's list of groups. + * + * @return + */ + public abstract String[] getGroups(); + /** * Get this player's block bag. * @@ -526,6 +574,36 @@ public abstract class LocalPlayer extends LocalCommandSender { */ public abstract BlockBag getInventoryBlockBag(); + /** + * Checks if a player has permission. + * + * @param perm + * @return + */ + public abstract boolean hasPermission(String perm); + + /** + * Open a file open dialog. + * + * @param extensions null to allow all + * @return + */ + public File openFileOpenDialog(String[] extensions) { + printError("File dialogs are not supported in your environment."); + return null; + } + + /** + * Open a file save dialog. + * + * @param extensions null to allow all + * @return + */ + public File openFileSaveDialog(String[] extensions) { + printError("File dialogs are not supported in your environment."); + return null; + } + /** * Returns true if the player can destroy bedrock. * @@ -549,8 +627,34 @@ public abstract class LocalPlayer extends LocalCommandSender { public void dispatchCUIHandshake() { } + /** + * Returns true if equal. + * + * @param other + * @return whether the other object is equivalent + */ @Override - public LocalPlayer asPlayer() { - return this; + public boolean equals(Object other) { + if (!(other instanceof LocalPlayer)) { + return false; + } + LocalPlayer other2 = (LocalPlayer) other; + return other2.getName().equals(getName()); + } + + /** + * Gets the hash code. + * + * @return hash code + */ + @Override + public int hashCode() { + return getName().hashCode(); + } + + public void checkPermission(String permission) throws WorldEditPermissionException { + if (!hasPermission(permission)) { + throw new WorldEditPermissionException(); + } } } diff --git a/src/main/java/com/sk89q/worldedit/PlayerNeededException.java b/src/main/java/com/sk89q/worldedit/PlayerNeededException.java deleted file mode 100644 index 83c459cae..000000000 --- a/src/main/java/com/sk89q/worldedit/PlayerNeededException.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.sk89q.worldedit; - -public class PlayerNeededException extends WorldEditException { - private static final long serialVersionUID = 1L; -}