{"id":19651866,"url":"https://github.com/jgniecki/minecraftmotdparser","last_synced_at":"2025-10-15T18:21:19.907Z","repository":{"id":228348686,"uuid":"751256102","full_name":"jgniecki/MinecraftMotdParser","owner":"jgniecki","description":"🐘 PHP library to parse minecraft server motd","archived":false,"fork":false,"pushed_at":"2025-03-26T15:21:41.000Z","size":93,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T09:44:49.953Z","etag":null,"topics":["generator","mineceraft","motd","parser","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/dev-lancer/minecraft-motd-parser","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgniecki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-01T08:44:07.000Z","updated_at":"2025-03-26T15:14:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a909b32-cce3-46c1-9c9f-c039ee347ad3","html_url":"https://github.com/jgniecki/MinecraftMotdParser","commit_stats":null,"previous_names":["developerlancer/minecraftmotdparser","jgniecki/minecraftmotdparser"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/jgniecki/MinecraftMotdParser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgniecki%2FMinecraftMotdParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgniecki%2FMinecraftMotdParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgniecki%2FMinecraftMotdParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgniecki%2FMinecraftMotdParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgniecki","download_url":"https://codeload.github.com/jgniecki/MinecraftMotdParser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgniecki%2FMinecraftMotdParser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279101341,"owners_count":26103775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","mineceraft","motd","parser","php"],"created_at":"2024-11-11T15:08:19.626Z","updated_at":"2025-10-15T18:21:19.879Z","avatar_url":"https://github.com/jgniecki.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minecraft MOTD Parser\n![](https://img.shields.io/packagist/l/dev-lancer/minecraft-motd-parser?style=for-the-badge)\n![](https://img.shields.io/packagist/dt/dev-lancer/minecraft-motd-parser?style=for-the-badge)\n![](https://img.shields.io/github/v/release/jgniecki/MinecraftMotdParser?style=for-the-badge)\n![](https://img.shields.io/packagist/php-v/dev-lancer/minecraft-motd-parser?style=for-the-badge)\n\nPHP library to parse minecraft server motd\n\n## Installation\nThis library can be installed by issuing the following command:\n```bash\ncomposer require dev-lancer/minecraft-motd-parser\n```\n\n## Documentation\n| Lang                  |\n|:----------------------|\n| [EN](docs/en/home.md) |\n| [PL](docs/pl/home.md) |\n\n\n## Parsing\n\n### Usage TextParser\nTo parse a text-based MOTD using custom formatting and colors:\n\n```php\n$formatCollection = \\DevLancer\\MinecraftMotdParser\\Collection\\FormatCollection::generate();\n$colorCollection  = \\DevLancer\\MinecraftMotdParser\\Collection\\ColorCollection::generate(true); //When set to true, colors from BE are added\n$parser = new \\DevLancer\\MinecraftMotdParser\\Parser\\TextParser($formatCollection, $colorCollection, '\u0026');\n\n$motd = \"A \u0026l\u0026fMine\u00264craft \u0026rServer\";\n$motdItemCollection = $parser-\u003eparse($motd, new \\DevLancer\\MinecraftMotdParser\\Collection\\MotdItemCollection());\n```\n\n### Usage ArrayParser\nTo parse a structured array-based MOTD:\n\n```php\n$formatCollection = \\DevLancer\\MinecraftMotdParser\\Collection\\FormatCollection::generate();\n$colorCollection  = \\DevLancer\\MinecraftMotdParser\\Collection\\ColorCollection::generate();\n$parser = new \\DevLancer\\MinecraftMotdParser\\Parser\\ArrayParser($formatCollection, $colorCollection);\n\n$motd = [\n    [ \"text\" =\u003e \"A \"],\n    [\n        \"bold\" =\u003e true,\n        \"extra\" =\u003e [\n            [\n                \"color\" =\u003e \"white\",\n                \"text\" =\u003e \"Mine\"\n            ],\n            [\n                \"color\" =\u003e \"dark_red\",\n                \"text\" =\u003e \"craft \"\n            ],\n        ]\n    ],\n    [\n        \"text\" =\u003e \"Server\"\n    ]\n];\n$motdItemCollection = $parser-\u003eparse($motd, new \\DevLancer\\MinecraftMotdParser\\Collection\\MotdItemCollection());\n```\n\n### Merging Similar Items\nThe mergeSimilarItem() method in the MotdItemCollection class merges adjacent MotdItem objects with the same formatting and color. This optimization helps to reduce redundancy in the formatting and color codes, making the MOTD more concise.\n\n```php\n$motd = \"A \u0026l\u0026fMine\u0026f\u0026lcraft \u0026rServer\";\n$motdItemCollection = $parser-\u003eparse($motd, new \\DevLancer\\MinecraftMotdParser\\Collection\\MotdItemCollection());\n\n//Output before\n[\n    ['text': \"A \"],\n    ['bold': true, 'color': \"white\", 'text': \"Mine\"],\n    ['bold': true, 'color': \"white\", 'text': \"craft \"],\n    ['reset': true, 'text': \"Server\"],\n]\n\n$motdItemCollection-\u003emergeSimilarItem();\n//Output after\n[\n    ['text': \"A \"],\n    ['bold': true, 'color': \"white\", 'text': \"Minecraft \"],\n    ['reset': true, 'text': \"Server\"],\n]\n```\n\n## Generation\n\n### MotdItemCollection\nExample of creating a MotdItemCollection:\n\n```php\n$parser = new \\DevLancer\\MinecraftMotdParser\\Parser\\TextParser();\n$motd = \"A §l§fMine§4craft §rServer\";\n$motdItemCollection = $parser-\u003eparse($motd, new \\DevLancer\\MinecraftMotdParser\\Collection\\MotdItemCollection());\n```\n\n### Usage HtmlGenerator\nTo generate HTML from a parsed MOTD:\n```php\n$generator = new \\DevLancer\\MinecraftMotdParser\\Generator\\HtmlGenerator();\n\n// Generate HTML from the MOTD item collection\necho $generator-\u003egenerate($motdItemCollection); \n```\n\n#### Output\nThe output will be:\n```html\nA \u003cspan style=\"font-weight: bold; color: #FFFFFF;\"\u003eMine\u003c/span\u003e\n\u003cspan style=\"font-weight: bold; color: #AA0000;\"\u003ecraft \u003c/span\u003e Server\n```\n\n### Usage RawGenerator\nTo generate raw text from a parsed MOTD:\n```php\n$generator = new \\DevLancer\\MinecraftMotdParser\\Generator\\RawGenerator(\"§\");\n// Generate raw text from the MOTD item collection\necho $generator-\u003egenerate($motdItemCollection); \n//output: A §f§lMine§4craft §rServer\n```\n\n### Usage TextGenerator\nTo generate plain text from a parsed MOTD:\n```php\n$generator = new \\DevLancer\\MinecraftMotdParser\\Generator\\TextGenerator();\n// Generate plain text from the MOTD item collection\necho $generator-\u003egenerate($motdItemCollection); \n//output: A Minecraft Server\n```\n\n## Custom formatter\n\n### Define new class formatter\nExample of creating a custom bold formatter:\n```php\nclass CustomBoldFormatter implements FormatterInterface\n{\n    public function getKey(): string\n    {\n        return 'l';\n    }\n\n    public function getName(): string\n    {\n        return 'bold';\n    }\n\n    public function getFormat(): string\n    {\n        return '\u003cb class=\"CustomBoldFormatter\"\u003e%s\u003c/b\u003e';\n    }\n}\n```\n\n### Usage\nTo use the custom formatter:\n\n```php\n// Create a new format collection\n$formatCollection = \\DevLancer\\MinecraftMotdParser\\Collection\\FormatCollection::generate();\n\n// and override the default formatter for bold\n$formatCollection-\u003eadd(new CustomBoldFormatter());\n\n// Create a new MOTD item\n$motdItem = new \\DevLancer\\MinecraftMotdParser\\MotdItem();\n$motdItem-\u003esetBold(true);\n$motdItem-\u003esetText(\"Hello World\");\n\n// Create a new MOTD item collection and add the MOTD item\n$motdItemCollection = new \\DevLancer\\MinecraftMotdParser\\Collection\\MotdItemCollection();\n$motdItemCollection-\u003eadd($motdItem);\n\n// Generate HTML using the custom formatter\n$generator = new \\DevLancer\\MinecraftMotdParser\\Generator\\HtmlGenerator($formatCollection);\necho $generator-\u003egenerate($motdItemCollection); \n```\n\n### Output\nThe output will be:\n```html\n\u003cb class=\"CustomBoldFormatter\"\u003eHello World\u003c/b\u003e\n```\n\n## License\nThis library is licensed under the [MIT](LICENSE) License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgniecki%2Fminecraftmotdparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgniecki%2Fminecraftmotdparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgniecki%2Fminecraftmotdparser/lists"}