Solved Sending a Message to Console?

Discussion in 'Plugin Development' started by SnipsRevival, Jul 11, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    SnipsRevival

    How can I log an info message to the console without having my plugin's name in square brackets at the beginning. Or how could I send a message to the console in the same format as sender.sendMessage(message) would when used in a command?
     
  2. Offline

    boboman13

    You can log without square brackets by creating your own logger of "Minecraft".
    Code:java
    1. /* I think thats the constructor */
    2. Logger log = Bukkit.getLogger();
    3. log.info("hi");
     
  3. Offline

    SnipsRevival

    boboman13 That helped get me off in the right direction, but I figured out an easier way.

    Code:
    ConsoleCommandSender console = getServer().getConsoleSender();
    console.sendMessage(message);
     
  4. Offline

    chris4315

    Might also be worthwhile to create a method that actually sends the console a message for you. Or you could simply just use the Logger.

    Here's a snippet:
    Code:java
    1.  
    2. public void tellConsole(String message){
    3. Bukkit.getConsoleSender().sendMessage(message);
    4. }
    5.  
     
  5. Offline

    Levi2241

    You could also do:
    Code:java
    1. public void logMsg(String message) {
    2. System.out.println(message);
    3. }
     
Thread Status:
Not open for further replies.

Share This Page