I was coding a UHC plugin. UHC has stuff called 'Scenarios'. An example of a scenario is NoFall. NoFall basically makes it so you cannot take damage from fall... I can setup this class and it's code correctly, but how can I enable the code inside it to be active/unactivate it within a command?
I don't think OP is asking for this, he's asking on how to enable/disable the code within a class on command...
just dont register that class as an event listener even if it implements it, if you dont register it nothing should happen
PHP: if($this->disabled){return;} basically if the property disabled is true, return(i hope you KNOW what return meant) even tho i recommend just dont even register events in the first place
I don't think anyone ever mentioned Event Listeners. He is implying that you can use a simple attribute in your class(Although it's technically an object) set to a boolean value that indicates whether the code in that class should be executed or not. It would really help if you explained how your CutClean class works. Does it implement pocketmine\event\Listener, and handle events itself? Or does the plugin's main Listener(I assume it has one) execute methods in the CutClean class on an event?
It's a class by itself which implements PluginBase. It just setDrops of ores to ingots. I need an example code to study...