Disabling Commands

Discussion in 'Plugin Development' started by DanLT, Aug 17, 2015.

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

    DanLT

    Hello,

    How to disable commands, when I type /start and enable them when I type /finish ?
     
  2. PlayerCommandPreProcessEvent and a boolean to check if is started or finished
     
  3. Offline

    DanLT

    Maybe you can give me an example, because I am new in this and it is hard for me.
     
  4. Offline

    Konato_K

    @DanLT Show us what you have tried and we'll help you from there.
     
  5. Offline

    teej107

    @DanLT Is this in your own plugin? If so then the PlayerCommandPreprocessEvent is not the way to go.
     
    Konato_K likes this.
  6. Offline

    DanLT

  7. @DanLT
    1. Use Bukkit's logger not Java's
    2. You don't need enable and disable messages
    3. Have you registered them in the plugin.yml?
     
  8. Offline

    teej107

    @DanLT Use a boolean to represent the state of the commands whether they are enabled or disabled. When a command is run, check the boolean and decide whether it should still run or not.
     
  9. Offline

    DanLT

    I have registered plugin.yml and with commands(/start and /finish everything is fine.I just don't know how to disable commands by using events.
    And teej107 can show me an example with code, because I can't understand completely.
     
  10. Offline

    Konato_K

    @DanLT If you can't understand what a boolean is you should learn java first then, if you really want help then do what you can and we'll see if we can help you, we won't write code for you, at least bother yourself to search up things out there.
     
  11. What @teej107 is talking about is to add a boolean variable like boolStart or boolFinish which will be used to decide whether or not your command is enabled.

    Your original post is a little difficult for me to understand (English?), but I made an addition to your posted code here. Use boolean variables to check whether or not the command is enabled/disabled.
     
  12. Offline

    Tecno_Wizard

    To do what he wants to do, I think this is the only way to do it. He wants to block ALL commands, not just his own.
     
  13. Offline

    DanLT

    @Tecno_Wizard Yes you are right.I want to disable all commands.
    I will try to explain what I want to do.When player types /start all commands(from Essentials and from other plugins) will be disabled except from /finish .And when player types /finish all commands will be enabled.
     
    Last edited: Aug 18, 2015
  14. Offline

    CraftCreeper6

    @DanLT
    Boolean, check if commands are disabled using that boolean, CommandPreProcessEvent, cancel the event if the boolean is true.

    EDIT: Add some exceptions if necessary.
     
Thread Status:
Not open for further replies.

Share This Page