Skip to content

Commit bdad4fa

Browse files
authored
Merge pull request #141 from aternosorg/failed-to-parse-from-pack-problem
Detect problem when parsing of datapack fails
2 parents 0adcde5 + 2bda146 commit bdad4fa

File tree

6 files changed

+14703
-1
lines changed

6 files changed

+14703
-1
lines changed

lang/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
"auth-server-problem": "The Mojang/Microsoft authentication servers are currently unreachable!",
9494
"auth-server-solution": "Wait a few minutes and try again. If the issue persists, check the official Mojang/Microsoft channels for any known authentication server problems.",
9595
"overworld-settings-missing-problem": "Overworld settings missing",
96-
"missing-datapack-mod-problem": "Datapack is missing, because the mod '{{mod-name}}' may not be installed."
96+
"missing-datapack-mod-problem": "Datapack is missing, because the mod '{{mod-name}}' may not be installed.",
97+
"datapack-parsing-problem": "The datapack '{{datapack}}' could not be parsed."
9798
}

src/Analyser/VanillaAnalyser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\AquaticWorldOnOlderVersionProblem;
77
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\AuthServerProblem;
88
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\CodeOfConductFolderMissingProblem;
9+
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\DatapackParsingProblem;
910
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\MalformedEncodingProblem;
1011
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\OldPlayerDirectoryProblem;
1112
use Aternos\Codex\Minecraft\Analysis\Problem\Vanilla\OverworldSettingsMissingProblem;
@@ -18,6 +19,7 @@ public function __construct()
1819
$this->addPossibleInsightClass(AquaticWorldOnOlderVersionProblem::class);
1920
$this->addPossibleInsightClass(AuthServerProblem::class);
2021
$this->addPossibleInsightClass(CodeOfConductFolderMissingProblem::class);
22+
$this->addPossibleInsightClass(DatapackParsingProblem::class);
2123
$this->addPossibleInsightClass(MalformedEncodingProblem::class);
2224
$this->addPossibleInsightClass(OldPlayerDirectoryProblem::class);
2325
$this->addPossibleInsightClass(OverworldSettingsMissingProblem::class);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Aternos\Codex\Minecraft\Analysis\Problem\Vanilla;
4+
5+
use Aternos\Codex\Minecraft\Analysis\Solution\File\FileDeleteSolution;
6+
use Aternos\Codex\Minecraft\Translator\Translator;
7+
8+
class DatapackParsingProblem extends VanillaProblem
9+
{
10+
protected string $datapack;
11+
12+
/**
13+
* @inheritDoc
14+
*/
15+
public function getMessage(): string
16+
{
17+
return Translator::getInstance()->getTranslation("datapack-parsing-problem", [
18+
"datapack" => $this->getDatapack()
19+
]);
20+
}
21+
22+
/**
23+
* @inheritDoc
24+
*/
25+
public static function getPatterns(): array
26+
{
27+
return ['/java.lang.IllegalStateException: Failed to parse .+ from pack file\/(.*)/'];
28+
}
29+
30+
/**
31+
* @inheritDoc
32+
*/
33+
public function setMatches(array $matches, mixed $patternKey): void
34+
{
35+
$this->datapack = $matches[1];
36+
$this->addSolution(new FileDeleteSolution($this->datapack));
37+
}
38+
39+
public function getDatapack(): string
40+
{
41+
return $this->datapack;
42+
}
43+
}

0 commit comments

Comments
 (0)