• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

aternosorg/codex-minecraft: PHP library to read, parse, print and analyse Minecr ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

aternosorg/codex-minecraft

开源软件地址(OpenSource Url):

https://github.com/aternosorg/codex-minecraft

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

Codex for Minecraft

About

Codex (lat. roughly for "log") is a PHP library to read, parse, print and analyse log files to find problems and suggest possible solutions. This is the implementation for Minecraft server logs including detectors, parsers and analysers to work with different Minecraft server log files.

Installation

composer require aternos/codex-minecraft

Usage

This is only an introduction to the Minecraft implementation of Codex, for more information take a look at the Codex repository: aternosorg/codex

Create a log file

[see 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"));

Create log object

[see codex#log]

If you know the log type, you can directly create a new log object.

<?php

$log = new \Aternos\Codex\Minecraft\Log\VanillaLog();
$log->setLogFile($logFile);

Detect the log type

[see codex#detection]

If you don't know the log type, you can let the Detective decide and create a log object.

<?php

$detective = new \Aternos\Codex\Minecraft\Detective\Detective();
$detective->setLogFile($logFile);
$log = $detective->detect();

Parse the log content

[see codex#parsing]

<?php

$log->parse();

Analyse the log

[see codex#analysing]

<?php

$analysis = $log->analyse();

The $analysis object contains problems and information which you can get with the $analysis->getProblems() and $analysis->getInformation() functions or all insights together with $analysis->getInsights(). The problems contain solutions, a few of them could be solved automatically. They implement the \Aternos\Codex\Analysis\AutomatableSolutionInterface, e.g. 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();
    }
}

Translations

The output messages, e.g. for problems and solutions are translated by the Translator. The available translations are in the lang folder. They are not complete (yet) and you can help to translate them here: https://crowdin.com/project/aternos. You can set the translation language with the setLanguage() function before using any getMessage() function.

See the current translation status here: TRANSLATION.md

<?php

\Aternos\Codex\Minecraft\Translator\Translator::getInstance()->setLanguage("de");



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap