Solved How do I do this

Discussion in 'Spigot Plugin Development' started by iMedia, Aug 9, 2018.

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

    Supporter

    Sorry for being such a noob c:

    How do I do this:

    [​IMG]

    (i have the motd set in the config)
     
  2. What is "it"?
    Since you're asking in "plugin development" i guess "it" is some java object? What object?

    What MOTD? The server list motd set in server.properties?
     
  3. iMedia

    Supporter

    Yes the MOTD set in the server.propertise that kind of MOTD
     
  4. iMedia

    Supporter

    I want to center the MOTD
     
  5. So I assume you want you count the amout of letters in your MOTD String?
     
  6. Also what is totallenght?
     
  7. Something like that?
    lineLength must be the amount of characters in one MOTD line in your case (which amount i currently don't know).
    Code (Java):
    public String centerLine(String text, int lineLength) {
        int spaces = (lineLength - text.length()) / 2;
        String result = text;
        if (spaces > 0) {
            for (int i = 0; i < spaces; i++) {
                result = " " + result + " ";
            }
            return result;
        } else {
            return result.substring(0, lineLength);
        }
    }
     
    #7 Michel_0, Aug 9, 2018
    Last edited: Aug 9, 2018
Thread Status:
Not open for further replies.