Skip to content
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

Detect Fabric loom logs #77

Merged
merged 1 commit into from
Jun 19, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\Fabric\FabricLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\VanillaServerLog;
use Aternos\Codex\Minecraft\Translator\Translator;

Expand Down Expand Up @@ -30,8 +31,8 @@ public function __construct()
public static function getPatterns(): array
{
return [
'/'. VanillaServerLog::getPrefixPattern() .'\[FabricLoader\] Loading [0-9]+ mods:[\s\n](?:\s*[^,]+, ?)*(?:\s+- )?java[ @](\d+)/',
'/'. VanillaServerLog::getPrefixPattern() .'Loading [0-9]+ mods:[\s\n](?:\s*- .+\n ?)*(?:\s+- )?java[ @](\d+)/'
'/'. FabricLog::getPrefixPattern() .'[\[(]FabricLoader[\])] Loading [0-9]+ mods:[\s\n](?:\s*[^,]+, ?)*(?:\s+- )?java[ @](\d+)/',
'/'. FabricLog::getPrefixPattern() .'(?:[\[(]FabricLoader[\])] )?Loading [0-9]+ mods:[\s\n](?:\s*- .+\n ?)*(?:\s+- )?java[ @](\d+)/'
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Analysis/Information/Fabric/FabricVersionInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function __construct()
public static function getPatterns(): array
{
return [
'/'. VanillaServerLog::getPrefixPattern() .'\[FabricLoader\] Loading [0-9]+ mods: (?:\w{1,63}@[^, ]+, )*fabricloader@('. static::$fabricVersionPattern .')/',
'/'. VanillaServerLog::getPrefixPattern() .'Loading Minecraft '. VanillaVersionInformation::getVersionPattern() .' with Fabric Loader ('. static::$fabricVersionPattern .')/'
'/'. VanillaServerLog::getPrefixPattern() .'[\[(]FabricLoader[\])] Loading [0-9]+ mods: (?:\w{1,63}@[^, ]+, )*fabricloader@('. static::$fabricVersionPattern .')/',
'/'. VanillaServerLog::getPrefixPattern() .'(?:\(FabricLoader\/GameProvider\) )?Loading Minecraft '. VanillaVersionInformation::getVersionPattern() .' with Fabric Loader ('. static::$fabricVersionPattern .')/'
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Log/Minecraft/Vanilla/Fabric/FabricClientLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FabricClientLog extends FabricLog implements ClientLogTypeInterface
public static function getDetectors(): array
{
return [
(new SinglePatternDetector())->setPattern('/^\[[\d:]+\] \[main\/INFO\]: Loading Minecraft [^ \n]+ with Fabric Loader [^ \n]+(\n.*)*\n\[[\d:]+\] \[Render thread\/INFO\]: Setting user: \w+/m'),
(new SinglePatternDetector())->setPattern('#^\[[\d:]+\] \[main\/INFO\](?:\:| \(FabricLoader/GameProvider\)) Loading Minecraft [^ \n]+ with Fabric Loader [^ \n]+(\n.*)*\n\[[\d:]+\] \[(?:Render thread|main)\/INFO\](?:\:| \(Minecraft\)) Setting user: \w+#m'),
];
}
}
7 changes: 5 additions & 2 deletions src/Log/Minecraft/Vanilla/Fabric/FabricLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
*/
abstract class FabricLog extends VanillaLog
{
protected static string $pattern = '/^(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\]\:?).*$/';
protected static string $prefixPattern = '(\[(?:[0-9]{2}\:?){3}\] \[[^\/]+\/(\w+)\]\:?) ';

/**
* @return DetectorInterface[]
*/
public static function getDetectors(): array
{
return array_merge(parent::getDetectors(), [
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'Loading Minecraft '. VanillaVersionInformation::getVersionPattern() . ' with Fabric Loader/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . '\[FabricLoader\] Loading \d+ mods:/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . '(?:\(FabricLoader\/GameProvider\) )?Loading Minecraft '. VanillaVersionInformation::getVersionPattern() . ' with Fabric Loader/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . '[[(]FabricLoader[\])] Loading \d+ mods:/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'A critical error occurred\nnet.fabricmc.loader/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'Found new data pack Fabric Mods, loading it automatically$/m'),
(new SinglePatternDetector())->setPattern('/^' . static::$prefixPattern . 'Reloading ResourceManager: Default, Fabric Mods \(Fabric Tool Attribute API/m')
Expand Down
Loading
Loading