Disallow plugins disabling other plugins (#5872)

This commit is contained in:
Javier León 2023-07-13 09:44:28 -03:00 committed by GitHub
parent 0d8a06732a
commit 1ffa945fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -486,6 +486,7 @@ class PluginManager{
return true; //TODO: maybe this should be an error?
}
/** @internal */
public function disablePlugins() : void{
while(count($this->enabledPlugins) > 0){
foreach($this->enabledPlugins as $plugin){
@ -503,7 +504,7 @@ class PluginManager{
}
}
public function disablePlugin(Plugin $plugin) : void{
private function disablePlugin(Plugin $plugin) : void{
if($plugin->isEnabled()){
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_disable($plugin->getDescription()->getFullName())));
(new PluginDisableEvent($plugin))->call();
@ -532,13 +533,6 @@ class PluginManager{
}
}
public function clearPlugins() : void{
$this->disablePlugins();
$this->plugins = [];
$this->enabledPlugins = [];
$this->fileAssociations = [];
}
/**
* Returns whether the given ReflectionMethod could be used as an event handler. Used to filter methods on Listeners
* when registering.