Solved PlayerCommandPreprocessEvent question

Discussion in 'Plugin Development' started by Goblom, Jan 13, 2014.

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

    Goblom

    Code:java
    1. public void onCommand(PlayerCommandPreprocessEvent event) {
    2. event.getMessage();
    3. }


    When using event.getMessage() does it return the "/" or not?

    Example: I do /kill. Does event.getMessage() return "/kill" or "kill"
     
  2. Offline

    ThunderWaffeMC

    It would return "kill" not "/kill".

    Edit: You could have done a simple test like so before posting on the forums:

    Code:java
    1.  
    2. @EventHandler
    3. public void onCommand(PlayerCommandPreprocessEvent event) {
    4. Player player = event.getPlayer();
    5. String message = event.getMessage();
    6. player.sendMessage("The command that was typed is: " + message);
    7. }
    8.  
     
  3. Offline

    Jake6177

    Nope, my plugin is based on this event. It returns the /.
     
    ThunderWaffeMC likes this.
  4. Offline

    ThunderWaffeMC

    Oh. That's strange.
     
  5. Offline

    Jake6177

    Yeah it is a bit. I was surprised when I first saw it.
     
  6. Offline

    Goblom

    ThunderWaffeMC I know i could have tested it but im too lazy to test something so trivial. Although i might test it now because its @ 50/50 regarding the "/"
     
  7. Offline

    ThunderWaffeMC

    Well, to get rid of it you would use a substring.

    Code:java
    1.  
    2. String message = event.getMessage().subString(1);
    3.  
     
Thread Status:
Not open for further replies.

Share This Page