8000 Add NeoForge support by JulianVennen · Pull Request #65 · aternosorg/codex-minecraft · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add NeoForge support #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2024
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 @@ -7,6 +7,7 @@
"pocketmine-version": "Pocketmine version",
"bedrock-version": "Bedrock version",
"forge-version": "Forge version",
"neoforge-version": "NeoForge version",
"magma-version": "Magma version",
"mohist-version": "Mohist version",
"arclight-version": "Arclight version",
Expand Down
19 changes: 19 additions & 0 deletions src/Analyser/NeoForgeAnalyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Aternos\Codex\Minecraft\Analyser;

use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeJavaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeVanillaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\NeoForge\NeoForgeVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;

class NeoForgeAnalyser extends VanillaAnalyser
{
public function __construct()
{
parent::__construct();
$this->addPossibleInsightClass(NeoForgeVersionInformation::class);
$this->overridePossibleInsightClass(VanillaVersionInformation::class, NeoForgeVanillaVersionInformation::class);
$this->addPossibleInsightClass(NeoForgeJavaVersionInformation::class);
}
}
10 changes: 10 additions & 0 deletions src/Analysis/Information/NeoForge/NeoForgeInformation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Information\NeoForge;

use Aternos\Codex\Minecraft\Analysis\Information\MinecraftInformation;

abstract class NeoForgeInformation extends MinecraftInformation
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Information\NeoForge;

use Aternos\Codex\Minecraft\Translator\Translator;

class NeoForgeJavaVersionInformation extends NeoForgeInformation
{
public function __construct()
{
$this->label = Translator::getInstance()->getTranslation("java-version");
}

/**
* @inheritDoc
*/
public static function getPatterns(): array
{
return ['/\[cpw\.mods\.modlauncher\.Launcher\/MODLAUNCHER\]: ModLauncher(?: [\w\.+]+)? starting: java version ([0-9\._]+) by Oracle Corporation/'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Information\NeoForge;

use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;

class NeoForgeVanillaVersionInformation extends VanillaVersionInformation
{
public static function getPatterns(): array
{
return array_merge(parent::getPatterns(), [
'/NeoForge mod loading, version ('. NeoForgeVersionInformation::getVersionPattern() .'), for MC ('. static::$vanillaVersionPattern . ')/',
"/--fml\.mcVersion, (". static::$vanillaVersionPattern .")/"
]);
}
}
32 changes: 32 additions & 0 deletions src/Analysis/Information/NeoForge/NeoForgeVersionInformation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Aternos\Codex\Minecraft\Analysis\Information\NeoForge;

use Aternos\Codex\Minecraft\Translator\Translator;

class NeoForgeVersionInformation extends NeoForgeInformation
{
protected static string $versionPattern = "[0-9\.]+(-beta)?";

public function __construct()
{
$this->label = Translator::getInstance()->getTranslation("neoforge-version");
}

public static function getPatterns(): array
{
return [
'/NeoForge mod loading, version ('. static::$versionPattern .'),/',
'/--fml\.neoForgeVersion, ('. static::$versionPattern .')/'
];
}

/**
* Get the NeoForge version pattern
* @return string
*/
public static function getVersionPattern(): string
{
return static::$versionPattern;
}
}
4 changes: 4 additions & 0 deletions src/Detective/Detective.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Forge\Magma\MagmaServerLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Forge\Mohist\MohistCrashReportLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Forge\Mohist\MohistServerLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\NeoForge\NeoForgeClientLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\NeoForge\NeoForgeServerLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\OldVanillaServerLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Quilt\QuiltClientLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Quilt\QuiltServerLog;
Expand All @@ -53,6 +55,7 @@ class Detective extends \Aternos\Codex\Detective\Detective
FabricClientLog::class,
QuiltClientLog::class,
ForgeClientLog::class,
NeoForgeClientLog::class,
VanillaClientLog::class,

VanillaServerLog::class,
Expand All @@ -68,6 +71,7 @@ class Detective extends \Aternos\Codex\Detective\Detective
ArclightServerLog::class,
MagmaServerLog::class,
ForgeServerLog::class,
NeoForgeServerLog::class,
PocketmineServerLog::class,
BedrockServerLog::class,
BedrockContentLog::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Log/Minecraft/Vanilla/Forge/ForgeClientLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ForgeClientLog extends ForgeLog implements ClientLogTypeInterface
public static function getDetectors(): array
{
return [
(new SinglePatternDetector())->setPattern('/^\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: Launching target \'(fml|forge)client\' with arguments.*$/m')
(new SinglePatternDetector())->setPattern('/^\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: ModLauncher running: .*--fml.forgeVersion.*(\n.*)*\n\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: Launching target \'(fml|forge)client\' with arguments.*$/m')
];
}
}
20 changes: 20 additions & 0 deletions src/Log/Minecraft/Vanilla/NeoForge/NeoForgeClientLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\NeoForge;

use Aternos\Codex\Detective\DetectorInterface;
use Aternos\Codex\Detective\SinglePatternDetector;
use Aternos\Codex\Minecraft\Log\Type\ClientLogTypeInterface;

class NeoForgeClientLog extends NeoForgeLog implements ClientLogTypeInterface
{
/**
* @return DetectorInterface[]
*/
public static function getDetectors(): array
{
return [
(new SinglePatternDetector())->setPattern('/^\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: ModLauncher running: .*--fml.neoForgeVersion.*(\n.*)*\n\[[^\]]+\] \[main\/INFO\]( \[[^\]]+\])?: Launching target \'(fml|forge)client\' with arguments.*$/m')
];
}
}
52 changes: 52 additions & 0 deletions src/Log/Minecraft/Vanilla/NeoForge/NeoForgeLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\NeoForge;

use Aternos\Codex\Analyser\AnalyserInterface;
use Aternos\Codex\Detective\DetectorInterface;
use Aternos\Codex\Detective\SinglePatternDetector;
use Aternos\Codex\Minecraft\Analyser\NeoForgeAnalyser;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\VanillaLog;
use Aternos\Codex\Minecraft\Parser\ForgeParser;
use Aternos\Codex\Parser\ParserInterface;

abstract class NeoForgeLog extends VanillaLog
{
protected static string $pattern = '/^(\[(?:\S+ )?(?:[0-9]{2}\:?){3}(?:\.[0-9]+)?\] \[[^\]]+\/(\w+)\](?: \[([^\]]+)\])?\:).*$/';

/**
* @return DetectorInterface[]
*/
public static function getDetectors(): array
{
return array_merge(parent::getDetectors(), [
(new SinglePatternDetector())->setPattern('/NeoForge mod loading/')
]);
}

/**
* @return AnalyserInterface
*/
public static function getDefaultAnalyser(): AnalyserInterface
{
return new NeoForgeAnalyser();
}

/**
* @return ParserInterface
*/
public static function getDefaultParser(): ParserInterface
{
return (new ForgeParser())
->setPattern(static::$pattern)
->setMatches([ForgeParser::PREFIX, ForgeParser::LEVEL, ForgeParser::CHANNEL]);
}

/**
* @return string
*/
public function getName(): string
{
return "NeoForge";
}
}
10 changes: 10 additions & 0 deletions src/Log/Minecraft/Vanilla/NeoForge/NeoForgeServerLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\NeoForge;

use Aternos\Codex\Minecraft\Log\Type\ServerLogTypeInterface;

class NeoForgeServerLog extends NeoForgeLog implements ServerLogTypeInterface
{

}
Loading
0