mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-19 04:15:04 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
@@ -36,10 +36,7 @@ final class ApiVersion{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $myVersionStr
|
||||
* @param string[] $wantVersionsStr
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCompatible(string $myVersionStr, array $wantVersionsStr) : bool{
|
||||
$myVersion = new VersionString($myVersionStr);
|
||||
|
@@ -49,8 +49,6 @@ class DiskResourceProvider implements ResourceProvider{
|
||||
* Gets an embedded resource on the plugin file.
|
||||
* WARNING: You must close the resource given using fclose()
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename){
|
||||
|
@@ -46,8 +46,6 @@ class PharPluginLoader implements PluginLoader{
|
||||
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void{
|
||||
$this->loader->addPath("$file/src");
|
||||
@@ -55,10 +53,6 @@ class PharPluginLoader implements PluginLoader{
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @return null|PluginDescription
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
||||
$phar = new \Phar($file);
|
||||
|
@@ -36,9 +36,6 @@ interface Plugin{
|
||||
|
||||
public function __construct(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file, ResourceProvider $resourceProvider);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled() : bool;
|
||||
|
||||
/**
|
||||
@@ -47,52 +44,27 @@ interface Plugin{
|
||||
* @internal This is intended for core use only and should not be used by plugins
|
||||
* @see PluginManager::enablePlugin()
|
||||
* @see PluginManager::disablePlugin()
|
||||
*
|
||||
* @param bool $enabled
|
||||
*/
|
||||
public function onEnableStateChange(bool $enabled) : void;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
public function getServer() : Server;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string;
|
||||
|
||||
/**
|
||||
* @return \AttachableLogger
|
||||
*/
|
||||
public function getLogger() : \AttachableLogger;
|
||||
|
||||
/**
|
||||
* @return PluginLoader
|
||||
*/
|
||||
public function getPluginLoader() : PluginLoader;
|
||||
|
||||
/**
|
||||
* @return TaskScheduler
|
||||
*/
|
||||
public function getScheduler() : TaskScheduler;
|
||||
|
||||
}
|
||||
|
@@ -126,9 +126,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
final public function isEnabled() : bool{
|
||||
return $this->isEnabled;
|
||||
}
|
||||
@@ -139,8 +136,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
* @internal This is intended for core use only and should not be used by plugins
|
||||
* @see PluginManager::enablePlugin()
|
||||
* @see PluginManager::disablePlugin()
|
||||
*
|
||||
* @param bool $enabled
|
||||
*/
|
||||
final public function onEnableStateChange(bool $enabled) : void{
|
||||
if($this->isEnabled !== $enabled){
|
||||
@@ -153,9 +148,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
final public function isDisabled() : bool{
|
||||
return !$this->isEnabled;
|
||||
}
|
||||
@@ -168,9 +160,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \AttachableLogger
|
||||
*/
|
||||
public function getLogger() : \AttachableLogger{
|
||||
return $this->logger;
|
||||
}
|
||||
@@ -233,8 +222,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return Command|PluginIdentifiableCommand|null
|
||||
*/
|
||||
public function getCommand(string $name){
|
||||
@@ -251,12 +238,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
* @param Command $command
|
||||
* @param string $label
|
||||
* @param string[] $args
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
|
||||
return false;
|
||||
@@ -266,8 +248,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
* Gets an embedded resource on the plugin file.
|
||||
* WARNING: You must close the resource given using fclose()
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename){
|
||||
@@ -276,11 +256,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
|
||||
/**
|
||||
* 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{
|
||||
if(trim($filename) === ""){
|
||||
@@ -315,9 +290,6 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
return $this->resourceProvider->getResources();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig() : Config{
|
||||
if($this->config === null){
|
||||
$this->reloadConfig();
|
||||
@@ -342,44 +314,26 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
||||
$this->config = new Config($this->configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Server
|
||||
*/
|
||||
final public function getServer() : Server{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
final public function getName() : string{
|
||||
return $this->description->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
final public function getFullName() : string{
|
||||
return $this->description->getFullName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getFile() : string{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PluginLoader
|
||||
*/
|
||||
public function getPluginLoader() : PluginLoader{
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TaskScheduler
|
||||
*/
|
||||
public function getScheduler() : TaskScheduler{
|
||||
return $this->scheduler;
|
||||
}
|
||||
|
@@ -86,8 +86,6 @@ class PluginDescription{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $plugin
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
private function loadMap(array $plugin) : void{
|
||||
@@ -161,16 +159,10 @@ class PluginDescription{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFullName() : string{
|
||||
return $this->name . " v" . $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCompatibleApis() : array{
|
||||
return $this->api;
|
||||
}
|
||||
@@ -189,16 +181,10 @@ class PluginDescription{
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPrefix() : string{
|
||||
return $this->prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCommands() : array{
|
||||
return $this->commands;
|
||||
}
|
||||
@@ -244,44 +230,26 @@ class PluginDescription{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getDepend() : array{
|
||||
return $this->depend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription() : string{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getLoadBefore() : array{
|
||||
return $this->loadBefore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMain() : string{
|
||||
return $this->main;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName() : string{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PluginLoadOrder
|
||||
*/
|
||||
public function getOrder() : PluginLoadOrder{
|
||||
return $this->order;
|
||||
}
|
||||
@@ -293,23 +261,14 @@ class PluginDescription{
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSoftDepend() : array{
|
||||
return $this->softDepend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion() : string{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWebsite() : string{
|
||||
return $this->website;
|
||||
}
|
||||
|
@@ -48,19 +48,12 @@ class PluginGraylist{
|
||||
return array_flip($this->plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWhitelist() : bool{
|
||||
return $this->isWhitelist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given name is permitted by this graylist.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAllowed(string $name) : bool{
|
||||
return $this->isWhitelist() === isset($this->plugins[$name]);
|
||||
|
@@ -30,33 +30,21 @@ interface PluginLoader{
|
||||
|
||||
/**
|
||||
* Returns whether this PluginLoader can load the plugin in the given path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canLoadPlugin(string $path) : bool;
|
||||
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void;
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @return null|PluginDescription
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription;
|
||||
|
||||
/**
|
||||
* Returns the protocol prefix used to access files in this plugin, e.g. file://, phar://
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAccessProtocol() : string;
|
||||
}
|
||||
|
@@ -87,11 +87,6 @@ class PluginManager{
|
||||
/** @var PluginGraylist|null */
|
||||
private $graylist;
|
||||
|
||||
/**
|
||||
* @param Server $server
|
||||
* @param null|string $pluginDataDirectory
|
||||
* @param PluginGraylist|null $graylist
|
||||
*/
|
||||
public function __construct(Server $server, ?string $pluginDataDirectory, ?PluginGraylist $graylist = null){
|
||||
$this->server = $server;
|
||||
$this->pluginDataDirectory = $pluginDataDirectory;
|
||||
@@ -106,11 +101,6 @@ class PluginManager{
|
||||
$this->graylist = $graylist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return null|Plugin
|
||||
*/
|
||||
public function getPlugin(string $name) : ?Plugin{
|
||||
if(isset($this->plugins[$name])){
|
||||
return $this->plugins[$name];
|
||||
@@ -119,9 +109,6 @@ class PluginManager{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PluginLoader $loader
|
||||
*/
|
||||
public function registerInterface(PluginLoader $loader) : void{
|
||||
$this->fileAssociations[get_class($loader)] = $loader;
|
||||
}
|
||||
@@ -141,10 +128,7 @@ class PluginManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param PluginLoader[] $loaders
|
||||
*
|
||||
* @return Plugin|null
|
||||
*/
|
||||
public function loadPlugin(string $path, ?array $loaders = null) : ?Plugin{
|
||||
foreach($loaders ?? $this->fileAssociations as $loader){
|
||||
@@ -197,7 +181,6 @@ class PluginManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $directory
|
||||
* @param array $newLoaders
|
||||
*
|
||||
* @return Plugin[]
|
||||
@@ -372,8 +355,6 @@ class PluginManager{
|
||||
* Returns whether a specified API version string is considered compatible with the server's API version.
|
||||
*
|
||||
* @param string ...$versions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isCompatibleApi(string ...$versions) : bool{
|
||||
$serverString = $this->server->getApiVersion();
|
||||
@@ -411,18 +392,10 @@ class PluginManager{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPluginEnabled(Plugin $plugin) : bool{
|
||||
return isset($this->plugins[$plugin->getDescription()->getName()]) and $plugin->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
*/
|
||||
public function enablePlugin(Plugin $plugin) : void{
|
||||
if(!$plugin->isEnabled()){
|
||||
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.enable", [$plugin->getDescription()->getFullName()]));
|
||||
@@ -446,9 +419,6 @@ class PluginManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
*/
|
||||
public function disablePlugin(Plugin $plugin) : void{
|
||||
if($plugin->isEnabled()){
|
||||
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
|
||||
@@ -482,9 +452,6 @@ class PluginManager{
|
||||
/**
|
||||
* Registers all the events in the given Listener class
|
||||
*
|
||||
* @param Listener $listener
|
||||
* @param Plugin $plugin
|
||||
*
|
||||
* @throws PluginException
|
||||
*/
|
||||
public function registerEvents(Listener $listener, Plugin $plugin) : void{
|
||||
@@ -548,10 +515,6 @@ class PluginManager{
|
||||
|
||||
/**
|
||||
* @param string $event Class name that extends Event
|
||||
* @param \Closure $handler
|
||||
* @param int $priority
|
||||
* @param Plugin $plugin
|
||||
* @param bool $handleCancelled
|
||||
*
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
|
@@ -28,8 +28,6 @@ interface ResourceProvider{
|
||||
* Gets an embedded resource on the plugin file.
|
||||
* WARNING: You must close the resource given using fclose()
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename);
|
||||
|
@@ -46,8 +46,6 @@ class ScriptPluginLoader implements PluginLoader{
|
||||
|
||||
/**
|
||||
* Loads the plugin contained in $file
|
||||
*
|
||||
* @param string $file
|
||||
*/
|
||||
public function loadPlugin(string $file) : void{
|
||||
include_once $file;
|
||||
@@ -55,10 +53,6 @@ class ScriptPluginLoader implements PluginLoader{
|
||||
|
||||
/**
|
||||
* Gets the PluginDescription from the file
|
||||
*
|
||||
* @param string $file
|
||||
*
|
||||
* @return null|PluginDescription
|
||||
*/
|
||||
public function getPluginDescription(string $file) : ?PluginDescription{
|
||||
$content = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
Reference in New Issue
Block a user