mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
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:
parent
24677e1d79
commit
a653289c40
@ -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
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user