diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-07 17:04:00 +1100 |
---|---|---|
committer | Andrew Ardill <andrew.ardill@gmail.com> | 2011-12-07 17:46:30 +1100 |
commit | 4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a (patch) | |
tree | 9f17134ef78895e4cdd15161b6fc022de18fefaa /src/main/java | |
parent | 93a4a9ba8ce37179bd903283c73c453c8abcc208 (diff) | |
download | craftbukkit-4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a.tar craftbukkit-4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a.tar.gz craftbukkit-4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a.tar.lz craftbukkit-4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a.tar.xz craftbukkit-4e318dd1c8e7b6b1cf741f9966a76fadc2f3ef1a.zip |
Implement new interface ConsoleCommandSender.
Also use abstracted ServerCommandSender to reduce complexity! Yay!
Diffstat (limited to 'src/main/java')
3 files changed, 37 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 45d74964..a70d1b3d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1,6 +1,8 @@ package org.bukkit.craftbukkit; import java.io.FileNotFoundException; + +import org.bukkit.craftbukkit.command.CraftConsoleCommandSender; import org.bukkit.generator.ChunkGenerator; import com.avaje.ebean.config.DataSourceConfig; import com.avaje.ebean.config.ServerConfig; diff --git a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java index 28f252e1..f1deb305 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java @@ -10,15 +10,15 @@ import org.bukkit.ChatColor; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.craftbukkit.CraftServer; -public class ColouredConsoleSender extends ConsoleCommandSender { +public class ColouredConsoleSender extends CraftConsoleCommandSender { private final ConsoleReader reader; private final Terminal terminal; private final Map<ChatColor, String> replacements = new EnumMap<ChatColor, String>(ChatColor.class); private final ChatColor[] colors = ChatColor.values(); - protected ColouredConsoleSender(CraftServer server) { - super(server); - this.reader = server.getReader(); + protected ColouredConsoleSender() { + super(); + this.reader = ((CraftServer) getServer()).getReader(); this.terminal = reader.getTerminal(); replacements.put(ChatColor.BLACK, ANSICodes.attrib(0)); @@ -61,7 +61,7 @@ public class ColouredConsoleSender extends ConsoleCommandSender { if (Bukkit.getConsoleSender() != null) { return Bukkit.getConsoleSender(); } else { - return new ColouredConsoleSender((CraftServer)Bukkit.getServer()); + return new ColouredConsoleSender(); } } } diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java new file mode 100644 index 00000000..2f9879ff --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.command; + +import org.bukkit.ChatColor; +import org.bukkit.command.ConsoleCommandSender; + +/** + * Represents CLI input from a console + */ +public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender { + + protected CraftConsoleCommandSender() { + super(); + } + + public void sendMessage(String message) { + System.out.println(ChatColor.stripColor(message)); + } + + public String getName() { + return "CONSOLE"; + } + + public boolean isOp() { + return true; + } + + public void setOp(boolean value) { + throw new UnsupportedOperationException("Cannot change operator status of server console"); + } +} |