diff --git a/src/Analysis/Problem/Bukkit/AmbiguousPluginNameProblem.php b/src/Analysis/Problem/Bukkit/AmbiguousPluginNameProblem.php index f3f74f4a..7fba0d7b 100644 --- a/src/Analysis/Problem/Bukkit/AmbiguousPluginNameProblem.php +++ b/src/Analysis/Problem/Bukkit/AmbiguousPluginNameProblem.php @@ -64,8 +64,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->firstPluginPath = $this->correctPluginPath($matches[2]); $this->secondPluginPath = $this->correctPluginPath($matches[3]); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getFirstPluginPath())); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getSecondPluginPath())); + $this->addSolution(new FileDeleteSolution($this->getFirstPluginPath())); + $this->addSolution(new FileDeleteSolution($this->getSecondPluginPath())); } /** diff --git a/src/Analysis/Problem/Bukkit/ChunkLoadExceptionProblem.php b/src/Analysis/Problem/Bukkit/ChunkLoadExceptionProblem.php index 4216ae11..5fc316df 100644 --- a/src/Analysis/Problem/Bukkit/ChunkLoadExceptionProblem.php +++ b/src/Analysis/Problem/Bukkit/ChunkLoadExceptionProblem.php @@ -50,8 +50,8 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new WorldRepairSolution())->setWorldName("world")); - $this->addSolution((new FileDeleteSolution())->setRelativePath("world")); - $this->addSolution((new ChunkRemoveSolution())); + $this->addSolution(new WorldRepairSolution("world")); + $this->addSolution(new FileDeleteSolution("world")); + $this->addSolution(new ChunkRemoveSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Bukkit/Plugin/AuthMeShutdownProblem.php b/src/Analysis/Problem/Bukkit/Plugin/AuthMeShutdownProblem.php index f7acf992..d51338a0 100644 --- a/src/Analysis/Problem/Bukkit/Plugin/AuthMeShutdownProblem.php +++ b/src/Analysis/Problem/Bukkit/Plugin/AuthMeShutdownProblem.php @@ -46,9 +46,9 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new AuthMeShutdownSolution())); - $this->addSolution((new PluginConfigureSolution())->setPluginName("AuthMe")->setSuggestedFile("plugins/AuthMe/config.yml")); - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName("AuthMe")); - $this->addSolution((new PluginRemoveSolution())->setPluginName("AuthMe")); + $this->addSolution(new AuthMeShutdownSolution()); + $this->addSolution(new PluginConfigureSolution("AuthMe", "plugins/AuthMe/config.yml")); + $this->addSolution(new PluginInstallDifferentVersionSolution("AuthMe")); + $this->addSolution(new PluginRemoveSolution("AuthMe")); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Bukkit/Plugin/MultiverseLoadProblem.php b/src/Analysis/Problem/Bukkit/Plugin/MultiverseLoadProblem.php index 866c18a8..000b52ff 100644 --- a/src/Analysis/Problem/Bukkit/Plugin/MultiverseLoadProblem.php +++ b/src/Analysis/Problem/Bukkit/Plugin/MultiverseLoadProblem.php @@ -56,7 +56,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->worldName = $matches[1]; - $this->addSolution((new WorldRepairSolution())->setWorldName($this->getWorldName())); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getWorldName())); + $this->addSolution(new WorldRepairSolution($this->getWorldName())); + $this->addSolution(new FileDeleteSolution($this->getWorldName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Bukkit/Plugin/PermissionsExConfigProblem.php b/src/Analysis/Problem/Bukkit/Plugin/PermissionsExConfigProblem.php index 39c3c2dd..c7acbd49 100644 --- a/src/Analysis/Problem/Bukkit/Plugin/PermissionsExConfigProblem.php +++ b/src/Analysis/Problem/Bukkit/Plugin/PermissionsExConfigProblem.php @@ -44,7 +44,7 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new PluginConfigureSolution())->setPluginName("PermissionsEx")->setSuggestedFile("plugins/PermissionsEx/permissions.yml")); - $this->addSolution((new PluginRemoveSolution())->setPluginName("PermissionsEx")); + $this->addSolution(new PluginConfigureSolution("PermissionsEx", "plugins/PermissionsEx/permissions.yml")); + $this->addSolution(new PluginRemoveSolution("PermissionsEx")); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Bukkit/PluginCommandExceptionProblem.php b/src/Analysis/Problem/Bukkit/PluginCommandExceptionProblem.php index 8bdbb69d..bdce16fe 100644 --- a/src/Analysis/Problem/Bukkit/PluginCommandExceptionProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginCommandExceptionProblem.php @@ -51,8 +51,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->command = $matches[1]; $this->pluginName = $matches[2]; - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new PluginRemoveSolution())->setPluginName($this->getPluginName())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new PluginRemoveSolution($this->getPluginName())); } /** diff --git a/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php b/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php index 61868107..dc291642 100644 --- a/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginDependenciesProblem.php @@ -88,15 +88,15 @@ public function setMatches(array $matches, mixed $patternKey): void if ($matches[4]) { $this->pluginName = $matches[4]; $this->pluginFilePath = $this->correctPluginPath($matches[1]); - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getPluginFilePath())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new FileDeleteSolution($this->getPluginFilePath())); } else { parent::setMatches($matches, $patternKey); } $this->dependencyPluginNames = preg_split("/, ?/", $matches[3]); foreach ($this->dependencyPluginNames as $name) { - $this->addSolution((new PluginInstallSolution())->setPluginName($name)); + $this->addSolution(new PluginInstallSolution($name)); } } diff --git a/src/Analysis/Problem/Bukkit/PluginDependencyProblem.php b/src/Analysis/Problem/Bukkit/PluginDependencyProblem.php index 828c7425..a25b0f21 100644 --- a/src/Analysis/Problem/Bukkit/PluginDependencyProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginDependencyProblem.php @@ -62,7 +62,7 @@ public function setMatches(array $matches, mixed $patternKey): void parent::setMatches($matches, $patternKey); $this->dependencyPluginName = $matches[3] ?: $matches[4]; - $this->addSolution((new PluginInstallSolution())->setPluginName($this->getDependencyPluginName())); + $this->addSolution(new PluginInstallSolution($this->getDependencyPluginName())); } /** diff --git a/src/Analysis/Problem/Bukkit/PluginFileProblem.php b/src/Analysis/Problem/Bukkit/PluginFileProblem.php index 296b3d99..c311482d 100644 --- a/src/Analysis/Problem/Bukkit/PluginFileProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginFileProblem.php @@ -45,8 +45,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->pluginFilePath = $folderPath . '/' . $pluginFileName; $this->pluginName = $this->extractPluginName($matches[1]); - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getPluginFilePath())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new FileDeleteSolution($this->getPluginFilePath())); } /** diff --git a/src/Analysis/Problem/Bukkit/PluginProblem.php b/src/Analysis/Problem/Bukkit/PluginProblem.php index bebd1f62..7458e111 100644 --- a/src/Analysis/Problem/Bukkit/PluginProblem.php +++ b/src/Analysis/Problem/Bukkit/PluginProblem.php @@ -41,8 +41,8 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->pluginName = $this->extractPluginName($matches[1]); - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new PluginRemoveSolution())->setPluginName($this->getPluginName())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new PluginRemoveSolution($this->getPluginName())); } /** diff --git a/src/Analysis/Problem/Bukkit/UnsupportedApiVersionProblem.php b/src/Analysis/Problem/Bukkit/UnsupportedApiVersionProblem.php index e7945618..06d23855 100644 --- a/src/Analysis/Problem/Bukkit/UnsupportedApiVersionProblem.php +++ b/src/Analysis/Problem/Bukkit/UnsupportedApiVersionProblem.php @@ -42,7 +42,7 @@ public function setMatches(array $matches, mixed $patternKey): void parent::setMatches($matches, $patternKey); $this->apiVersion = $matches[3]; - $this->addSolution((new ServerInstallDifferentVersionSolution())->setSoftwareVersion($this->getApiVersion())); + $this->addSolution(new ServerInstallDifferentVersionSolution($this->getApiVersion())); } diff --git a/src/Analysis/Problem/Bukkit/UnsupportedClassVersionProblem.php b/src/Analysis/Problem/Bukkit/UnsupportedClassVersionProblem.php index 59daa1b2..61708a4c 100644 --- a/src/Analysis/Problem/Bukkit/UnsupportedClassVersionProblem.php +++ b/src/Analysis/Problem/Bukkit/UnsupportedClassVersionProblem.php @@ -49,7 +49,7 @@ public function setMatches(array $matches, mixed $patternKey): void $this->classFileVersion = intval($matches[3]); } - $this->addSolution((new UpdateJavaSolution())->setVersion($this->getJavaVersion())); + $this->addSolution(new UpdateJavaSolution($this->getJavaVersion())); } diff --git a/src/Analysis/Problem/Bukkit/WorldDuplicateProblem.php b/src/Analysis/Problem/Bukkit/WorldDuplicateProblem.php index ca303129..ebc20df6 100644 --- a/src/Analysis/Problem/Bukkit/WorldDuplicateProblem.php +++ b/src/Analysis/Problem/Bukkit/WorldDuplicateProblem.php @@ -55,7 +55,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->worldName = $matches[1]; - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->worldName . "/uid.dat")); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->worldName)); + $this->addSolution(new FileDeleteSolution($this->worldName . "/uid.dat")); + $this->addSolution(new FileDeleteSolution($this->worldName)); } } \ No newline at end of file diff --git a/src/Analysis/Problem/CrashReport/TickingEntityProblem.php b/src/Analysis/Problem/CrashReport/TickingEntityProblem.php index 68d4d69d..40a17326 100644 --- a/src/Analysis/Problem/CrashReport/TickingEntityProblem.php +++ b/src/Analysis/Problem/CrashReport/TickingEntityProblem.php @@ -32,7 +32,7 @@ public function getMessage(): string { return Translator::getInstance()->getTranslation("ticking-entity-problem", [ "name" => $this->getName(), - "location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ() + "location" => sprintf("%s, %s, %s", $this->getLocationX(), $this->getLocationY(), $this->getLocationZ()) ]); } diff --git a/src/Analysis/Problem/Fabric/FabricDuplicateModProblem.php b/src/Analysis/Problem/Fabric/FabricDuplicateModProblem.php index 75b6208e..96e001aa 100644 --- a/src/Analysis/Problem/Fabric/FabricDuplicateModProblem.php +++ b/src/Analysis/Problem/Fabric/FabricDuplicateModProblem.php @@ -4,6 +4,7 @@ use Aternos\Codex\Minecraft\Analysis\Solution\File\FileDeleteSolution; +use Aternos\Codex\Minecraft\Analysis\Solution\File\FilePathType; use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\VanillaServerLog; use Aternos\Codex\Minecraft\Translator\Translator; @@ -42,6 +43,6 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->setModName($matches[3]); - $this->addSolution((new FileDeleteSolution())->setAbsolutePath($matches[4])); + $this->addSolution(new FileDeleteSolution($matches[4], FilePathType::ABSOLUTE)); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Fabric/FabricEntryStageProblem.php b/src/Analysis/Problem/Fabric/FabricEntryStageProblem.php index a6106b25..001695f5 100644 --- a/src/Analysis/Problem/Fabric/FabricEntryStageProblem.php +++ b/src/Analysis/Problem/Fabric/FabricEntryStageProblem.php @@ -38,6 +38,6 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->setModName($matches[1]); - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); + $this->addSolution(new ModRemoveSolution($this->getModName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Fabric/FabricIncompatibleModsProblem.php b/src/Analysis/Problem/Fabric/FabricIncompatibleModsProblem.php index 891593de..3c5401e3 100644 --- a/src/Analysis/Problem/Fabric/FabricIncompatibleModsProblem.php +++ b/src/Analysis/Problem/Fabric/FabricIncompatibleModsProblem.php @@ -46,7 +46,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->setModName($matches[1]); $this->setSecondModName($matches[3]); - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); - $this->addSolution((new ModRemoveSolution())->setModName($this->getSecondModName())); + $this->addSolution(new ModRemoveSolution($this->getModName())); + $this->addSolution(new ModRemoveSolution($this->getSecondModName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Fabric/FabricMixinProblem.php b/src/Analysis/Problem/Fabric/FabricMixinProblem.php index 08b1f8f0..10cd2c28 100644 --- a/src/Analysis/Problem/Fabric/FabricMixinProblem.php +++ b/src/Analysis/Problem/Fabric/FabricMixinProblem.php @@ -31,6 +31,6 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->setModName($matches[1]); - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); + $this->addSolution(new ModRemoveSolution($this->getModName())); } } diff --git a/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php b/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php index 19331f82..6cf4ffe3 100644 --- a/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php +++ b/src/Analysis/Problem/Fabric/FabricModDependencyProblem.php @@ -60,7 +60,7 @@ public function setMatches(array $matches, mixed $patternKey): void case 'short-error': $this->setModName($matches[2]); $this->setDependency($matches[empty($matches[3]) ? 4 : 3]); - $solution = (new ModInstallSolution())->setModName($this->getDependency()); + $solution = (new ModInstallSolution($this->getDependency())); if ($matches[5] != '*') { $solution->setModVersion($matches[5]); } @@ -70,7 +70,7 @@ public function setMatches(array $matches, mixed $patternKey): void case 'any': $this->setModName($matches[1]); $this->setDependency($matches[empty($matches[3]) ? 4 : 3]); - $this->addSolution((new ModInstallSolution())->setModName($this->getDependency())); + $this->addSolution(new ModInstallSolution($this->getDependency())); return; case 'minimum': @@ -91,10 +91,9 @@ public function setMatches(array $matches, mixed $patternKey): void $firstSymbol = $matches[4] === "exclusive" ? ">" : ">="; $secondSymbol = $matches[6] === "exclusive" ? "<" : "<="; + $modVersion = $firstSymbol . $matches[3] . ", " . $secondSymbol . $matches[5]; - $this->addSolution((new ModInstallSolution()) - ->setModName($this->getDependency()) - ->setModVersion($firstSymbol . $matches[3] . ", " . $secondSymbol . $matches[5])); + $this->addSolution(new ModInstallSolution($this->getDependency(), $modVersion)); return; default: @@ -104,7 +103,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->setModName($matches[1]); $this->setDependency($matches[empty($matches[4]) ? 5 : 4]); - $this->addSolution((new ModInstallSolution())->setModName($this->getDependency())->setModVersion($symbol . $matches[3])); + $modVersion = $symbol . $matches[3]; + $this->addSolution(new ModInstallSolution($this->getDependency(), $modVersion)); } /** diff --git a/src/Analysis/Problem/Folia/PluginRegionalTickingProblem.php b/src/Analysis/Problem/Folia/PluginRegionalTickingProblem.php index c7bf5a0d..bf79a05c 100644 --- a/src/Analysis/Problem/Folia/PluginRegionalTickingProblem.php +++ b/src/Analysis/Problem/Folia/PluginRegionalTickingProblem.php @@ -52,8 +52,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->pluginFilePath = $folderPath . '/' . $pluginFileName; $this->pluginName = $matches[3]; - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getPluginFilePath())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new FileDeleteSolution($this->getPluginFilePath())); $this->addSolution(new InstallNonRegionalTickingSoftwareSolution()); } diff --git a/src/Analysis/Problem/Forge/FmlConfirmProblem.php b/src/Analysis/Problem/Forge/FmlConfirmProblem.php index 1019e1c1..39c0a774 100644 --- a/src/Analysis/Problem/Forge/FmlConfirmProblem.php +++ b/src/Analysis/Problem/Forge/FmlConfirmProblem.php @@ -43,6 +43,6 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new CommandRunSolution())->setCommand('/fml confirm')); + $this->addSolution(new CommandRunSolution('/fml confirm')); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/LanguageProviderVersionProblem.php b/src/Analysis/Problem/Forge/LanguageProviderVersionProblem.php index eb0f2b9f..a845520c 100644 --- a/src/Analysis/Problem/Forge/LanguageProviderVersionProblem.php +++ b/src/Analysis/Problem/Forge/LanguageProviderVersionProblem.php @@ -49,7 +49,7 @@ public function setMatches(array $matches, mixed $patternKey): void $this->requiredVersion = $matches[3]; $this->foundVersion = $matches[4]; - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); - $this->addSolution((new ForgeInstallDifferentVersionSolution())); + $this->addSolution(new ModRemoveSolution($this->getModName())); + $this->addSolution(new ForgeInstallDifferentVersionSolution()); } } diff --git a/src/Analysis/Problem/Forge/MissingDatapackModProblem.php b/src/Analysis/Problem/Forge/MissingDatapackModProblem.php index 6734eeab..f590eab5 100644 --- a/src/Analysis/Problem/Forge/MissingDatapackModProblem.php +++ b/src/Analysis/Problem/Forge/MissingDatapackModProblem.php @@ -41,7 +41,7 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->modName = $matches[1]; - $this->addSolution((new ModInstallSolution())->setModName($this->modName)); + $this->addSolution(new ModInstallSolution($this->modName)); $this->addSolution(new DoNothingSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/ModDependencyProblem.php b/src/Analysis/Problem/Forge/ModDependencyProblem.php index 7b79e4fe..97974f8f 100644 --- a/src/Analysis/Problem/Forge/ModDependencyProblem.php +++ b/src/Analysis/Problem/Forge/ModDependencyProblem.php @@ -65,14 +65,14 @@ public function setMatches(array $matches, mixed $patternKey): void switch ($patternKey) { case 0: $this->dependencyMods[] = $matches[2]; - $this->addSolution((new ModInstallSolution())->setModName($matches[2])); + $this->addSolution(new ModInstallSolution($matches[2])); break; case 1: $count = preg_match_all('/(\w+)(?:@\[?([0-9\.]+))?[,\]]/', $matches[2], $dependencyMatches); if (!$count) { if (preg_match('/\[(\S+)\]/', $matches[2], $dependencyMatches)) { $this->dependencyMods[] = $dependencyMatches[1]; - $this->addSolution((new ModInstallSolution())->setModName($dependencyMatches[1])); + $this->addSolution(new ModInstallSolution($dependencyMatches[1])); } return; } @@ -82,7 +82,7 @@ public function setMatches(array $matches, mixed $patternKey): void $version = $dependencyMatches[2][$i]; $this->dependencyMods[] = $name; - $solution = (new ModInstallSolution())->setModName($name); + $solution = new ModInstallSolution($name); if ($version) { $solution->setModVersion($version); } @@ -92,7 +92,7 @@ public function setMatches(array $matches, mixed $patternKey): void case 2: case 3: $this->dependencyMods[] = $matches[2]; - $this->addSolution((new ModInstallSolution())->setModName($matches[2])->setModVersion($matches[3])); + $this->addSolution(new ModInstallSolution($matches[2], $matches[3])); break; } } diff --git a/src/Analysis/Problem/Forge/ModDuplicateProblem.php b/src/Analysis/Problem/Forge/ModDuplicateProblem.php index 8294ef45..8be58a3b 100644 --- a/src/Analysis/Problem/Forge/ModDuplicateProblem.php +++ b/src/Analysis/Problem/Forge/ModDuplicateProblem.php @@ -4,6 +4,7 @@ use Aternos\Codex\Analysis\InsightInterface; use Aternos\Codex\Minecraft\Analysis\Solution\File\FileDeleteSolution; +use Aternos\Codex\Minecraft\Analysis\Solution\File\FilePathType; use Aternos\Codex\Minecraft\Translator\Translator; /** @@ -61,8 +62,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->firstModPath = $matches[2]; $this->secondModPath = $matches[3]; - $this->addSolution((new FileDeleteSolution())->setAbsolutePath($this->getFirstModPath())); - $this->addSolution((new FileDeleteSolution())->setAbsolutePath($this->getSecondModPath())); + $this->addSolution(new FileDeleteSolution($this->getFirstModPath(), FilePathType::ABSOLUTE)); + $this->addSolution(new FileDeleteSolution($this->getSecondModPath(), FilePathType::ABSOLUTE)); } /** diff --git a/src/Analysis/Problem/Forge/ModExceptionProblem.php b/src/Analysis/Problem/Forge/ModExceptionProblem.php index c48d40e6..3dd58cc2 100644 --- a/src/Analysis/Problem/Forge/ModExceptionProblem.php +++ b/src/Analysis/Problem/Forge/ModExceptionProblem.php @@ -49,7 +49,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->modName = trim($matches[1]); - $this->addSolution((new ModInstallDifferentVersionSolution())->setModName($this->getModName())); - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); + $this->addSolution(new ModInstallDifferentVersionSolution($this->getModName())); + $this->addSolution(new ModRemoveSolution($this->getModName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/ModFatalProblem.php b/src/Analysis/Problem/Forge/ModFatalProblem.php index bb7b3a28..213bedcf 100644 --- a/src/Analysis/Problem/Forge/ModFatalProblem.php +++ b/src/Analysis/Problem/Forge/ModFatalProblem.php @@ -58,16 +58,16 @@ public function setMatches(array $matches, mixed $patternKey): void $this->modVersion = $matches[2]; $this->modName = $matches[3]; $this->modFileName = $matches[4]; - $this->addSolution((new FileDeleteSolution())->setRelativePath("mods/" . $this->getModFileName())); + $this->addSolution(new FileDeleteSolution("mods/" . $this->getModFileName())); break; case 1: $this->modId = $matches[2]; $this->modName = $matches[1]; - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); + $this->addSolution(new ModRemoveSolution($this->getModName())); break; } - $this->addSolution((new ModInstallDifferentVersionSolution())->setModName($this->getModName())); + $this->addSolution(new ModInstallDifferentVersionSolution($this->getModName())); } /** diff --git a/src/Analysis/Problem/Forge/ModWrongMinecraftVersionProblem.php b/src/Analysis/Problem/Forge/ModWrongMinecraftVersionProblem.php index 01be8ea4..8921ae02 100644 --- a/src/Analysis/Problem/Forge/ModWrongMinecraftVersionProblem.php +++ b/src/Analysis/Problem/Forge/ModWrongMinecraftVersionProblem.php @@ -60,7 +60,7 @@ public function setMatches(array $matches, mixed $patternKey): void $this->modName = $matches[1]; $this->minecraftVersion = $matches[2]; - $this->addSolution((new ModRemoveSolution())->setModName($this->getModName())); - $this->addSolution((new ForgeInstallDifferentVersionSolution())); + $this->addSolution(new ModRemoveSolution($this->getModName())); + $this->addSolution(new ForgeInstallDifferentVersionSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/MultipleModulesExportProblem.php b/src/Analysis/Problem/Forge/MultipleModulesExportProblem.php index 81376715..8112f56c 100644 --- a/src/Analysis/Problem/Forge/MultipleModulesExportProblem.php +++ b/src/Analysis/Problem/Forge/MultipleModulesExportProblem.php @@ -46,9 +46,9 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->modName = $matches[1]; - $this->addSolution((new ModRemoveSolution())->setModName($this->modName)); + $this->addSolution(new ModRemoveSolution($this->modName)); $this->secondModName = $matches[2]; - $this->addSolution((new ModRemoveSolution())->setModName($this->secondModName)); + $this->addSolution(new ModRemoveSolution($this->secondModName)); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/PTRLibDependencyProblem.php b/src/Analysis/Problem/Forge/PTRLibDependencyProblem.php index 45a693c4..2bb0315b 100644 --- a/src/Analysis/Problem/Forge/PTRLibDependencyProblem.php +++ b/src/Analysis/Problem/Forge/PTRLibDependencyProblem.php @@ -35,6 +35,6 @@ public static function getPatterns(): array public function setMatches(array $matches, mixed $patternKey): void { $this->modName = "PTRLib"; - $this->addSolution((new ModInstallSolution())->setModName($this->modName)); + $this->addSolution(new ModInstallSolution($this->modName)); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/WorldMissingModProblem.php b/src/Analysis/Problem/Forge/WorldMissingModProblem.php index 3ebcb7b8..c675e8c8 100644 --- a/src/Analysis/Problem/Forge/WorldMissingModProblem.php +++ b/src/Analysis/Problem/Forge/WorldMissingModProblem.php @@ -46,7 +46,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->modName = $matches[1]; - $this->addSolution((new ModInstallSolution())->setModName($this->getModName())); - $this->addSolution((new DoNothingSolution())); + $this->addSolution(new ModInstallSolution($this->getModName())); + $this->addSolution(new DoNothingSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Forge/WorldModVersionProblem.php b/src/Analysis/Problem/Forge/WorldModVersionProblem.php index 2fa5da7c..bd1d35a0 100644 --- a/src/Analysis/Problem/Forge/WorldModVersionProblem.php +++ b/src/Analysis/Problem/Forge/WorldModVersionProblem.php @@ -55,8 +55,8 @@ public function setMatches(array $matches, mixed $patternKey): void $this->expectedVersion = $matches[2]; $this->currentVersion = $matches[3]; - $this->addSolution((new ModInstallSolution())->setModName($this->getModName())->setModVersion($this->getExpectedVersion())); - $this->addSolution((new DoNothingSolution())); + $this->addSolution(new ModInstallSolution($this->getModName(), $this->getExpectedVersion())); + $this->addSolution(new DoNothingSolution()); } /** diff --git a/src/Analysis/Problem/Paper/ApiVersionLowerThanAllowedProblem.php b/src/Analysis/Problem/Paper/ApiVersionLowerThanAllowedProblem.php index 3c72bed3..9c71c416 100644 --- a/src/Analysis/Problem/Paper/ApiVersionLowerThanAllowedProblem.php +++ b/src/Analysis/Problem/Paper/ApiVersionLowerThanAllowedProblem.php @@ -46,7 +46,7 @@ public function setMatches(array $matches, mixed $patternKey): void parent::setMatches($matches, $patternKey); $this->pluginApiVersion = $matches[3]; - $this->addSolution((new ChangeMinimumAllowedApiVersionSolution())->setApiVersion($this->getPluginApiVersion())); + $this->addSolution(new ChangeMinimumAllowedApiVersionSolution($this->getPluginApiVersion())); } /** diff --git a/src/Analysis/Problem/Pocketmine/PluginDependencyProblem.php b/src/Analysis/Problem/Pocketmine/PluginDependencyProblem.php index 35b0b339..f40e265c 100644 --- a/src/Analysis/Problem/Pocketmine/PluginDependencyProblem.php +++ b/src/Analysis/Problem/Pocketmine/PluginDependencyProblem.php @@ -60,7 +60,7 @@ public function setMatches(array $matches, mixed $patternKey): void $this->pluginName = $matches[1]; $this->dependencyPluginName = $matches[2]; - $this->addSolution((new PluginInstallSolution())->setPluginName($this->getDependencyPluginName())); - $this->addSolution((new PluginRemoveSolution())->setPluginName($this->getPluginName())); + $this->addSolution(new PluginInstallSolution($this->getDependencyPluginName())); + $this->addSolution(new PluginRemoveSolution($this->getPluginName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Pocketmine/PluginIncompatibleProblem.php b/src/Analysis/Problem/Pocketmine/PluginIncompatibleProblem.php index c04216d1..0989f2dc 100644 --- a/src/Analysis/Problem/Pocketmine/PluginIncompatibleProblem.php +++ b/src/Analysis/Problem/Pocketmine/PluginIncompatibleProblem.php @@ -49,7 +49,7 @@ public function setMatches(array $matches, mixed $patternKey): void { $this->pluginName = $matches[1]; - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); - $this->addSolution((new PluginRemoveSolution())->setPluginName($this->getPluginName())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); + $this->addSolution(new PluginRemoveSolution($this->getPluginName())); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Pocketmine/PluginRuntimeProblem.php b/src/Analysis/Problem/Pocketmine/PluginRuntimeProblem.php index a6362568..67bcb859 100644 --- a/src/Analysis/Problem/Pocketmine/PluginRuntimeProblem.php +++ b/src/Analysis/Problem/Pocketmine/PluginRuntimeProblem.php @@ -45,8 +45,8 @@ public function setMatches(array $matches, $patternKey): void $this->pluginPath = $matches[1]; $this->pluginName = $matches[2]; - $this->addSolution((new FileDeleteSolution())->setRelativePath($this->getPluginPath())); - $this->addSolution((new PluginInstallDifferentVersionSolution())->setPluginName($this->getPluginName())); + $this->addSolution(new FileDeleteSolution($this->getPluginPath())); + $this->addSolution(new PluginInstallDifferentVersionSolution($this->getPluginName())); } /** diff --git a/src/Analysis/Problem/Vanilla/MalformedEncodingProblem.php b/src/Analysis/Problem/Vanilla/MalformedEncodingProblem.php index 8986d05c..7556fddf 100644 --- a/src/Analysis/Problem/Vanilla/MalformedEncodingProblem.php +++ b/src/Analysis/Problem/Vanilla/MalformedEncodingProblem.php @@ -43,6 +43,6 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new ChangeMOTDSolution())); + $this->addSolution(new ChangeMOTDSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Vanilla/OldPlayerDirectoryProblem.php b/src/Analysis/Problem/Vanilla/OldPlayerDirectoryProblem.php index 51b21cee..9af03e9a 100644 --- a/src/Analysis/Problem/Vanilla/OldPlayerDirectoryProblem.php +++ b/src/Analysis/Problem/Vanilla/OldPlayerDirectoryProblem.php @@ -43,6 +43,6 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new FileDeleteSolution())->setRelativePath('world/players')); + $this->addSolution(new FileDeleteSolution("world/players")); } } \ No newline at end of file diff --git a/src/Analysis/Problem/Vanilla/TickingBlockEntityProblem.php b/src/Analysis/Problem/Vanilla/TickingBlockEntityProblem.php index 325a1257..493f3a47 100644 --- a/src/Analysis/Problem/Vanilla/TickingBlockEntityProblem.php +++ b/src/Analysis/Problem/Vanilla/TickingBlockEntityProblem.php @@ -44,7 +44,7 @@ public static function getPatterns(): array */ public function setMatches(array $matches, mixed $patternKey): void { - $this->addSolution((new GenerateNewWorldSolution())); - $this->addSolution((new BlockRemoveSolution())); + $this->addSolution(new GenerateNewWorldSolution()); + $this->addSolution(new BlockRemoveSolution()); } } \ No newline at end of file diff --git a/src/Analysis/Solution/Bukkit/Plugin/AuthMeShutdownSolution.php b/src/Analysis/Solution/Bukkit/Plugin/AuthMeShutdownSolution.php index 98ff5ce9..d8d88bea 100644 --- a/src/Analysis/Solution/Bukkit/Plugin/AuthMeShutdownSolution.php +++ b/src/Analysis/Solution/Bukkit/Plugin/AuthMeShutdownSolution.php @@ -3,6 +3,7 @@ namespace Aternos\Codex\Minecraft\Analysis\Solution\Bukkit\Plugin; use Aternos\Codex\Minecraft\Analysis\Solution\File\FileEditSolution; +use Aternos\Codex\Minecraft\Analysis\Solution\File\FilePathType; use Aternos\Codex\Minecraft\Translator\Translator; /** @@ -12,10 +13,15 @@ */ class AuthMeShutdownSolution extends FileEditSolution { - protected ?string $path = 'plugins/AuthMe/config.yml'; - protected bool $relativePath = true; - protected ?string $pattern = '/^(\s+)stopServer\: true$/'; - protected ?string $replacement = '$1stopServer: false'; + public function __construct( + string $path = 'plugins/AuthMe/config.yml', + FilePathType $type = FilePathType::RELATIVE, + string $pattern = '/^(\s+)stopServer\: true$/', + string $replacement = '$1stopServer: false' + ) + { + parent::__construct($path, $type, $pattern, $replacement); + } /** * @return string diff --git a/src/Analysis/Solution/Bukkit/PluginConfigureSolution.php b/src/Analysis/Solution/Bukkit/PluginConfigureSolution.php index 12a7862b..69894435 100644 --- a/src/Analysis/Solution/Bukkit/PluginConfigureSolution.php +++ b/src/Analysis/Solution/Bukkit/PluginConfigureSolution.php @@ -11,7 +11,10 @@ */ class PluginConfigureSolution extends PluginSolution { - protected ?string $suggestedFile = null; + public function __construct(string $pluginName, protected ?string $suggestedFile = null) + { + parent::__construct($pluginName); + } /** * Get the solution as a human-readable message diff --git a/src/Analysis/Solution/Bukkit/PluginSolution.php b/src/Analysis/Solution/Bukkit/PluginSolution.php index 7021bdd9..a8b53898 100644 --- a/src/Analysis/Solution/Bukkit/PluginSolution.php +++ b/src/Analysis/Solution/Bukkit/PluginSolution.php @@ -9,12 +9,17 @@ */ abstract class PluginSolution extends BukkitSolution { - protected ?string $pluginName = null; + /** + * @param string $pluginName + */ + public function __construct(protected string $pluginName) + { + } /** - * @return string|null + * @return string */ - public function getPluginName(): ?string + public function getPluginName(): string { return $this->pluginName; } diff --git a/src/Analysis/Solution/Bukkit/ServerInstallDifferentVersionSolution.php b/src/Analysis/Solution/Bukkit/ServerInstallDifferentVersionSolution.php index c5ce8619..9eb3d4ca 100644 --- a/src/Analysis/Solution/Bukkit/ServerInstallDifferentVersionSolution.php +++ b/src/Analysis/Solution/Bukkit/ServerInstallDifferentVersionSolution.php @@ -6,7 +6,12 @@ class ServerInstallDifferentVersionSolution extends BukkitSolution { - protected ?string $softwareVersion = null; + /** + * @param string $softwareVersion + */ + public function __construct(protected string $softwareVersion) + { + } /** * Returns the suggested server software version that should be installed. diff --git a/src/Analysis/Solution/CommandRunSolution.php b/src/Analysis/Solution/CommandRunSolution.php index ecd9eed9..cde60172 100644 --- a/src/Analysis/Solution/CommandRunSolution.php +++ b/src/Analysis/Solution/CommandRunSolution.php @@ -12,7 +12,12 @@ */ class CommandRunSolution extends MinecraftSolution implements AutomatableSolutionInterface { - protected ?string $command = null; + /** + * @param string $command + */ + public function __construct(protected string $command) + { + } /** * Get the solution as a human-readable message @@ -25,9 +30,9 @@ public function getMessage(): string } /** - * @return string|null + * @return string */ - public function getCommand(): ?string + public function getCommand(): string { return $this->command; } diff --git a/src/Analysis/Solution/CrashReport/RemoveEntitySolution.php b/src/Analysis/Solution/CrashReport/RemoveEntitySolution.php index e7e347c3..1505e776 100644 --- a/src/Analysis/Solution/CrashReport/RemoveEntitySolution.php +++ b/src/Analysis/Solution/CrashReport/RemoveEntitySolution.php @@ -11,13 +11,27 @@ */ class RemoveEntitySolution extends CrashReportSolution { - protected ?string $name; - protected ?string $type; - protected ?float $locationX; - protected ?float $locationY; - protected ?float $locationZ; - protected ?string $dimension = null; - protected ?string $levelName = null; + /** + * @param string|null $name + * @param string|null $type + * @param float|null $locationX + * @param float|null $locationY + * @param float|null $locationZ + * @param string|null $dimension + * @param string|null $levelName + */ + public function __construct( + protected ?string $name = null, + protected ?string $type = null, + protected ?float $locationX = null, + protected ?float $locationY = null, + protected ?float $locationZ = null, + protected ?string $dimension = null, + protected ?string $levelName = null + ) + { + } + /** * @inheritDoc @@ -26,7 +40,7 @@ public function getMessage(): string { return Translator::getInstance()->getTranslation("remove-entity-solution", [ "name" => $this->getName(), - "location" => $this->getLocationX() . ", " . $this->getLocationY() . ", " . $this->getLocationZ() + "location" => sprintf("%s, %s, %s", $this->getLocationX(), $this->getLocationY(), $this->getLocationZ()) ]); } diff --git a/src/Analysis/Solution/File/FileEditSolution.php b/src/Analysis/Solution/File/FileEditSolution.php index f729a48c..232ae922 100644 --- a/src/Analysis/Solution/File/FileEditSolution.php +++ b/src/Analysis/Solution/File/FileEditSolution.php @@ -12,8 +12,23 @@ */ class FileEditSolution extends FileSolution implements AutomatableSolutionInterface { - protected ?string $pattern = null; - protected ?string $replacement = null; + + /** + * @param string $path The relative path (without a starting slash) or absolute path to the file. + * If the path is relative, it will be treated as relative to the Minecraft server root directory. + * @param FilePathType $type Is the path relative or absolute? + * @param string $pattern The regex pattern to search for in the file content. + * @param string $replacement The replacement string for the matched pattern. + */ + public function __construct( + string $path, + FilePathType $type = FilePathType::RELATIVE, + protected string $pattern, + protected string $replacement + ) + { + parent::__construct($path, $type); + } /** * Get the solution as a human-readable message diff --git a/src/Analysis/Solution/File/FilePathType.php b/src/Analysis/Solution/File/FilePathType.php new file mode 100644 index 00000000..e4c07fb2 --- /dev/null +++ b/src/Analysis/Solution/File/FilePathType.php @@ -0,0 +1,9 @@ +path = $path; - $this->relativePath = true; + $this->type = FilePathType::RELATIVE; return $this; } @@ -38,13 +46,12 @@ public function setRelativePath(string $path): static public function setAbsolutePath(string $path): static { $this->path = $path; - $this->relativePath = false; + $this->type = FilePathType::ABSOLUTE; return $this; } /** * Get the path - * * If isRelative() the path is relative to the Minecraft server root directory without a starting slash * * @return string @@ -55,15 +62,24 @@ public function getPath(): string } /** - * Check if the path is relative + * Get the type of the path (absolute or relative) * + * @return FilePathType + */ + public function getType(): FilePathType + { + return $this->type; + } + + /** + * Check if the path is relative * The path is relative to the Minecraft server root directory without a starting slash * * @return bool */ - public function isRelativePath(): bool + public function isRelative(): bool { - return $this->relativePath; + return $this->getType() === FilePathType::RELATIVE; } /** @@ -73,6 +89,6 @@ public function isRelativePath(): bool */ public function isAbsolutePath(): bool { - return !$this->relativePath; + return $this->getType() === FilePathType::ABSOLUTE; } } \ No newline at end of file diff --git a/src/Analysis/Solution/Forge/ModInstallSolution.php b/src/Analysis/Solution/Forge/ModInstallSolution.php index bd85dac5..ac19013c 100644 --- a/src/Analysis/Solution/Forge/ModInstallSolution.php +++ b/src/Analysis/Solution/Forge/ModInstallSolution.php @@ -11,7 +11,15 @@ */ class ModInstallSolution extends ModSolution { - protected ?string $modVersion = null; + + /** + * @param string $modName + * @param string|null $modVersion + */ + public function __construct(string $modName, protected ?string $modVersion = null) + { + parent::__construct($modName); + } /** * Get the solution as a human-readable message diff --git a/src/Analysis/Solution/Forge/ModSolution.php b/src/Analysis/Solution/Forge/ModSolution.php index bd6d0c73..4dd04de4 100644 --- a/src/Analysis/Solution/Forge/ModSolution.php +++ b/src/Analysis/Solution/Forge/ModSolution.php @@ -9,12 +9,17 @@ */ abstract class ModSolution extends ForgeSolution { - protected ?string $modName = null; + /** + * @param string $modName + */ + public function __construct(protected string $modName) + { + } /** - * @return string|null + * @return string */ - public function getModName(): ?string + public function getModName(): string { return $this->modName; } diff --git a/src/Analysis/Solution/Paper/ChangeMinimumAllowedApiVersionSolution.php b/src/Analysis/Solution/Paper/ChangeMinimumAllowedApiVersionSolution.php index f4e62b64..d6871616 100644 --- a/src/Analysis/Solution/Paper/ChangeMinimumAllowedApiVersionSolution.php +++ b/src/Analysis/Solution/Paper/ChangeMinimumAllowedApiVersionSolution.php @@ -12,12 +12,17 @@ class ChangeMinimumAllowedApiVersionSolution extends PaperSolution { - protected ?string $apiVersion = null; + /** + * @param string $apiVersion + */ + public function __construct(protected string $apiVersion) + { + } /** - * @return string|null + * @return string */ - public function getApiVersion(): ?string + public function getApiVersion(): string { return $this->apiVersion; } diff --git a/src/Analysis/Solution/Pocketmine/PluginSolution.php b/src/Analysis/Solution/Pocketmine/PluginSolution.php index d86bbdc1..29914b39 100644 --- a/src/Analysis/Solution/Pocketmine/PluginSolution.php +++ b/src/Analysis/Solution/Pocketmine/PluginSolution.php @@ -9,7 +9,12 @@ */ abstract class PluginSolution extends PocketmineSolution { - protected ?string $pluginName = null; + /** + * @param string $pluginName + */ + public function __construct(protected string $pluginName) + { + } /** * @param string $pluginName @@ -22,9 +27,9 @@ public function setPluginName(string $pluginName): static } /** - * @return string|null + * @return string */ - public function getPluginName(): ?string + public function getPluginName(): string { return $this->pluginName; } diff --git a/src/Analysis/Solution/UpdateJavaSolution.php b/src/Analysis/Solution/UpdateJavaSolution.php index 515ebe73..c688600f 100644 --- a/src/Analysis/Solution/UpdateJavaSolution.php +++ b/src/Analysis/Solution/UpdateJavaSolution.php @@ -11,7 +11,12 @@ */ class UpdateJavaSolution extends MinecraftSolution { - protected ?string $version = null; + /** + * @param string $version + */ + public function __construct(protected string $version) + { + } /** * Get the solution as a human-readable message @@ -24,9 +29,9 @@ public function getMessage(): string } /** - * @return string|null + * @return string */ - public function getVersion(): ?string + public function getVersion(): string { return $this->version; } diff --git a/src/Analysis/Solution/Vanilla/WorldRepairSolution.php b/src/Analysis/Solution/Vanilla/WorldRepairSolution.php index 2c75254e..22b208bc 100644 --- a/src/Analysis/Solution/Vanilla/WorldRepairSolution.php +++ b/src/Analysis/Solution/Vanilla/WorldRepairSolution.php @@ -11,7 +11,12 @@ */ class WorldRepairSolution extends VanillaSolution { - protected ?string $worldName = null; + /** + * @param string $worldName + */ + public function __construct(protected string $worldName) + { + } /** * Get the solution as a human-readable message @@ -34,9 +39,9 @@ public function setWorldName(string $worldName): static } /** - * @return string|null + * @return string */ - public function getWorldName(): ?string + public function getWorldName(): string { return $this->worldName; }