Dylan K. Taylor 5a55d434ab Nuke plugin loaders from orbit
This features a near-total rewrite of PluginLoaders and some code associated with them.

Highlights:
- PluginManager->registerInterface() does not return anything, and now accepts a PluginLoader instance instead of a string.
- PluginLoader itself is drastically simplified. getPluginFilters(), enablePlugin() and disablePlugin() are now removed. loadPlugin() responsibilities are now solely confined to doing whatever is necessary to make the plugin's classes visible by the server, and does not emit log messages or check for data directories.
- PluginBase->init() and PluginBase->isInitialized() have been removed.
- Plugin interface now declares a signature for the constructor which implementations must comply with.
- Plugin interface now declares setEnabled().
2018-06-12 10:23:49 +01:00

152 lines
3.1 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
/**
* Plugin related classes
*/
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
*/
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
*/
public function isEnabled() : bool;
/**
* @param bool $enabled
*/
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
*/
public function isDisabled() : bool;
/**
* Gets the plugin's data folder to save files and configuration.
* This directory name has a trailing slash.
*
* @return string
*/
public function getDataFolder() : string;
/**
* @return PluginDescription
*/
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
*/
public function getServer() : Server;
/**
* @return string
*/
public function getName() : string;
/**
* @return PluginLogger
*/
public function getLogger() : PluginLogger;
/**
* @return PluginLoader
*/
public function getPluginLoader();
/**
* @return TaskScheduler
*/
public function getScheduler() : TaskScheduler;
}