How to stop certain commands?

Discussion in 'Plugin Development' started by James | Buchanan, Apr 21, 2012.

Thread Status:
Not open for further replies.
  1. So, i want to cancel the /helpop command from essentials, and i want to have 3 new commands for it, !<message>, /. <message> and /helpop <message>. and yes, there will be no '/' for the '!' one.
    Hope this was clear enough :)
  2. Offline


    2. @EventHandler(priority = EventPriority.NORMAL)
    3. private void blockCommandsWhenTalk(PlayerCommandPreprocessEvent event) {
    4. Player player = event.getPlayer();
    5. if(event.getMessage().startsWith("/")){
    6. player.sendMessage("Can't do commands!");
    7. event.setCancelled(true);
    8. }
    9. }

    Change the startsWith to your command. or the action you want to be followed. Very basic example.
  3. Offline


    Im getting an error telling me that void cant be a type for blockCommandsWhenTalk?? HELP

    Ok actually this doesnt work at all!

    Ok it does work! But how do I prevent them from having any numbers in a /sponsor <playername> <Item ID> <amount> I want the amount to only be allowed 1

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page