Skip to content

Commit

Permalink
Merge pull request #44 from aternosorg/custom-skin-loader
Browse files Browse the repository at this point in the history
Add support for logs by CustomSkinLoader
  • Loading branch information
JulianVennen authored Jan 20, 2023
2 parents 5240560 + 611708f commit 3462068
Show file tree
Hide file tree
Showing 12 changed files with 1,025 additions and 197 deletions.
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"magma-version": "Magma version",
"mohist-version": "Mohist version",
"arclight-version": "Arclight version",
"custom-skin-loader-version": "Custom Skin Loader version",
"authme-shutdown-problem": "The plugin 'AuthMe' fails to load and shuts the server down.",
"pex-config-problem": "The configuration of the plugin 'PermissionsEx' is invalid.",
"ambiguous-plugin-name-problem": "There are multiple plugin files for the plugin name '{{plugin-name}}': '{{first-plugin-path}}' and '{{second-plugin-path}}'.",
Expand Down
17 changes: 17 additions & 0 deletions src/Analyser/CustomSkinLoaderAnalyser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Aternos\Codex\Minecraft\Analyser;

use Aternos\Codex\Minecraft\Analysis\Information\CustomSkinLoader\CustomSkinLoaderJavaVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\CustomSkinLoader\CustomSkinLoaderMinecraftVersionInformation;
use Aternos\Codex\Minecraft\Analysis\Information\CustomSkinLoader\CustomSkinLoaderVersionInformation;

class CustomSkinLoaderAnalyser extends MinecraftAnalyser
{
public function __construct()
{
$this->addPossibleInsightClass(CustomSkinLoaderVersionInformation::class);
$this->addPossibleInsightClass(CustomSkinLoaderJavaVersionInformation::class);
$this->addPossibleInsightClass(CustomSkinLoaderMinecraftVersionInformation::class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

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

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

abstract class CustomSkinLoaderInformation extends MinecraftInformation
{

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

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

use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;
use Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader\CustomSkinLoaderLog;
use Aternos\Codex\Minecraft\Translator\Translator;

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

/**
* 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 [ '/^' . CustomSkinLoaderLog::getPrefixPattern() . 'Java Version: ([0-9\.]+(?:_\d+)?)/'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

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

use Aternos\Codex\Minecraft\Analysis\Information\Vanilla\VanillaVersionInformation;
use Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader\CustomSkinLoaderLog;
use Aternos\Codex\Minecraft\Translator\Translator;

class CustomSkinLoaderMinecraftVersionInformation extends CustomSkinLoaderInformation
{
public function __construct()
{
$this->label = Translator::getInstance()->getTranslation("minecraft-version");
}

/**
* 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 [ '/^' . CustomSkinLoaderLog::getPrefixPattern() . 'Minecraft: (' . VanillaVersionInformation::getVersionPattern() . ')$/'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

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

use Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader\CustomSkinLoaderLog;
use Aternos\Codex\Minecraft\Translator\Translator;

class CustomSkinLoaderVersionInformation extends CustomSkinLoaderInformation
{
public function __construct()
{
$this->label = Translator::getInstance()->getTranslation("custom-skin-loader-version");
}

/**
* 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 [ '/^' . CustomSkinLoaderLog::getPrefixPattern() . 'CustomSkinLoader ([\d.]+)$/'];
}
}
4 changes: 3 additions & 1 deletion src/Detective/Detective.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Aternos\Codex\Minecraft\Log\Minecraft\Bedrock\BedrockServerLog;
use Aternos\Codex\Minecraft\Log\Minecraft\BungeeCord\BungeeCordProxyLog;
use Aternos\Codex\Minecraft\Log\Minecraft\BungeeCord\Waterfall\WaterFallProxyLog;
use Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader\CustomSkinLoaderClientLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Geyser\GeyserProxyLog;
use Aternos\Codex\Minecraft\Log\Minecraft\MinecraftLog;
use Aternos\Codex\Minecraft\Log\Minecraft\Pocketmine\PocketmineServerLog;
Expand Down Expand Up @@ -83,7 +84,8 @@ class Detective extends \Aternos\Codex\Detective\Detective
MohistCrashReportLog::class,
ArclightCrashReportLog::class,

PrismLauncherClientLog::class
PrismLauncherClientLog::class,
CustomSkinLoaderClientLog::class,
];

/**
Expand Down
18 changes: 18 additions & 0 deletions src/Log/Minecraft/CustomSkinLoader/CustomSkinLoaderClientLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader;

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

class CustomSkinLoaderClientLog extends CustomSkinLoaderLog implements ClientLogTypeInterface
{
/**
* @return DetectorInterface[]
*/
public static function getDetectors(): array
{
return [(new SinglePatternDetector())->setPattern("/^\[\d{4}(?:\-\d\d){2} (?:[0-9]{2}\:?){3}\] \[Render thread INFO\] CustomSkinLoader [\d\.]+$/m")];
}
}
50 changes: 50 additions & 0 deletions src/Log/Minecraft/CustomSkinLoader/CustomSkinLoaderLog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader;

use Aternos\Codex\Analyser\AnalyserInterface;
use Aternos\Codex\Minecraft\Analyser\CustomSkinLoaderAnalyser;
use Aternos\Codex\Minecraft\Parser\Parser;

/**
* Class CustomSkinLoaderLog
*
* @package Aternos\Codex\Minecraft\Log\Minecraft\CustomSkinLoader
*/
abstract class CustomSkinLoaderLog extends \Aternos\Codex\Minecraft\Log\Minecraft\MinecraftLog
{
protected static string $prefixPattern = '\[\d{4}(?:\-\d\d){2} (?:[0-9]{2}\:?){3}\] \[[^\]]+ [A-Z]+\] ';
protected static string $pattern = '/^(\[(\d{4}(?:\-\d\d){2} (?:[0-9]{2}\:?){3})\] \[[^\]]+ ([A-Z]+)\]) .*$/';

/**
* @return Parser
*/
public static function getDefaultParser(): Parser
{
return (new Parser())
->setPattern(static::$pattern)
->setTimeFormat('Y-m-d H:i:s')
->setMatches([Parser::PREFIX, Parser::TIME, Parser::LEVEL]);;
}

public static function getDefaultAnalyser(): AnalyserInterface
{
return new CustomSkinLoaderAnalyser();
}

/**
* @return string
*/
public function getName(): string
{
return "Custom Skin Loader";
}

/**
* @return string
*/
public static function getPrefixPattern(): string
{
return static::$prefixPattern;
}
}
Loading

0 comments on commit 3462068

Please sign in to comment.