Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"mod-duplicate-problem-no-path": "There are multiple mod files for the mod name '{{mod-name}}'.",
"mod-exception-problem": "The mod '{{mod-name}}' has thrown an exception.",
"mod-fatal-problem": "The mod '{{mod-name}}' has a fatal error.",
"mod-invalid-dist-dedicated-server-problem": "The mod '{{mod-name}}' tries to load clientside features on a dedicated server. It is probably a clientside only mod.",
"world-missing-mod-problem": "The world was saved with mod '{{mod-name}}' which appears to be missing.",
"world-mod-version-problem": "This world was saved with mod '{{mod-name}}' version {{mod-expected-version}} and it is now at version {{mod-current-version}}.",
"plugin-incompatible-problem": "The plugin '{{plugin-name}}' is incompatible with your current server version.",
Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/NeoForgeAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeVanillaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\InvalidDistDedicatedServerProblem;

class NeoForgeAnalyser extends VanillaAnalyser
{
Expand All @@ -15,5 +16,6 @@ public function __construct()
$this->addPossibleInsightClass(NeoForgeVersionInformation::class);
$this->overridePossibleInsightClass(VanillaVersionInformation::class, NeoForgeVanillaVersionInformation::class);
$this->addPossibleInsightClass(NeoForgeJavaVersionInformation::class);
$this->addPossibleInsightClass(InvalidDistDedicatedServerProblem::class);
}
}
2 changes: 2 additions & 0 deletions src/Analyser/Report/CrashReport/ForgeCrashReportAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Aternos\Codex\Minecraft\Analyser\Report\CrashReport;

use Aternos\Codex\Minecraft\Analysis\Information\Forge\CrashReport\ForgeVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\InvalidDistDedicatedServerProblem;

/**
* Class ForgeCrashReportAnalyser
Expand All @@ -15,5 +16,6 @@ public function __construct()
{
parent::__construct();
$this->addPossibleInsightClass(ForgeVersionInformation::class);
$this->addPossibleInsightClass(InvalidDistDedicatedServerProblem::class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace Aternos\Codex\Minecraft\Analyser\Report\CrashReport;

use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Problem\Forge\InvalidDistDedicatedServerProblem;

class NeoForgeCrashReportAnalyser extends MinecraftCrashReportAnalyser
{
public function __construct()
{
parent::__construct();
$this->addPossibleInsightClass(NeoForgeVersionInformation::class);
$this->addPossibleInsightClass(InvalidDistDedicatedServerProblem::class);
}
}
84 changes: 84 additions & 0 deletions src/Analysis/Problem/Forge/InvalidDistDedicatedServerProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php

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

use Aternos\Codex\Minecraft\Analysis\Solution\File\FileDeleteSolution;
use Aternos\Codex\Minecraft\Analysis\Solution\Forge\ModInstallDifferentVersionSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

class InvalidDistDedicatedServerProblem extends ModProblem
{
protected ?string $modFileName = null;
protected ?string $modVersion = null;
protected ?string $modId = null;

/**
* Get a human-readable message
*
* @return string
*/
public function getMessage(): string
{
return Translator::getInstance()->getTranslation("mod-invalid-dist-dedicated-server-problem", ["mod-name" => $this->getModName()]);
}

/**
* Get an array of possible patterns
*
* The array key of the pattern will be passed to setMatches()
*
* @return string[]
*/
public static function getPatterns(): array
{
return [
'/^\s*Mod file: (.*)'
. '\n\s*Failure message: ([^\(\n]+) \(([^\)]+)\) has failed to load correctly'
. '\n\s*java\.lang\.BootstrapMethodError: java\.lang\.RuntimeException: '
. 'Attempted to load class [\w\/]+ for invalid dist DEDICATED_SERVER'
. '\n\s*Mod version: (.*)/'
];
}

/**
* Apply the matches from the pattern
*
* @param array $matches
* @param mixed $patternKey
* @return void
*/
public function setMatches(array $matches, mixed $patternKey): void
{
$this->modFileName = $matches[1];
$this->modName = $matches[2];
$this->modId = $matches[3];
$this->modVersion = $matches[4];

$this->addSolution((new FileDeleteSolution())->setRelativePath("mods/" . $this->getModFileName()));
$this->addSolution((new ModInstallDifferentVersionSolution())->setModName($this->getModName()));
}

/**
* @return string|null
*/
public function getModFileName(): ?string
{
return $this->modFileName;
}

/**
* @return string|null
*/
public function getModVersion(): ?string
{
return $this->modVersion;
}

/**
* @return string|null
*/
public function getModId(): ?string
{
return $this->modId;
}
}
Loading