Added an asPlayer method to LocalCommandSender, which casts the object to LocalPlayer if possible and throws an exception otherwise.

This commit is contained in:
TomyLobo 2011-12-13 03:43:26 +01:00
parent 3960726d7a
commit 87940c9eae
3 changed files with 13 additions and 0 deletions

View File

@ -114,4 +114,8 @@ public abstract class LocalCommandSender {
public int hashCode() {
return getName().hashCode();
}
public LocalPlayer asPlayer() throws PlayerNeededException {
throw new PlayerNeededException();
}
}

View File

@ -549,4 +549,8 @@ public abstract class LocalPlayer extends LocalCommandSender {
public void dispatchCUIHandshake() {
}
@Override
public LocalPlayer asPlayer() {
return this;
}
}

View File

@ -0,0 +1,5 @@
package com.sk89q.worldedit;
public class PlayerNeededException extends WorldEditException {
private static final long serialVersionUID = 1L;
}