Skip to content

Commit

Permalink
Merge pull request #77 from aternosorg/fabric-loom
Browse files Browse the repository at this point in the history
Detect Fabric loom logs
  • Loading branch information
JulianVennen authored Jun 19, 2024
2 parents 61517e0 + 715d2ab commit 7206b8a
Show file tree
Hide file tree
Showing 9 changed files with 2,334 additions and 7 deletions.
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

0 comments on commit 7206b8a

Please sign in to comment.