Sending formatted msg to player

Discussion in 'Plugin Development' started by zajacmp3, Mar 31, 2013.

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



    I want to make a formatted msg sended to a player.
    Normally to send something like it to standard output I make something like this:
    System.out.printf( "%-15s %15s %n", heading1, heading2);

    and I get heading1 blank space filling up to 15 characters long and heading 2.

    How can I make something similar to be sended to player as a msg.
    Bukkit does not cooperate with me cause it demands string and here I get problems.

    I am stuck with something like this:
    p.sendRawMessage("%-5s %-15s %-10s %-10s",Integer.toString(n),dbp.get(t),dbd.get(t),dbk.get(t));
    Also how can I make it formatted with colours.


    I am not sure if anyone will help me here:

    So far I made it running but not well with this function:
        private String getAlignedString(String string, int i, int j) {
            int l = string.length();
            for(int t = 0 ; t<j ; t++){
                string = " "+string;
            l = string.length();
            for(int t = l ; t<i ; t++){
                string = string+" ";
            return string;
  2. Offline


    player.sendMessage(ChatColor.RED + "MESSAGE HERE");

    That sends a red message to player.
Thread Status:
Not open for further replies.

Share This Page