Minecraft Server MOTD Parser
Introduction
This package support CommonJS, ES Module, and tree shaking
Can convert minecraft server MOTD data to text, json, html, and clean codes.
Support 1.16 custom hex color, and auto check motd data type.
Don't have other dependencies.
Installation
choose your favorite package manager
$ npm install @sfirew/minecraft-motd-parser
$ yarn add @sfirew/minecraft-motd-parser
$ pnpm add @sfirew/minecraft-motd-parser
Usage
CommonJS
const { autoToHTML } = require('@sfirew/minecraft-motd-parser');
ES6 Modules
import { autoToHTML } from '@sfirew/minecraft-motd-parser'
Simple use example
import { autoToHTML as motdParser } from '@sfirew/minecraft-motd-parser'
import motdParser from '@sfirew/minecraft-motd-parser'
const hypixelMotdString = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
console.log(motdParser(hypixelMotdString));
Some good custom motd hex color servers
The parser does not have the Minecraft font by default.
Minecraft font example
No Minecraft font
You can try server status view in my created service
https://mcsv.top/server/mc.hypixel.net
More Example
Some examples here, you can use TypeScript or JavaScript.
cleanCodes(string)
clean motd text color codes.
import motdParser from '@sfirew/minecraft-motd-parser'
import { cleanCodes } from '@sfirew/minecraft-motd-parser'
const motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
const result = cleanCodes(motdText);
console.log(result);
autoToHTML(string | object)
auto check MOTD data type then return same html result.
import motdParser from '@sfirew/minecraft-motd-parser'
let jsonExample = {
"extra": [
{
"bold": true,
"color": "gold",
"text": "Viper "
},
{
"color": "gray",
"text": "┃ "
},
{
"color": "yellow",
"text": "Summer Sale"
},
{
"color": "white",
"text": " at "
},
{
"color": "gold",
"text": "store.vipermc.net\n"
},
{
"color": "gray",
"text": "► "
},
{
"color": "yellow",
"text": "EOTW "
},
{
"color": "white",
"text": "on "
},
{
"color": "gold",
"text": "Infernal"
},
{
"color": "white",
"text": " is this Thursday at "
},
{
"color": "yellow",
"text": "5PM ET"
},
{
"color": "white",
"text": "."
}
],
"text": ""
};
let autoJsonResult = motdParser.autoToHTML(jsonExample);
console.log(autoJsonResult);
let textExample = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
let autoTextResult = motdParser.autoToHTML(textExample);
console.log(autoTextResult);
textToHTML(string)
convert motd text to html.
let motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
let result = motdParser.textToHTML(motdText);
console.log(result);
textToJSON(string)
convert motd json to html.
let motdText = "§aHypixel Network §7§c1.8/1.9/1.10/1.11/1.12 §e§lNEW PTL GAME:§b§l THE BRIDGE";
let result = motdParser.textToJSON(motdText);
console.log(result);
JSONToHTML(object)
convert text to motd json.
let mcfalloutJson = {
"extra": [
{
"color": "gray",
"text": " "
},
{
"color": "gold",
"text": "廢土伺服器 "
},
{
"color": "white",
"text": "mcFallout.net"
},
{
"color": "dark_gray",
"text": " - "
},
{
"color": "gray",
"text": "版本 1.17.1 "
},
{
"color": "gold",
"text": "洞穴"
},
{
"color": "light_purple",
"text": "與"
},
{
"color": "aqua",
"text": "山崖\n"
},
{
"color": "gray",
"text": " "
},
{
"color": "dark_gray",
"text": "享受工廠、農場、建築與紅石"
}
],
"text": ""
}
let result = motdParser.JSONToHTML(mcfalloutJson);
console.log(result)