Skip to content

Commit

Permalink
PluginDependenciesProblem: Use plugin name from end of error message …
Browse files Browse the repository at this point in the history
…if available (instead of parsing from path)
  • Loading branch information
pavog committed Oct 2, 2024
1 parent 5b7dff7 commit cc2cf10
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
14 changes: 12 additions & 2 deletions src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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 \'([^\']+)\')?/'
];
}

/**
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'."
Expand Down

0 comments on commit cc2cf10

Please sign in to comment.