mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Remove a whole bunch of crap from the Plugin
public interface (#2268)
- remove onLoad(), onEnable(), onDisable() - remove Config related methods - remove getResource(), saveResource(), getResources() did I troll any readers so far? On a more serious note, these methods do not need to be declared in this interface because they are either hooks (`onLoad()`, `onEnable()`, `onDisable()`) or methods only used from within `PluginBase` and its children. They are not intended to be public API, and for this reason they don't need to be exposed in the interface.
This commit is contained in:
parent
3846ee3d1d
commit
49bca0d5a1
@ -29,8 +29,6 @@ namespace pocketmine\plugin;
|
||||
use pocketmine\command\CommandExecutor;
|
||||
use pocketmine\scheduler\TaskScheduler;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Config;
|
||||
|
||||
|
||||
/**
|
||||
* It is recommended to use PluginBase for the actual plugin
|
||||
@ -39,16 +37,6 @@ interface Plugin extends CommandExecutor{
|
||||
|
||||
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file);
|
||||
|
||||
/**
|
||||
* Called when the plugin is loaded, before calling onEnable()
|
||||
*/
|
||||
public function onLoad();
|
||||
|
||||
/**
|
||||
* Called when the plugin is enabled
|
||||
*/
|
||||
public function onEnable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -59,12 +47,6 @@ interface Plugin extends CommandExecutor{
|
||||
*/
|
||||
public function setEnabled(bool $enabled = true) : void;
|
||||
|
||||
/**
|
||||
* Called when the plugin is disabled
|
||||
* Use this to free open things and finish actions
|
||||
*/
|
||||
public function onDisable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
@ -83,46 +65,6 @@ interface Plugin extends CommandExecutor{
|
||||
*/
|
||||
public function getDescription() : PluginDescription;
|
||||
|
||||
/**
|
||||
* Gets an embedded resource in the plugin file.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename);
|
||||
|
||||
/**
|
||||
* Saves an embedded resource to its relative location in the data folder
|
||||
*
|
||||
* @param string $filename
|
||||
* @param bool $replace
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function saveResource(string $filename, bool $replace = false) : bool;
|
||||
|
||||
/**
|
||||
* Returns all the resources packaged with the plugin
|
||||
*
|
||||
* @return \SplFileInfo[]
|
||||
*/
|
||||
public function getResources() : array;
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig() : Config;
|
||||
|
||||
public function saveConfig();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function saveDefaultConfig() : bool;
|
||||
|
||||
public function reloadConfig();
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
|
@ -68,20 +68,29 @@ abstract class PluginBase implements Plugin{
|
||||
$this->configFile = $this->dataFolder . "config.yml";
|
||||
$this->logger = new PluginLogger($this);
|
||||
$this->scheduler = new TaskScheduler($this->logger, $this->getFullName());
|
||||
|
||||
$this->onLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the plugin is loaded, before calling onEnable()
|
||||
*/
|
||||
public function onLoad(){
|
||||
protected function onLoad()/* : void /* TODO: uncomment this for next major version */{
|
||||
|
||||
}
|
||||
|
||||
public function onEnable(){
|
||||
/**
|
||||
* Called when the plugin is enabled
|
||||
*/
|
||||
protected function onEnable()/* : void /* TODO: uncomment this for next major version */{
|
||||
|
||||
}
|
||||
|
||||
public function onDisable(){
|
||||
/**
|
||||
* Called when the plugin is disabled
|
||||
* Use this to free open things and finish actions
|
||||
*/
|
||||
protected function onDisable()/* : void /* TODO: uncomment this for next major version */{
|
||||
|
||||
}
|
||||
|
||||
@ -183,6 +192,8 @@ abstract class PluginBase implements Plugin{
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an embedded resource to its relative location in the data folder
|
||||
*
|
||||
* @param string $filename
|
||||
* @param bool $replace
|
||||
*
|
||||
|
@ -201,7 +201,6 @@ class PluginManager{
|
||||
* @see Plugin::__construct()
|
||||
*/
|
||||
$plugin = new $mainClass($loader, $this->server, $description, $dataFolder, $prefixed);
|
||||
$plugin->onLoad();
|
||||
$this->plugins[$plugin->getDescription()->getName()] = $plugin;
|
||||
|
||||
$pluginCommands = $this->parseYamlCommands($plugin);
|
||||
|
Loading…
x
Reference in New Issue
Block a user