Skip to content
Merged
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 @@ -75,6 +75,7 @@
"server-install-different-version-solution": "Install the version '{{software-version}}' of your server software.",
"plugin-api-version-problem": "The plugin '{{plugin-name}}' needs version '{{software-version}}' of your server software.",
"plugin-java-version-problem": "The plugin '{{plugin-name}}' requires Java version {{java-version}} or later to run.",
"mod-java-version-problem": "The mod '{{mod-name}}' requires Java version {{java-version}} or later to run.",
"change-java-version-solution": "Change your Java version to {{java-version}} or later.",
"ticking-entity-problem": "The entity '{{name}}' at the location {{location}} is causing issues while ticking.",
"remove-entity-solution": "Remove the entity '{{name}}' at the location {{location}}.",
Expand Down
2 changes: 2 additions & 0 deletions src/Analyser/FabricAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricMixinProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricModDependencyProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricModIncompatibleMinecraftVersionProblem;
use Aternos\Codex\Minecraft\Analysis\Problem\Fabric\FabricModJavaVersionProblem;

class FabricAnalyser extends VanillaAnalyser
{
Expand All @@ -24,6 +25,7 @@ public function __construct()
$this->addPossibleInsightClass(FabricJavaVersionInformation::class);
$this->addPossibleInsightClass(FabricModDependencyProblem::class);
$this->addPossibleInsightClass(FabricModIncompatibleMinecraftVersionProblem::class);
$this->addPossibleInsightClass(FabricModJavaVersionProblem::class);
$this->addPossibleInsightClass(FabricMixinProblem::class);
$this->addPossibleInsightClass(FabricIncompatibleModsProblem::class);
$this->addPossibleInsightClass(FabricDuplicateModProblem::class);
Expand Down
3 changes: 2 additions & 1 deletion src/Analysis/Problem/Fabric/FabricModDependencyProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public function getMessage(): string
public static function getPatterns(): array
{
$mod = "/- Mod " . static::getModNamePattern() . "(?: [^ ]+)? ";
$dependency = " of (?:mod )?" . static::getModNamePattern("dependency") . ",/";
// Java has its own problem, FabricModJavaVersionProblem
$dependency = " of (?:mod )?(?!" . FabricModJavaVersionProblem::JAVA_MOD . ")" . static::getModNamePattern("dependency") . ",/";

return [
'short-error' => '/net\.fabricmc\.loader\.discovery\.ModResolutionException: Could not find required mod: ' . static::getModNamePattern()
Expand Down
90 changes: 90 additions & 0 deletions src/Analysis/Problem/Fabric/FabricModJavaVersionProblem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

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

use Aternos\Codex\Analysis\InsightInterface;
use Aternos\Codex\Minecraft\Analysis\Solution\UpdateJavaSolution;
use Aternos\Codex\Minecraft\Translator\Translator;

/**
* A mod requires a different Java version.
* The Fabric Loader provides Java as a built-in mod with the id "java" and the name of the running JVM,
* so the loader reports it like any other missing mod dependency.
*/
class FabricModJavaVersionProblem extends FabricModProblem
{
/**
* The built-in Java mod, named after the running JVM
* Example: 'Java HotSpot(TM) 64-Bit Server VM' (java)
*/
public const string JAVA_MOD = "'[^']+' \(java\)";

protected string $javaVersion;

/**
* @return string
*/
public function getJavaVersion(): string
{
return $this->javaVersion;
}

/**
* @param string $javaVersion
* @return $this
*/
protected function setJavaVersion(string $javaVersion): static
{
$this->javaVersion = $javaVersion;
return $this;
}

/**
* @inheritDoc
*/
public function getMessage(): string
{
return Translator::getInstance()->getTranslation("mod-java-version-problem", [
"mod-name" => $this->getModName(),
"java-version" => $this->getJavaVersion()
]);
}

/**
* Matches a Java version requirement in the dependency list of the loader, e.g.
* - Mod 'Foo' (foo) 1.0.0 requires version 99 or later of 'Java HotSpot(TM) 64-Bit Server VM' (java), but only the wrong version is present: 25!
* - Mod 'Foo' (foo) 1.0.0 requires version 99 of 'Java HotSpot(TM) 64-Bit Server VM' (java), but only the wrong version is present: 25!
*
* @inheritDoc
*/
public static function getPatterns(): array
{
$mod = "/- Mod " . static::getModNamePattern() . "(?: [^ ]+)? ";

return [
'minimum' => $mod . "requires version (?<version>[^ ]+) or later of " . static::JAVA_MOD . "/",
'specific' => $mod . "requires version (?<version>[^ ]+) of " . static::JAVA_MOD . "/",
];
}

/**
* @inheritDoc
*/
public function setMatches(array $matches, mixed $patternKey): void
{
$this->setModName($matches["mod"]);
$this->setJavaVersion($matches["version"]);
$this->addSolution(new UpdateJavaSolution($this->getJavaVersion()));
}

/**
* @param InsightInterface $insight
* @return bool
*/
public function isEqual(InsightInterface $insight): bool
{
return $insight instanceof static
&& parent::isEqual($insight)
&& $this->getJavaVersion() === $insight->getJavaVersion();
}
}
272 changes: 272 additions & 0 deletions test/data/Vanilla/Fabric/fabric-java-version-dependency-exact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
{
"id": "fabric\/server",
"name": "Fabric",
"type": "Server Log",
"version": "26.3",
"title": "Fabric 26.3 Server Log",
"entries": [
{
"level": 6,
"time": null,
"prefix": null,
"lines": [
{
"number": 1,
"content": "Starting net.fabricmc.loader.impl.game.minecraft.BundlerClassPathCapture"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 2,
"content": "[18:57:49] [main\/INFO]: Loading Minecraft 26.3 with Fabric Loader 0.20.1"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 3,
"content": "[18:57:49] [main\/INFO]: Mappings not present!"
}
]
},
{
"level": 4,
"time": null,
"prefix": "[18:57:49] [main\/WARN]:",
"lines": [
{
"number": 4,
"content": "[18:57:49] [main\/WARN]: Mod resolution failed"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 5,
"content": "[18:57:49] [main\/INFO]: Immediate reason: [HARD_DEP_INCOMPATIBLE_PRESELECTED foo 1.0.0 {depends java @ [99]}, ROOT_FORCELOAD_SINGLE foo 1.0.0]"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 6,
"content": "[18:57:49] [main\/INFO]: Reason: [HARD_DEP foo 1.0.0 {depends java @ [99]}]"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 7,
"content": "[18:57:49] [main\/INFO]: SERVER environment disabled: [fabric-renderer-api-v1, fabric-model-loading-api-v1, fabric-key-mapping-api-v1, fabric-screen-api-v1, fabric-sound-api-v1, fabric-rendering-v1, fabric-renderer-indigo]"
}
]
},
{
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 8,
"content": "[18:57:49] [main\/INFO]: Fix: add [], remove [], replace [[java 25] -> add:java 99 ([[99,99]])]"
}
]
},
{
"level": 3,
"time": null,
"prefix": "[18:57:49] [main\/ERROR]:",
"lines": [
{
"number": 9,
"content": "[18:57:49] [main\/ERROR]: Incompatible mods found!"
},
{
"number": 10,
"content": "net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!"
},
{
"number": 11,
"content": "A potential solution has been determined, this may resolve your problem:"
},
{
"number": 12,
"content": "\t - Replace 'Java HotSpot(TM) 64-Bit Server VM' (java) 25 with version 99."
},
{
"number": 13,
"content": "More details:"
},
{
"number": 14,
"content": "\t - Mod 'Foo' (foo) 1.0.0 requires version 99 of 'Java HotSpot(TM) 64-Bit Server VM' (java), but only the wrong version is present: 25!"
},
{
"number": 15,
"content": "\tat net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51)"
},
{
"number": 16,
"content": "\tat net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:207)"
},
{
"number": 17,
"content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:142)"
},
{
"number": 18,
"content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:66)"
},
{
"number": 19,
"content": "\tat net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23)"
},
{
"number": 20,
"content": "\tat net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69)"
},
{
"number": 21,
"content": "\tat net.fabricmc.installer.ServerLauncher.main(ServerLauncher.java:69)"
},
{
"number": 22,
"content": ""
}
]
}
],
"analysis": {
"problems": [
{
"message": "The mod 'Foo' requires Java version 99 or later to run.",
"counter": 1,
"entry": {
"level": 3,
"time": null,
"prefix": "[18:57:49] [main\/ERROR]:",
"lines": [
{
"number": 9,
"content": "[18:57:49] [main\/ERROR]: Incompatible mods found!"
},
{
"number": 10,
"content": "net.fabricmc.loader.impl.FormattedException: Some of your mods are incompatible with the game or each other!"
},
{
"number": 11,
"content": "A potential solution has been determined, this may resolve your problem:"
},
{
"number": 12,
"content": "\t - Replace 'Java HotSpot(TM) 64-Bit Server VM' (java) 25 with version 99."
},
{
"number": 13,
"content": "More details:"
},
{
"number": 14,
"content": "\t - Mod 'Foo' (foo) 1.0.0 requires version 99 of 'Java HotSpot(TM) 64-Bit Server VM' (java), but only the wrong version is present: 25!"
},
{
"number": 15,
"content": "\tat net.fabricmc.loader.impl.FormattedException.ofLocalized(FormattedException.java:51)"
},
{
"number": 16,
"content": "\tat net.fabricmc.loader.impl.FabricLoaderImpl.load(FabricLoaderImpl.java:207)"
},
{
"number": 17,
"content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.init(Knot.java:142)"
},
{
"number": 18,
"content": "\tat net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:66)"
},
{
"number": 19,
"content": "\tat net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23)"
},
{
"number": 20,
"content": "\tat net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69)"
},
{
"number": 21,
"content": "\tat net.fabricmc.installer.ServerLauncher.main(ServerLauncher.java:69)"
},
{
"number": 22,
"content": ""
}
]
},
"solutions": [
{
"message": "Change your Java version to 99 or later."
}
]
}
],
"information": [
{
"message": "Minecraft version: 26.3",
"counter": 1,
"entry": {
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 2,
"content": "[18:57:49] [main\/INFO]: Loading Minecraft 26.3 with Fabric Loader 0.20.1"
}
]
},
"label": "Minecraft version",
"value": "26.3"
},
{
"message": "Fabric loader version: 0.20.1",
"counter": 1,
"entry": {
"level": 6,
"time": null,
"prefix": "[18:57:49] [main\/INFO]:",
"lines": [
{
"number": 2,
"content": "[18:57:49] [main\/INFO]: Loading Minecraft 26.3 with Fabric Loader 0.20.1"
}
]
},
"label": "Fabric loader version",
"value": "0.20.1"
}
]
}
}
Loading
Loading