Skip to content

Commit

Permalink
Merge pull request #68 from KurtThiemann/master
Browse files Browse the repository at this point in the history
Detect Mod File needs language provider problem
  • Loading branch information
matthi4s authored Apr 5, 2024
2 parents 278a8b8 + ece7cf7 commit bb73fa6
Show file tree
Hide file tree
Showing 8 changed files with 1,887 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@
"type-proxy": "Proxy Log",
"type-content": "Content Log",
"type-crash-report": "Crash Report",
"type-unknown": "Unknown Log"
}
"type-unknown": "Unknown Log",
"forge-language-provider-version-problem": "The mod '{{mod-file}}' requires '{{required-version}}', but '{{found-version}}' is installed."
}
4 changes: 3 additions & 1 deletion src/Analyser/ForgeAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Aternos\Codex\Minecraft\Analysis\Information\Forge\ForgeVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\FmlConfirmProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\LanguageProviderVersionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ModDependencyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ModDuplicateProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\ModExceptionProblem;
Expand Down Expand Up @@ -41,5 +42,6 @@ public function __construct()
$this->addPossibleInsightClass(ModWrongMinecraftVersionProblem::class);
$this->addPossibleInsightClass(PTRLibDependencyProblem::class);
$this->addPossibleInsightClass(MultipleModulesExportProblem::class);
$this->addPossibleInsightClass(LanguageProviderVersionProblem::class);
}
}
}
55 changes: 55 additions & 0 deletions src/Analysis/Problem/Forge/LanguageProviderVersionProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

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

use Aternos\Codex\Minecraft\Analysis\Solution\Forge\ForgeInstallDifferentVersionSolution;
use Aternos\Codex\Minecraft\Analysis\Solution\Forge\ModRemoveSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

class LanguageProviderVersionProblem extends ModProblem
{
protected string $languageProvider = "";
protected string $requiredVersion = "";
protected string $foundVersion = "";

/**
* @inheritDoc
*/
public function getMessage(): string
{
$provider = $this->languageProvider;
if ($provider === "javafml") {
$provider = "Forge";
}
return Translator::getInstance()->getTranslation("forge-language-provider-version-problem",
[
"mod-file" => $this->getModName(),
"required-version" => $provider . " " . $this->requiredVersion,
"found-version" => $this->foundVersion
]);
}

/**
* @inheritDoc
*/
public static function getPatterns(): array
{
return [
"/Mod File ([^\/\n]+) needs language provider ([\w-]+):(.*?) to load[\n\s§\da-f]*We have found (\d+)/"
];
}

/**
* @inheritDoc
*/
public function setMatches(array $matches, mixed $patternKey): void
{
$this->modName = $matches[1];
$this->languageProvider = $matches[2];
$this->requiredVersion = $matches[3];
$this->foundVersion = $matches[4];

$this->addSolution((new ModRemoveSolution())->setModName($this->getModName()));
$this->addSolution((new ForgeInstallDifferentVersionSolution()));
}
}
Loading

0 comments on commit bb73fa6

Please sign in to comment.