From 10fa74b4176c9134a04e9ff7635fa61763ad10f9 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 7 Oct 2018 17:48:11 +0100 Subject: [PATCH] Make clear that Plugin->setEnabled() is @internal Use of this by plugins will produce a lot of undefined behaviour, such as event handlers not being unregistered, scheduled tasks not being removed, and registered permissions causing memory leaks. --- src/pocketmine/plugin/Plugin.php | 6 ++++++ src/pocketmine/plugin/PluginBase.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/pocketmine/plugin/Plugin.php b/src/pocketmine/plugin/Plugin.php index 77d5dd964..a3b582ead 100644 --- a/src/pocketmine/plugin/Plugin.php +++ b/src/pocketmine/plugin/Plugin.php @@ -55,6 +55,12 @@ interface Plugin extends CommandExecutor{ public function isEnabled() : bool; /** + * Called by the plugin manager when the plugin is enabled or disabled to inform the plugin of its enabled state. + * + * @internal This is intended for core use only and should not be used by plugins + * @see PluginManager::enablePlugin() + * @see PluginManager::disablePlugin() + * * @param bool $enabled */ public function setEnabled(bool $enabled = true) : void; diff --git a/src/pocketmine/plugin/PluginBase.php b/src/pocketmine/plugin/PluginBase.php index bba7231e9..63fe5c60f 100644 --- a/src/pocketmine/plugin/PluginBase.php +++ b/src/pocketmine/plugin/PluginBase.php @@ -93,6 +93,12 @@ abstract class PluginBase implements Plugin{ } /** + * Called by the plugin manager when the plugin is enabled or disabled to inform the plugin of its enabled state. + * + * @internal This is intended for core use only and should not be used by plugins + * @see PluginManager::enablePlugin() + * @see PluginManager::disablePlugin() + * * @param bool $enabled */ final public function setEnabled(bool $enabled = true) : void{