Blocked access to ColouredConsoleSenders constructor, implemented getConsoleSender

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
CraftBukkit/Spigot 2011-09-24 23:14:13 +01:00
parent 86526921b7
commit 7cddc13d28
2 changed files with 14 additions and 1 deletions

View file

@ -839,4 +839,8 @@ public final class CraftServer implements Server {
((CraftWorld)world).getHandle().worldData.setGameType(mode.getValue());
}
}
public ConsoleCommandSender getConsoleSender() {
return console.console;
}
}

View file

@ -5,6 +5,7 @@ import java.util.Map;
import jline.ANSIBuffer.ANSICodes;
import jline.ConsoleReader;
import jline.Terminal;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.craftbukkit.CraftServer;
@ -15,7 +16,7 @@ public class ColouredConsoleSender extends ConsoleCommandSender {
private final Map<ChatColor, String> replacements = new EnumMap<ChatColor, String>(ChatColor.class);
private final ChatColor[] colors = ChatColor.values();
public ColouredConsoleSender(CraftServer server) {
protected ColouredConsoleSender(CraftServer server) {
super(server);
this.reader = server.getReader();
this.terminal = reader.getTerminal();
@ -55,4 +56,12 @@ public class ColouredConsoleSender extends ConsoleCommandSender {
super.sendMessage(message);
}
}
public static ConsoleCommandSender getInstance() {
if (Bukkit.getConsoleSender() != null) {
return Bukkit.getConsoleSender();
} else {
return new ColouredConsoleSender((CraftServer)Bukkit.getServer());
}
}
}