Deny using commands

Discussion in 'Plugin Development' started by greaperc4, Oct 9, 2013.

Thread Status:
Not open for further replies.
  1. Hello,

    I am trying something out, I want to disable any command EXCEPT the ones from the plugin itself.
    But I don't really know how to disable the commands,

    I know it has something to do with the PlayerCommandPreprocessEvent.. well that's what I think

    Could anyone help, that would be nice.

    Thanks, Greaperc4
     
  2. Offline

    MrSparkzz

    greaperc4
    Here's what to do
    Code:java
    1.  
    2. @EventHandler(priority = EventPriority.LOWEST)
    3. public void onCommandPreProcess(PlayerCommandPreprocessEvent event){
    4. if(event.getMessage().toLowerCase().startsWith("/command")){ // check for input
    5. event.setCancelled(true); // cancels the command event
    6. }
    7. }
    8.  
     
    Mathias Eklund likes this.

  3. How does it make it saver, and do you have proof ?
     
    MrSparkzz likes this.
  4. Offline

    MrSparkzz

    Actually, now that I think about it, this wouldn't work. The reason I used a PlayerCommandPrepreocessEvent is because it will execute before the commands. Which, in this case, is what he wants. Yes you could do the AsyncPlayerChatEvent, but from my understanding I'm almost certain that it would still run the command, maybe even skipping the AsyncPlayerChatEvent event. I'm not sure, because I haven't tested it, but I'm almost certain that the AsyncPlayerChatEvent wont work, or wont work as well as the PlayerCommandPrepreocessEvent.
     
  5. Offline

    sgavster

    T3h Cr33p3r Doesn't work. AsyncPlayerChatEvent is a chat, commands is not chat, it's a command! haha test it :p
     
  6. Offline

    MrSparkzz

  7. Offline

    DAZ3DNDC0NFUS3D

    Join the millions of other people that don't like to be argued with? Its part of life, and if you can't have an argument or heated debate with someone without jumping off the edge and going crazy, maybe its best to ignore them?
     
  8. Offline

    MrSparkzz

    I wasn't arguing. I was just saying that I'm pretty sure that's not what it's used for. PlayerCommandPreprocessEvent will run code before the command is actually processed.
     
  9. Offline

    JPG2000

    T3h Cr33p3r Don't argue with me?

    Lets see. I hate the word yolo, yet people use it all the time. So, Im issuaing a world wide yolo ban.

    Does the yolo (god damit) thing sound right?
     
  10. Offline

    Mathias Eklund

    imo, that works perfectly fine.
     
Thread Status:
Not open for further replies.

Share This Page