Rename Plugin->setEnabled() with a more clear name

This is intended to break API in order to jerk the rug out from underneath plugin developers who have been misusing this without noticing the side effects.
This commit is contained in:
Dylan K. Taylor 2018-10-08 13:06:51 +01:00
parent 24677e1d79
commit a653289c40
3 changed files with 4 additions and 4 deletions

View File

@ -51,7 +51,7 @@ interface Plugin extends CommandExecutor{
*
* @param bool $enabled
*/
public function setEnabled(bool $enabled = true) : void;
public function onEnableStateChange(bool $enabled) : void;
/**
* @return bool

View File

@ -110,7 +110,7 @@ abstract class PluginBase implements Plugin{
*
* @param bool $enabled
*/
final public function setEnabled(bool $enabled = true) : void{
final public function onEnableStateChange(bool $enabled) : void{
if($this->isEnabled !== $enabled){
$this->isEnabled = $enabled;
if($this->isEnabled){

View File

@ -412,7 +412,7 @@ class PluginManager{
$permManager->addPermission($perm);
}
$plugin->getScheduler()->setEnabled(true);
$plugin->setEnabled(true);
$plugin->onEnableStateChange(true);
$this->enabledPlugins[$plugin->getDescription()->getName()] = $plugin;
@ -498,7 +498,7 @@ class PluginManager{
unset($this->enabledPlugins[$plugin->getDescription()->getName()]);
try{
$plugin->setEnabled(false);
$plugin->onEnableStateChange(false);
}catch(\Throwable $e){
$this->server->getLogger()->logException($e);
}