Discussion in 'Plugin Development' started by DanLT, Aug 17, 2015.
How to disable commands, when I type /start and enable them when I type /finish ?
PlayerCommandPreProcessEvent and a boolean to check if is started or finished
Maybe you can give me an example, because I am new in this and it is hard for me.
@DanLT Show us what you have tried and we'll help you from there.
@DanLT Is this in your own plugin? If so then the PlayerCommandPreprocessEvent is not the way to go.
Yes it is in my plugin, I am trying to develop it.Here is my plugin files.I have stoped, when I have created both commands.
This is my first plugin, so please help me if you can !
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?
@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.
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.
@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.
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.
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.
@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.
Boolean, check if commands are disabled using that boolean, CommandPreProcessEvent, cancel the event if the boolean is true.
EDIT: Add some exceptions if necessary.
Separate names with a comma.