diff --git a/src/com/massivecraft/mcore/sender/FakeBlockCommandSender.java b/src/com/massivecraft/mcore/sender/FakeBlockCommandSender.java deleted file mode 100644 index 3b28014f..00000000 --- a/src/com/massivecraft/mcore/sender/FakeBlockCommandSender.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.mcore.sender; - -import org.bukkit.Bukkit; -import org.bukkit.block.Block; -import org.bukkit.command.BlockCommandSender; - -public class FakeBlockCommandSender extends BasicCommandSender implements BlockCommandSender -{ - public FakeBlockCommandSender() - { - super("@", true, false); - } - - @Override - public Block getBlock() - { - return Bukkit.getWorlds().get(0).getBlockAt(0, 0, 0); - } - - // -------------------------------------------- // - // INSTANCE - // -------------------------------------------- // - - private static FakeBlockCommandSender i = new FakeBlockCommandSender(); - public static FakeBlockCommandSender get() { return i; } - -} diff --git a/src/com/massivecraft/mcore/store/SenderEntity.java b/src/com/massivecraft/mcore/store/SenderEntity.java index 283d21b3..73ac7d09 100644 --- a/src/com/massivecraft/mcore/store/SenderEntity.java +++ b/src/com/massivecraft/mcore/store/SenderEntity.java @@ -77,26 +77,6 @@ public abstract class SenderEntity> extends Entity return SenderUtil.isRconId(this.getId()); } - public boolean isBlock() - { - return SenderUtil.isBlockId(this.getId()); - } - - public boolean isNonplayer() - { - return SenderUtil.isNonplayerId(this.getId()); - } - - public boolean isStandardNonplayer() - { - return SenderUtil.isStandardNonplayerId(this.getId()); - } - - public boolean isNonstandardNonplayer() - { - return SenderUtil.isNonstandardNonplayerId(this.getId()); - } - // GET // TODO: Usage of sender instead of id here is cheating but is good performance-wise so it can be ok. diff --git a/src/com/massivecraft/mcore/util/SenderUtil.java b/src/com/massivecraft/mcore/util/SenderUtil.java index 6059f7a4..9a520439 100644 --- a/src/com/massivecraft/mcore/util/SenderUtil.java +++ b/src/com/massivecraft/mcore/util/SenderUtil.java @@ -23,7 +23,6 @@ import org.bukkit.entity.Player; import com.massivecraft.mcore.MCore; import com.massivecraft.mcore.event.MCoreSenderRegisterEvent; import com.massivecraft.mcore.event.MCoreSenderUnregisterEvent; -import com.massivecraft.mcore.sender.FakeBlockCommandSender; /** * We add an ID <--> CommandSender lookup feature. @@ -45,12 +44,10 @@ public class SenderUtil // Ids for standard-non-players public final static String ID_CONSOLE = IDPREFIX+"console"; public final static String ID_RCON = IDPREFIX+"rcon"; - public final static String ID_BLOCK = IDPREFIX+"block"; // Names for standard-non-players public final static String VANILLA_CONSOLE_NAME = "CONSOLE"; public final static String VANILLA_RCON_NAME = "Rcon"; - public final static String VANILLA_BLOCK_NAME = "@"; // -------------------------------------------- // // REGISTRY @@ -93,7 +90,6 @@ public class SenderUtil { register(getConsole()); register(getRcon()); - register(getBlock()); } }); } @@ -122,41 +118,12 @@ public class SenderUtil return ID_RCON.equals(o); } - public static boolean isBlockId(Object o) - { - return ID_BLOCK.equals(o); - } - - public static boolean isNonplayerId(Object o) - { - if (!isSenderId(o)) return false; - if (isPlayerId(o)) return false; - return true; - } - - public static boolean isStandardNonplayerId(Object o) - { - if (isConsoleId(o)) return true; - if (isRconId(o)) return true; - if (isBlockId(o)) return true; - return false; - } - - public static boolean isNonstandardNonplayerId(Object o) - { - if (!isSenderId(o)) return false; - if (isStandardNonplayerId(o)) return false; - if (isPlayerId(o)) return false; - return true; - } - // -------------------------------------------- // // SENDER/OBJECT TYPE CHECKING // -------------------------------------------- // public static boolean isSender(Object o) { - // The object must be a CommandSender and musn't be null. return o instanceof CommandSender; } @@ -165,6 +132,11 @@ public class SenderUtil return o instanceof Player; } + public static boolean isBlock(Object o) + { + return o instanceof BlockCommandSender; + } + public static boolean isConsole(Object o) { if (!(o instanceof ConsoleCommandSender)) return false; @@ -179,13 +151,6 @@ public class SenderUtil return true; } - public static boolean isBlock(Object o) - { - if (!(o instanceof BlockCommandSender)) return false; - if (!VANILLA_BLOCK_NAME.equals(((CommandSender)o).getName())) return false; - return true; - } - public static boolean isNonplayer(Object o) { if (!isSender(o)) return false; @@ -193,22 +158,6 @@ public class SenderUtil return true; } - public static boolean isStandardNonplayer(Object o) - { - if (isConsole(o)) return true; - if (isRcon(o)) return true; - if (isBlock(o)) return true; - return false; - } - - public static boolean isNonstandardNonplayer(Object o) - { - if (!isSender(o)) return false; - if (isStandardNonplayer(o)) return false; - if (isPlayer(o)) return false; - return true; - } - // -------------------------------------------- // // GET ID // -------------------------------------------- // @@ -219,8 +168,7 @@ public class SenderUtil if (isPlayer(o)) return ((CommandSender)o).getName(); if (isConsole(o)) return ID_CONSOLE; if (isRcon(o)) return ID_RCON; - if (isBlock(o)) return ID_BLOCK; - return IDPREFIX+((CommandSender)o).getName(); + return ((CommandSender)o).getName(); } // -------------------------------------------- // @@ -256,11 +204,6 @@ public class SenderUtil return getAsRcon(getSender(senderId)); } - public static BlockCommandSender getBlock(String senderId) - { - return getAsBlock(getSender(senderId)); - } - // MARCHAL STUFF public static CommandSender getAsSender(Object o) @@ -275,6 +218,12 @@ public class SenderUtil return (Player) o; } + public static BlockCommandSender getAsBlock(Object o) + { + if (!isBlock(o)) return null; + return (BlockCommandSender) o; + } + public static ConsoleCommandSender getAsConsole(Object o) { if (!isConsole(o)) return null; @@ -287,12 +236,6 @@ public class SenderUtil return (RemoteConsoleCommandSender) o; } - public static BlockCommandSender getAsBlock(Object o) - { - if (!isBlock(o)) return null; - return (BlockCommandSender) o; - } - // -------------------------------------------- // // GET STANDARD-NON-PLAYERS // -------------------------------------------- // @@ -310,11 +253,6 @@ public class SenderUtil return minecraftServer.remoteConsole; } - public static BlockCommandSender getBlock() - { - return FakeBlockCommandSender.get(); - } - // -------------------------------------------- // // GET ALL ONLINE // -------------------------------------------- //