Solved Trimming Troubles

Discussion in 'Plugin Development' started by BungeeTheCookie, Aug 4, 2014.

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

    BungeeTheCookie

    Hello people of Bukkit!
    Whenever I use the .trim() method, it trims the space at the end of the string, but it also trims the first character as well. For example, when I use /g Hello I am God, and it is supposed to broadcast Hello I am God, it just says I am God.

    Code:
    StringBuilder sb = new StringBuilder();
                    for(int i = 1; i < args.length; i++) {
                        sb.append(args[i]).append(" ");
                    }
                    String message = sb.toString().trim();
    How do I fix this?
     
  2. Offline

    Flamedek

    BungeeTheCookie You should start with int i = 0.
    Right now the first element never gets picked
     
  3. Offline

    teej107

  4. Offline

    BungeeTheCookie

    Flamedek teej107
    Lol, I messed up. I copied and pasted from my Command class also in my plugin where the index has to start with one, and I forgot to change it back to zero :p. Thanks guys.
     
Thread Status:
Not open for further replies.

Share This Page