Skip to content

Commit

Permalink
Merge pull request #22 from aternosorg/bukkit-dependencies
Browse files Browse the repository at this point in the history
Add additional bukkit dependency error
  • Loading branch information
JulianVennen authored Jun 7, 2022
2 parents c1a0686 + c5ce756 commit ea3053a
Show file tree
Hide file tree
Showing 16 changed files with 2,544 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"authme-shutdown-problem": "The plugin 'AuthMe' fails to load and shuts the server down.",
"pex-config-problem": "The configuration of the plugin 'PermissionsEx' is invalid.",
"ambiguous-plugin-name-problem": "There are multiple plugin files for the plugin name '{{plugin-name}}': '{{first-plugin-path}}' and '{{second-plugin-path}}'.",
"plugin-dependency-problem": "The plugin '{{plugin-name}}' is missing the required the plugin '{{dependency-plugin-name}}'.",
"plugin-dependency-problem": "The plugin '{{plugin-name}}' is missing the required plugin '{{dependency-plugin-name}}'.",
"plugin-dependencies-problem": "The plugin '{{plugin-name}}' is missing the required plugins {{dependency-plugin-names}}.",
"plugin-disabling-problem": "The plugin '{{plugin-name}}' could not be disabled.",
"plugin-enabling-problem": "The plugin '{{plugin-name}}' could not be enabled.",
"plugin-runtime-problem": "The plugin '{{plugin-name}}' has a problem while running.",
Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/BukkitAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\Plugin\MultiverseLoadProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\Plugin\PermissionsExConfigProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\PluginCommandExceptionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\PluginDependenciesProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\PluginDependencyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\PluginDisablingProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Bukkit\PluginEnablingProblem;
Expand Down Expand Up @@ -46,6 +47,7 @@ public static function getInsightClasses(): array
AuthMeShutdownProblem::class,
PermissionsExConfigProblem::class,
MultiverseLoadProblem::class,
PluginDependenciesProblem::class,
];
}
}
134 changes: 134 additions & 0 deletions src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Problem\Bukkit;

use Aternos\Codex\Minecraft\Analysis\Solution\Bukkit\PluginInstallSolution;
use Aternos\Codex\Minecraft\Analysis\Solution\File\FileDeleteSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

/**
* Class PluginDependencyProblem
*
* @package Aternos\Codex\Minecraft\Analysis\Problem\Bukkit
*/
class PluginDependenciesProblem extends BukkitProblem
{
/**
* @var string
*/
protected $pluginPath;

/**
* @var string
*/
protected $pluginName;

/**
* @var string[]
*/
protected $dependencyPluginNames;

/**
* @return string
*/
public function getPluginPath(): string
{
return $this->pluginPath;
}

/**
* @return string
*/
public function getPluginName()
{
return $this->pluginName;
}

/**
* get a list of missing dependencies
* @return string[]
*/
public function getDependencyPlugins(): array
{
return $this->dependencyPluginNames;
}

/**
* @return string
*/
public function getDependencyPluginNames(): string
{
$result = [];
foreach ($this->dependencyPluginNames as $name) {
$result[] = "'". $name ."'";
}
return implode(", ", $result);
}

/**
* Get a human readable message
*
* @return string
*/
public function getMessage(): string
{
if (count($this->getDependencyPlugins()) === 1) {
return Translator::getInstance()->getTranslation("plugin-dependency-problem", [
"plugin-name" => $this->getPluginName(),
"dependency-plugin-name" => $this->getDependencyPlugins()[0]
]);
}

return Translator::getInstance()->getTranslation("plugin-dependencies-problem", [
"plugin-name" => $this->getPluginName(),
"dependency-plugin-names" => $this->getDependencyPluginNames()
]);
}

/**
* Get an array of possible patterns
*
* The array key of the pattern will be passed to setMatches()
*
* @return array
*/
public static function getPatterns(): array
{
return ['/Could not load \'(plugins[\/\\\]((?!\.jar).*)\.jar)\' in folder \'[^\']+\'\norg\.bukkit\.plugin\.UnknownDependencyException\: Unknown\/missing dependency plugins: \[([\w ,]+)\]/'];
}

/**
* Apply the matches from the pattern
*
* @param array $matches
* @param $patternKey
*/
public function setMatches(array $matches, $patternKey): void
{
$this->pluginPath = $matches[1];
$this->pluginName = $matches[2];
$this->dependencyPluginNames = preg_split("/, ?/", $matches[3]);

foreach ($this->dependencyPluginNames as $name) {
$this->addSolution((new PluginInstallSolution())->setPluginName($name));
}
$this->addSolution((new FileDeleteSolution())->setRelativePath($this->getPluginPath()));
}

/**
* @param static $insight
* @return bool
*/
public function isEqual($insight): bool
{
if ($this->getPluginName() !== $insight->getPluginName() || $this->getPluginPath() !== $insight->getPluginPath()) {
return false;
}

$dependencies = $insight->getDependencyPlugins();
sort($dependencies);
$ownDependencies = $this->getDependencyPlugins();
sort($ownDependencies);
return $dependencies === $ownDependencies;
}
}
36 changes: 36 additions & 0 deletions test/data/bukkit/paper-multiple-dependencies.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[14:22:43] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[14:22:45] [Worker-Main-1/INFO]: Loaded 7 recipes
[14:22:46] [Server thread/INFO]: Starting minecraft server version 1.18.2
[14:22:46] [Server thread/INFO]: Loading properties
[14:22:46] [Server thread/INFO]: This server is running Paper version git-Paper-333 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 9fd870d)
[14:22:46] [Server thread/INFO]: Server Ping Player Sample Count: 12
[14:22:46] [Server thread/INFO]: Using 4 threads for Netty based IO
[14:22:46] [Server thread/INFO]: Default game type: SURVIVAL
[14:22:46] [Server thread/INFO]: Generating keypair
[14:22:46] [Server thread/INFO]: Starting Minecraft server on *:23728
[14:22:46] [Server thread/INFO]: Using epoll channel type
[14:22:46] [Server thread/INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[14:22:46] [Server thread/INFO]: Paper: Using OpenSSL 1.1.x (Linux x86_64) cipher from Velocity.
[14:22:46] [Server thread/ERROR]: Could not load 'plugins/mclogs-bukkit-2.3.1.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [example2, example1]. Please download and install these plugins to run 'Mclogs'.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:291) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-333]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[14:22:46] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[14:22:46] [Server thread/INFO]: Preparing level "world"
[14:22:52] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[14:22:53] [Server thread/INFO]: Time elapsed: 243 ms
[14:22:53] [Server thread/INFO]: Preparing start region for dimension minecraft:the_nether
[14:22:53] [Server thread/INFO]: Time elapsed: 153 ms
[14:22:53] [Server thread/INFO]: Preparing start region for dimension minecraft:the_end
[14:22:53] [Server thread/INFO]: Time elapsed: 193 ms
[14:22:53] [Server thread/INFO]: Starting GS4 status listener
[14:22:53] [Server thread/INFO]: Thread Query Listener started
[14:22:53] [Query Listener #1/INFO]: Query running on 0.0.0.0:9898
[14:22:53] [Server thread/INFO]: JMX monitoring enabled
[14:22:53] [Server thread/INFO]: Running delayed init tasks
[14:22:53] [Server thread/INFO]: Done (7.061s)! For help, type "help"
[14:22:53] [Server thread/INFO]: Timings Reset
42 changes: 42 additions & 0 deletions test/data/bukkit/paper-plugin-dependency-1-18-2-duplicate.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[08:29:59] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[08:30:08] [Worker-Main-1/INFO]: Loaded 7 recipes
[08:30:12] [Server thread/INFO]: Starting minecraft server version 1.18.2
[08:30:12] [Server thread/INFO]: Loading properties
[08:30:12] [Server thread/INFO]: This server is running Paper version git-Paper-333 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 9fd870d)
[08:30:12] [Server thread/INFO]: Server Ping Player Sample Count: 12
[08:30:12] [Server thread/INFO]: Using 4 threads for Netty based IO
[08:30:13] [Server thread/INFO]: Default game type: SURVIVAL
[08:30:13] [Server thread/INFO]: Generating keypair
[08:30:13] [Server thread/INFO]: Starting Minecraft server on *:32699
[08:30:13] [Server thread/INFO]: Using epoll channel type
[08:30:13] [Server thread/INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[08:30:13] [Server thread/INFO]: Paper: Using OpenSSL 1.1.x (Linux x86_64) cipher from Velocity.
[08:30:13] [Server thread/ERROR]: Could not load 'plugins/ViaBackwards-4.2.1.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [ViaVersion]. Please download and install these plugins to run 'ViaBackwards'.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:291) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-333]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[08:30:13] [Server thread/ERROR]: Could not load 'plugins/ViaBackwards-4.2.1.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [ViaVersion]. Please download and install these plugins to run 'ViaBackwards'.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:291) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-333]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[08:30:13] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[08:30:13] [Server thread/INFO]: Preparing level "world"
[08:30:24] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[08:30:26] [Worker-Main-1/INFO]: Preparing spawn area: 0%
[08:30:26] [Worker-Main-1/INFO]: Preparing spawn area: 99%
[08:30:36] [Server thread/INFO]: Time elapsed: 937 ms
[08:30:36] [Server thread/INFO]: Starting GS4 status listener
[08:30:36] [Query Listener #1/INFO]: Query running on 0.0.0.0:9898
[08:30:36] [Server thread/INFO]: Thread Query Listener started
[08:30:36] [Server thread/INFO]: JMX monitoring enabled
[08:30:36] [Server thread/INFO]: Running delayed init tasks
[08:30:36] [Server thread/INFO]: Done (24.549s)! For help, type "help"
[08:30:36] [Server thread/INFO]: Timings Reset
34 changes: 34 additions & 0 deletions test/data/bukkit/paper-plugin-dependency-1-18-2.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[08:29:59] [ServerMain/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[08:30:08] [Worker-Main-1/INFO]: Loaded 7 recipes
[08:30:12] [Server thread/INFO]: Starting minecraft server version 1.18.2
[08:30:12] [Server thread/INFO]: Loading properties
[08:30:12] [Server thread/INFO]: This server is running Paper version git-Paper-333 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 9fd870d)
[08:30:12] [Server thread/INFO]: Server Ping Player Sample Count: 12
[08:30:12] [Server thread/INFO]: Using 4 threads for Netty based IO
[08:30:13] [Server thread/INFO]: Default game type: SURVIVAL
[08:30:13] [Server thread/INFO]: Generating keypair
[08:30:13] [Server thread/INFO]: Starting Minecraft server on *:32699
[08:30:13] [Server thread/INFO]: Using epoll channel type
[08:30:13] [Server thread/INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[08:30:13] [Server thread/INFO]: Paper: Using OpenSSL 1.1.x (Linux x86_64) cipher from Velocity.
[08:30:13] [Server thread/ERROR]: Could not load 'plugins/ViaBackwards-4.2.1.jar' in folder 'plugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [ViaVersion]. Please download and install these plugins to run 'ViaBackwards'.
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:291) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-333]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-333]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[08:30:13] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[08:30:13] [Server thread/INFO]: Preparing level "world"
[08:30:24] [Server thread/INFO]: Preparing start region for dimension minecraft:overworld
[08:30:26] [Worker-Main-1/INFO]: Preparing spawn area: 0%
[08:30:26] [Worker-Main-1/INFO]: Preparing spawn area: 99%
[08:30:36] [Server thread/INFO]: Time elapsed: 937 ms
[08:30:36] [Server thread/INFO]: Starting GS4 status listener
[08:30:36] [Query Listener #1/INFO]: Query running on 0.0.0.0:9898
[08:30:36] [Server thread/INFO]: Thread Query Listener started
[08:30:36] [Server thread/INFO]: JMX monitoring enabled
[08:30:36] [Server thread/INFO]: Running delayed init tasks
[08:30:36] [Server thread/INFO]: Done (24.549s)! For help, type "help"
[08:30:36] [Server thread/INFO]: Timings Reset
Loading

0 comments on commit ea3053a

Please sign in to comment.