mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Replace disallowed operators in src/plugin/
This commit is contained in:
parent
3f8f5cd200
commit
03f47d0a78
@ -53,7 +53,7 @@ final class ApiVersion{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($version->getMinor() === $myVersion->getMinor() and $version->getPatch() > $myVersion->getPatch()){ //If the plugin requires bug fixes in patches, being backwards compatible
|
if($version->getMinor() === $myVersion->getMinor() && $version->getPatch() > $myVersion->getPatch()){ //If the plugin requires bug fixes in patches, being backwards compatible
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class PharPluginLoader implements PluginLoader{
|
|||||||
|
|
||||||
public function canLoadPlugin(string $path) : bool{
|
public function canLoadPlugin(string $path) : bool{
|
||||||
$ext = ".phar";
|
$ext = ".phar";
|
||||||
return is_file($path) and substr($path, -strlen($ext)) === $ext;
|
return is_file($path) && substr($path, -strlen($ext)) === $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,11 +209,11 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
|||||||
*/
|
*/
|
||||||
public function getCommand(string $name){
|
public function getCommand(string $name){
|
||||||
$command = $this->getServer()->getPluginCommand($name);
|
$command = $this->getServer()->getPluginCommand($name);
|
||||||
if($command === null or $command->getOwningPlugin() !== $this){
|
if($command === null || $command->getOwningPlugin() !== $this){
|
||||||
$command = $this->getServer()->getPluginCommand(strtolower($this->description->getName()) . ":" . $name);
|
$command = $this->getServer()->getPluginCommand(strtolower($this->description->getName()) . ":" . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($command instanceof PluginOwned and $command->getOwningPlugin() === $this){
|
if($command instanceof PluginOwned && $command->getOwningPlugin() === $this){
|
||||||
return $command;
|
return $command;
|
||||||
}else{
|
}else{
|
||||||
return null;
|
return null;
|
||||||
@ -254,7 +254,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
|
|||||||
mkdir(dirname($out), 0755, true);
|
mkdir(dirname($out), 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists($out) and !$replace){
|
if(file_exists($out) && !$replace){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class PluginDescription{
|
|||||||
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
$this->compatibleMcpeProtocols = array_map("\intval", (array) ($plugin["mcpe-protocol"] ?? []));
|
||||||
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? []));
|
$this->compatibleOperatingSystems = array_map("\strval", (array) ($plugin["os"] ?? []));
|
||||||
|
|
||||||
if(isset($plugin["commands"]) and is_array($plugin["commands"])){
|
if(isset($plugin["commands"]) && is_array($plugin["commands"])){
|
||||||
foreach($plugin["commands"] as $commandName => $commandData){
|
foreach($plugin["commands"] as $commandName => $commandData){
|
||||||
if(!is_string($commandName)){
|
if(!is_string($commandName)){
|
||||||
throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command");
|
throw new PluginDescriptionParseException("Invalid Plugin commands, key must be the name of the command");
|
||||||
|
@ -47,7 +47,7 @@ final class PluginLoadabilityChecker{
|
|||||||
|
|
||||||
public function check(PluginDescription $description) : Translatable|null{
|
public function check(PluginDescription $description) : Translatable|null{
|
||||||
$name = $description->getName();
|
$name = $description->getName();
|
||||||
if(stripos($name, "pocketmine") !== false or stripos($name, "minecraft") !== false or stripos($name, "mojang") !== false){
|
if(stripos($name, "pocketmine") !== false || stripos($name, "minecraft") !== false || stripos($name, "mojang") !== false){
|
||||||
return KnownTranslationFactory::pocketmine_plugin_restrictedName();
|
return KnownTranslationFactory::pocketmine_plugin_restrictedName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ final class PluginLoadabilityChecker{
|
|||||||
return KnownTranslationFactory::pocketmine_plugin_ambiguousMinAPI(implode(", ", $ambiguousVersions));
|
return KnownTranslationFactory::pocketmine_plugin_ambiguousMinAPI(implode(", ", $ambiguousVersions));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($description->getCompatibleOperatingSystems()) > 0 and !in_array(Utils::getOS(), $description->getCompatibleOperatingSystems(), true)) {
|
if(count($description->getCompatibleOperatingSystems()) > 0 && !in_array(Utils::getOS(), $description->getCompatibleOperatingSystems(), true)) {
|
||||||
return KnownTranslationFactory::pocketmine_plugin_incompatibleOS(implode(", ", $description->getCompatibleOperatingSystems()));
|
return KnownTranslationFactory::pocketmine_plugin_incompatibleOS(implode(", ", $description->getCompatibleOperatingSystems()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ class PluginManager{
|
|||||||
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_load($description->getFullName())));
|
$this->server->getLogger()->info($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_load($description->getFullName())));
|
||||||
|
|
||||||
$dataFolder = $this->getDataDirectory($path, $description->getName());
|
$dataFolder = $this->getDataDirectory($path, $description->getName());
|
||||||
if(file_exists($dataFolder) and !is_dir($dataFolder)){
|
if(file_exists($dataFolder) && !is_dir($dataFolder)){
|
||||||
$this->server->getLogger()->error($language->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
|
$this->server->getLogger()->error($language->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
|
||||||
$description->getName(),
|
$description->getName(),
|
||||||
KnownTranslationFactory::pocketmine_plugin_badDataFolder($dataFolder)
|
KnownTranslationFactory::pocketmine_plugin_badDataFolder($dataFolder)
|
||||||
@ -274,7 +274,7 @@ class PluginManager{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($triage->plugins[$name]) or $this->getPlugin($name) instanceof Plugin){
|
if(isset($triage->plugins[$name]) || $this->getPlugin($name) instanceof Plugin){
|
||||||
$this->server->getLogger()->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_duplicateError($name)));
|
$this->server->getLogger()->error($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_duplicateError($name)));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ class PluginManager{
|
|||||||
$this->server->getLogger()->warning($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_spacesDiscouraged($name)));
|
$this->server->getLogger()->warning($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_spacesDiscouraged($name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->graylist !== null and !$this->graylist->isAllowed($name)){
|
if($this->graylist !== null && !$this->graylist->isAllowed($name)){
|
||||||
$this->server->getLogger()->notice($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
|
$this->server->getLogger()->notice($this->server->getLanguage()->translate(KnownTranslationFactory::pocketmine_plugin_loadError(
|
||||||
$name,
|
$name,
|
||||||
$this->graylist->isWhitelist() ? KnownTranslationFactory::pocketmine_plugin_disallowedByWhitelist() : KnownTranslationFactory::pocketmine_plugin_disallowedByBlacklist()
|
$this->graylist->isWhitelist() ? KnownTranslationFactory::pocketmine_plugin_disallowedByWhitelist() : KnownTranslationFactory::pocketmine_plugin_disallowedByBlacklist()
|
||||||
@ -314,7 +314,7 @@ class PluginManager{
|
|||||||
private function checkDepsForTriage(string $pluginName, string $dependencyType, array &$dependencyLists, array $loadedPlugins, PluginLoadTriage $triage) : void{
|
private function checkDepsForTriage(string $pluginName, string $dependencyType, array &$dependencyLists, array $loadedPlugins, PluginLoadTriage $triage) : void{
|
||||||
if(isset($dependencyLists[$pluginName])){
|
if(isset($dependencyLists[$pluginName])){
|
||||||
foreach($dependencyLists[$pluginName] as $key => $dependency){
|
foreach($dependencyLists[$pluginName] as $key => $dependency){
|
||||||
if(isset($loadedPlugins[$dependency]) or $this->getPlugin($dependency) instanceof Plugin){
|
if(isset($loadedPlugins[$dependency]) || $this->getPlugin($dependency) instanceof Plugin){
|
||||||
$this->server->getLogger()->debug("Successfully resolved $dependencyType dependency \"$dependency\" for plugin \"$pluginName\"");
|
$this->server->getLogger()->debug("Successfully resolved $dependencyType dependency \"$dependency\" for plugin \"$pluginName\"");
|
||||||
unset($dependencyLists[$pluginName][$key]);
|
unset($dependencyLists[$pluginName][$key]);
|
||||||
}elseif(array_key_exists($dependency, $triage->plugins)){
|
}elseif(array_key_exists($dependency, $triage->plugins)){
|
||||||
@ -348,7 +348,7 @@ class PluginManager{
|
|||||||
$this->checkDepsForTriage($name, "hard", $triage->dependencies, $loadedPlugins, $triage);
|
$this->checkDepsForTriage($name, "hard", $triage->dependencies, $loadedPlugins, $triage);
|
||||||
$this->checkDepsForTriage($name, "soft", $triage->softDependencies, $loadedPlugins, $triage);
|
$this->checkDepsForTriage($name, "soft", $triage->softDependencies, $loadedPlugins, $triage);
|
||||||
|
|
||||||
if(!isset($triage->dependencies[$name]) and !isset($triage->softDependencies[$name])){
|
if(!isset($triage->dependencies[$name]) && !isset($triage->softDependencies[$name])){
|
||||||
unset($triage->plugins[$name]);
|
unset($triage->plugins[$name]);
|
||||||
$loadedThisLoop++;
|
$loadedThisLoop++;
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ class PluginManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function isPluginEnabled(Plugin $plugin) : bool{
|
public function isPluginEnabled(Plugin $plugin) : bool{
|
||||||
return isset($this->plugins[$plugin->getDescription()->getName()]) and $plugin->isEnabled();
|
return isset($this->plugins[$plugin->getDescription()->getName()]) && $plugin->isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function enablePlugin(Plugin $plugin) : void{
|
public function enablePlugin(Plugin $plugin) : void{
|
||||||
@ -485,7 +485,7 @@ class PluginManager{
|
|||||||
* @phpstan-return class-string<Event>|null
|
* @phpstan-return class-string<Event>|null
|
||||||
*/
|
*/
|
||||||
private function getEventsHandledBy(\ReflectionMethod $method) : ?string{
|
private function getEventsHandledBy(\ReflectionMethod $method) : ?string{
|
||||||
if($method->isStatic() or !$method->getDeclaringClass()->implementsInterface(Listener::class)){
|
if($method->isStatic() || !$method->getDeclaringClass()->implementsInterface(Listener::class)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$tags = Utils::parseDocComment((string) $method->getDocComment());
|
$tags = Utils::parseDocComment((string) $method->getDocComment());
|
||||||
|
@ -42,7 +42,7 @@ class ScriptPluginLoader implements PluginLoader{
|
|||||||
|
|
||||||
public function canLoadPlugin(string $path) : bool{
|
public function canLoadPlugin(string $path) : bool{
|
||||||
$ext = ".php";
|
$ext = ".php";
|
||||||
return is_file($path) and substr($path, -strlen($ext)) === $ext;
|
return is_file($path) && substr($path, -strlen($ext)) === $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user