From cc2cf103659d47c1ae9b06fb096091a3de07bcdc Mon Sep 17 00:00:00 2001 From: Paul Vogel Date: Wed, 2 Oct 2024 19:28:18 +0200 Subject: [PATCH] PluginDependenciesProblem: Use plugin name from end of error message if available (instead of parsing from path) --- .../Problem/Bukkit/PluginDependenciesProblem.php | 14 ++++++++++++-- .../Paper/paper-multiple-dependencies-1-18-2.json | 4 ++-- .../Paper/paper-multiple-dependencies-1-20-4.json | 4 ++-- .../Paper/paper-multiple-depepdencies-1-21-1.json | 4 ++-- .../paper-plugin-dependency-1-18-2-duplicate.json | 4 ++-- .../Paper/paper-plugin-dependency-1-18-2.json | 4 ++-- .../Paper/paper-plugin-dependency-1-20-4.json | 4 ++-- .../Paper/paper-plugin-dependency-1-21-1.json | 4 ++-- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php b/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php index df008de..d1b16f2 100644 --- a/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php @@ -3,7 +3,9 @@ namespace Aternos\Codex\Minecraft\Analysis\Problem\Bukkit; use Aternos\Codex\Analysis\InsightInterface; +use Aternos\Codex\Minecraft\Analysis\Solution\Bukkit\PluginInstallDifferentVersionSolution; use Aternos\Codex\Minecraft\Analysis\Solution\Bukkit\PluginInstallSolution; +use Aternos\Codex\Minecraft\Analysis\Solution\Bukkit\PluginRemoveFileSolution; use Aternos\Codex\Minecraft\Translator\Translator; /** @@ -70,7 +72,8 @@ public static function getPatterns(): array { return [ '/Could not load \'(plugins[\/\\\][^\']+\.jar)\' in (?:folder )?\'([^\']+)\'' - . '\norg\.bukkit\.plugin\.UnknownDependencyException\: Unknown\/missing dependency plugins: \[([\w ,]+)\]/']; + . '\norg\.bukkit\.plugin\.UnknownDependencyException\: Unknown\/missing dependency plugins: \[([\w ,]+)\](?:\. Please download and install these plugins to run \'([^\']+)\')?/' + ]; } /** @@ -82,7 +85,14 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - parent::setMatches($matches, $patternKey); + if ($matches[4]) { + $this->pluginName = $matches[4]; + $this->pluginFilePath = $this->correctPluginPath($matches[1]); + $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); + $this->addSolution((new PluginRemoveFileSolution())->setPluginFilePath($this->getPluginFilePath())->setPluginName($this->getPluginName())); + } else { + parent::setMatches($matches, $patternKey); + } $this->dependencyPluginNames = preg_split("/, ?/", $matches[3]); foreach ($this->dependencyPluginNames as $name) { diff --git a/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-18-2.json b/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-18-2.json index baa83e2..ac59d75 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-18-2.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-18-2.json @@ -356,7 +356,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'mclogs-bukkit-2.3.1' is missing the required plugins 'example2', 'example1'.", + "message": "The plugin 'Mclogs' is missing the required plugins 'example2', 'example1'.", "counter": 1, "entry": { "level": 3, @@ -399,7 +399,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'mclogs-bukkit-2.3.1'." + "message": "Install a different version of the plugin 'Mclogs'." }, { "message": "Delete the file 'plugins\/mclogs-bukkit-2.3.1.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-20-4.json b/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-20-4.json index c2e615a..6dc1d10 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-20-4.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-multiple-dependencies-1-20-4.json @@ -405,7 +405,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'mclogs-bukkit-2.3.1' is missing the required plugins 'example1', 'example2'.", + "message": "The plugin 'Mclogs' is missing the required plugins 'example1', 'example2'.", "counter": 1, "entry": { "level": 3, @@ -456,7 +456,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'mclogs-bukkit-2.3.1'." + "message": "Install a different version of the plugin 'Mclogs'." }, { "message": "Delete the file 'plugins\/mclogs-bukkit-2.3.1.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-multiple-depepdencies-1-21-1.json b/test/data/Vanilla/Bukkit/Paper/paper-multiple-depepdencies-1-21-1.json index f5a25f8..ffd8a54 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-multiple-depepdencies-1-21-1.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-multiple-depepdencies-1-21-1.json @@ -478,7 +478,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'mclogs-bukkit-2.6.3' is missing the required plugins 'example1', 'example2'.", + "message": "The plugin 'Mclogs' is missing the required plugins 'example1', 'example2'.", "counter": 1, "entry": { "level": 3, @@ -529,7 +529,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'mclogs-bukkit-2.6.3'." + "message": "Install a different version of the plugin 'Mclogs'." }, { "message": "Delete the file 'plugins\/mclogs-bukkit-2.6.3.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2-duplicate.json b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2-duplicate.json index 7c38d76..cbc16eb 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2-duplicate.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2-duplicate.json @@ -373,7 +373,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'ViaBackwards-4.2.1' is missing the required plugin 'ViaVersion'.", + "message": "The plugin 'ViaBackwards' is missing the required plugin 'ViaVersion'.", "counter": 2, "entry": { "level": 3, @@ -416,7 +416,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'ViaBackwards-4.2.1'." + "message": "Install a different version of the plugin 'ViaBackwards'." }, { "message": "Delete the file 'plugins\/ViaBackwards-4.2.1.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2.json b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2.json index d31e113..b4e684e 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-18-2.json @@ -334,7 +334,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'ViaBackwards-4.2.1' is missing the required plugin 'ViaVersion'.", + "message": "The plugin 'ViaBackwards' is missing the required plugin 'ViaVersion'.", "counter": 1, "entry": { "level": 3, @@ -377,7 +377,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'ViaBackwards-4.2.1'." + "message": "Install a different version of the plugin 'ViaBackwards'." }, { "message": "Delete the file 'plugins\/ViaBackwards-4.2.1.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-20-4.json b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-20-4.json index 3db73e3..4e32e9e 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-20-4.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-20-4.json @@ -471,7 +471,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'worldguard-bukkit-7.0.9-dist' is missing the required plugin 'WorldEdit'.", + "message": "The plugin 'WorldGuard' is missing the required plugin 'WorldEdit'.", "counter": 1, "entry": { "level": 3, @@ -522,7 +522,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'worldguard-bukkit-7.0.9-dist'." + "message": "Install a different version of the plugin 'WorldGuard'." }, { "message": "Delete the file 'plugins\/worldguard-bukkit-7.0.9-dist.jar'." diff --git a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-21-1.json b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-21-1.json index 55ae8d5..5c7570b 100644 --- a/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-21-1.json +++ b/test/data/Vanilla/Bukkit/Paper/paper-plugin-dependency-1-21-1.json @@ -753,7 +753,7 @@ "analysis": { "problems": [ { - "message": "The plugin 'worldguard-bukkit-7.0.12-dist' is missing the required plugin 'WorldEdit'.", + "message": "The plugin 'WorldGuard' is missing the required plugin 'WorldEdit'.", "counter": 1, "entry": { "level": 3, @@ -804,7 +804,7 @@ }, "solutions": [ { - "message": "Install a different version of the plugin 'worldguard-bukkit-7.0.12-dist'." + "message": "Install a different version of the plugin 'WorldGuard'." }, { "message": "Delete the file 'plugins\/worldguard-bukkit-7.0.12-dist.jar'."