mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 18:27:17 +01:00
Blocked access to ColouredConsoleSenders constructor, implemented getConsoleSender
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
86526921b7
commit
7cddc13d28
2 changed files with 14 additions and 1 deletions
|
@ -839,4 +839,8 @@ public final class CraftServer implements Server {
|
|||
((CraftWorld)world).getHandle().worldData.setGameType(mode.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public ConsoleCommandSender getConsoleSender() {
|
||||
return console.console;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue