Plugin Help How to fix PlayerCommandPreprocessEvent not splitting correctly

Discussion in 'Plugin Help/Development/Requests' started by Cycryl, Sep 30, 2015.

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

    Cycryl

    Hey Bukkit forums!
    I recently needed to read argumens from a list from the PlayerCommandPreprocessEvent.
    To do this i tried to use event.getMessage().split(" ");
    I realized that it was not working.
    After playing around with it for a bit I found out that the spaces in are actually so called "Non-breaking spaces".
    So the split character had to be one of these "Non-breaking spaces."
    If I do .split(" ") with one of these in the parenthesies it works.

    To get this character do this:

    Windows:
    Hold Alt
    Enter 0160 into the number pad
    Release alt

    Mac:
    alt+space
     
  2. Online

    timtower Administrator Administrator Moderator

    @Cycryl Spacebar should work just fine, it does with my plugins (as far as I still use that event)
     
  3. Offline

    Cycryl

    Im using craftbukkit 1.8 snapshot maybe thats the reason. If there are more versions it occurrs in people can come backto this thread
     
  4. Offline

    I Al Istannen

    @Cycryl I am using that too, and everything works fine with just a normal space. As String.split() accepts a RegEx, you could try splitting at "\s" instead of " ". That should match any whitespace character.
     
  5. Offline

    Cycryl

    Wow thanks i didnt even know that was possible thanks man
     
Thread Status:
Not open for further replies.

Share This Page