aternos / codex-minecraft
PHP 库,用于读取、解析、打印和分析 Minecraft 日志文件。
Requires
- php: >=8.1.0
- ext-json: *
- aternos/codex: ^2.1.1
Requires (Dev)
- phpunit/phpunit: ^10.2
- dev-master
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.2
- v3.0.1
- v3.0.0
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.1
- v2.0.0
- v1.13.1
- v1.13.0
- v1.12.1
- v1.12.0
- v1.11.4
- v1.11.3
- v1.11.2
- v1.11.1
- v1.11.0
- v1.10.1
- v1.10.0
- v1.9.0
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.2
- v1.1.1
- v1.0.1
- v1.0.0
- v0.4.0
- v0.3.0
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.1
- v0.1.0
- dev-neovanilla
- dev-use-multi-pattern-detector
This package is auto-updated.
Last update: 2024-09-23 11:24:43 UTC
README
关于
Codex (拉丁语中意为“日志”) 是一个 PHP 库,用于读取、解析、打印和分析日志文件以查找问题并提出可能的解决方案。这是针对 Minecraft 日志的实现,包括检测器、解析器和分析器,用于处理不同类型的 Minecraft 日志文件。
安装
composer require aternos/codex-minecraft
用法
这仅是 Codex 在 Minecraft 中的实现的简介,更多详细信息请查看 Codex 仓库:aternosorg/codex
创建日志文件
[见 codex#logfile]
<?php $logFile = new \Aternos\Codex\Log\File\StringLogFile("This is the log content"); $logFile = new \Aternos\Codex\Log\File\PathLogFile("/path/to/log"); $logFile = new \Aternos\Codex\Log\File\StreamLogFile(fopen("/path/to/log", "r"));
创建日志对象
[见 codex#log]
如果您知道日志类型,您可以直接创建一个新的日志对象。
<?php $log = new \Aternos\Codex\Minecraft\Log\Minecraft\Vanilla\VanillaServerLog(); $log->setLogFile($logFile);
检测日志类型
[见 codex#detection]
如果您不知道日志类型,可以让 Detective 来决定并创建日志对象。
<?php $detective = new \Aternos\Codex\Minecraft\Detective\Detective(); $detective->setLogFile($logFile); $log = $detective->detect();
解析日志内容
[见 codex#parsing]
<?php $log->parse();
分析日志
[见 codex#analysing]
<?php $analysis = $log->analyse();
$analysis
对象包含问题和信息,您可以使用 $analysis->getProblems()
和 $analysis->getInformation()
函数获取它们,或者使用 $analysis->getInsights()
获取所有洞察。问题包含解决方案,其中一些可以自动解决。它们实现了 \Aternos\Codex\Analysis\AutomatableSolutionInterface
,例如 FileDeleteSolution
。
<?php foreach ($analysis->getInformation() as $information) { echo $information->getLabel() . ": " . $information->getValue(); } foreach ($analysis->getProblems() as $problem) { echo $problem->getMessage(); foreach($problem->getSolutions() as $solution) { echo $solution->getMessage(); } }
翻译
输出消息,例如问题和解决方案,由 Translator
翻译。可用的翻译位于 lang
文件夹中。它们还不完整(尚不完整),您可以在此处帮助翻译它们:https://crowdin.com/project/aternos。您可以在使用任何 getMessage()
函数之前使用 setLanguage()
函数设置翻译语言。
在此处查看当前翻译状态:TRANSLATION.md
<?php \Aternos\Codex\Minecraft\Translator\Translator::getInstance()->setLanguage("de");