From bca7707835013d4d3557931ed85dabff7bc308fc Mon Sep 17 00:00:00 2001 From: Paul Vogel Date: Tue, 10 Nov 2026 18:46:38 +0100 Subject: [PATCH] use named pattern keys in forge mod problems --- .../Problem/Forge/ModDependencyProblem.php | 16 ++++++++-------- src/Analysis/Problem/Forge/ModFatalProblem.php | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Analysis/Problem/Forge/ModDependencyProblem.php b/src/Analysis/Problem/Forge/ModDependencyProblem.php index 2961297c..1b08625a 100644 --- a/src/Analysis/Problem/Forge/ModDependencyProblem.php +++ b/src/Analysis/Problem/Forge/ModDependencyProblem.php @@ -33,10 +33,10 @@ public function getMessage(): string public static function getPatterns(): array { return [ - '/The mod \S+ \(([^\)]+)\) requires mods \[([^\]]+)\] to be available/', - '/net\.minecraftforge\.fml\.common\.MissingModsException: Mod \S+ \((.+)\) requires (.+)/', - '/net\.minecraftforge\.fml\.ModLoadingException: Mod \§.([^\§]+)\§. requires \§.([^\§]+)\§. \§.([^ \§]+)[^\§]*\§./', - '/net\.minecraftforge\.fml\.LoadingFailedException: Loading errors encountered: \[\n(?:.*\n)*Mod \§.([^\§]+)§. requires \§.([^\§]+)\§. \§.([^ \§]+)[^\§]*\§./' + 'requires-mods' => '/The mod \S+ \(([^\)]+)\) requires mods \[([^\]]+)\] to be available/', + 'missing-mods-exception' => '/net\.minecraftforge\.fml\.common\.MissingModsException: Mod \S+ \((.+)\) requires (.+)/', + 'mod-loading-exception' => '/net\.minecraftforge\.fml\.ModLoadingException: Mod \§.([^\§]+)\§. requires \§.([^\§]+)\§. \§.([^ \§]+)[^\§]*\§./', + 'loading-failed-exception' => '/net\.minecraftforge\.fml\.LoadingFailedException: Loading errors encountered: \[\n(?:.*\n)*Mod \§.([^\§]+)§. requires \§.([^\§]+)\§. \§.([^ \§]+)[^\§]*\§./' ]; } @@ -48,11 +48,11 @@ public function setMatches(array $matches, mixed $patternKey): void $this->modName = $matches[1]; switch ($patternKey) { - case 0: + case 'requires-mods': $this->dependencyMods[] = $matches[2]; $this->addSolution(new ModInstallSolution($matches[2])); break; - case 1: + case 'missing-mods-exception': $count = preg_match_all('/(\w+)(?:@\[?([0-9\.]+))?[,\]]/', $matches[2], $dependencyMatches); if (!$count) { if (preg_match('/\[(\S+)\]/', $matches[2], $dependencyMatches)) { @@ -74,8 +74,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->addSolution($solution); } break; - case 2: - case 3: + case 'mod-loading-exception': + case 'loading-failed-exception': $this->dependencyMods[] = $matches[2]; $this->addSolution(new ModInstallSolution($matches[2], $matches[3])); break; diff --git a/src/Analysis/Problem/Forge/ModFatalProblem.php b/src/Analysis/Problem/Forge/ModFatalProblem.php index 3832ffa2..c0fcc7c1 100644 --- a/src/Analysis/Problem/Forge/ModFatalProblem.php +++ b/src/Analysis/Problem/Forge/ModFatalProblem.php @@ -28,8 +28,8 @@ public function getMessage(): string public static function getPatterns(): array { return [ - '/\s*U[LCHIJAD]*E\s+(\w+)\{([^\}]+)\} \[([^\]]+)\] \(([^\)]+)\)/', - '/^\s*([^\(\n]+) \(([^\)]+)\) has failed to load correctly/m' + 'mod-state' => '/\s*U[LCHIJAD]*E\s+(\w+)\{([^\}]+)\} \[([^\]]+)\] \(([^\)]+)\)/', + 'failed-to-load' => '/^\s*([^\(\n]+) \(([^\)]+)\) has failed to load correctly/m' ]; } @@ -39,14 +39,14 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { switch ($patternKey) { - case 0: + case 'mod-state': $this->modId = $matches[1]; $this->modVersion = $matches[2]; $this->modName = $matches[3]; $this->modFileName = $matches[4]; $this->addSolution(new FileDeleteSolution("mods/" . $this->getModFileName())); break; - case 1: + case 'failed-to-load': $this->modId = $matches[2]; $this->modName = $matches[1]; $this->addSolution(new ModRemoveSolution($this->getModName()));