package net.minecraft.network.rcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; public class RConConsoleSource implements ICommandSender { /** Single instance of RConConsoleSource */ public static final RConConsoleSource instance = new RConConsoleSource(); /** RCon string buffer for log. */ private StringBuffer buffer = new StringBuffer(); private static final String __OBFID = "CL_00001800"; /** * Gets the name of this command sender (usually username, but possibly "Rcon") */ public String getCommandSenderName() { return "Rcon"; } public IChatComponent getFormattedCommandSenderName() { return new ChatComponentText(this.getCommandSenderName()); } /** * Notifies this sender of some sort of information. This is for messages intended to display to the user. Used * for typical output (like "you asked for whether or not this game rule is set, so here's your answer"), warnings * (like "I fetched this block for you by ID, but I'd like you to know that every time you do this, I die a little * inside"), and errors (like "it's not called iron_pixacke, silly"). */ public void addChatMessage(IChatComponent message) { this.buffer.append(message.getUnformattedText()); } /** * Returns true if the command sender is allowed to use the given command. */ public boolean canCommandSenderUseCommand(int permissionLevel, String command) { return true; } /** * Return the position for this command sender. */ public ChunkCoordinates getCommandSenderPosition() { return new ChunkCoordinates(0, 0, 0); } public World getEntityWorld() { return MinecraftServer.getServer().getEntityWorld(); } /** * Clears the RCon log */ @SideOnly(Side.SERVER) public void resetLog() { this.buffer.setLength(0); } /** * Gets the contents of the RCon log */ @SideOnly(Side.SERVER) public String getLogContents() { return this.buffer.toString(); } }