mc-utils icon indicating copy to clipboard operation
mc-utils copied to clipboard

[Util Change]: Server Info bugs

Open Dawsson opened this issue 1 year ago • 1 comments

Util Name

Server Info

Changes

Fix the font, fix the undefined

image image

Extra Info

No errors in console

Dawsson avatar Apr 17 '24 21:04 Dawsson

There seems to be a conflict between the latin letter small capital unicode character and the font being applied. The minecraft monospace font doesn't seem to have a "F" variant, when changed to the minecraft font it shows as "normal". The undefined is coming from the fact that the code does not check if item from the json request is an object so when item is a string, which is the case for the motd from flyte.gg

motd_json": {
    "extra": [
      {
        "color": "light_purple",
        "text": "                     ꜰʟʏᴛᴇ ѕᴍᴘ"
      },
      "\n"
    ],

so "\n" will be shown as undefined. This can be changed by changing:

let asString = status.motd_json.extra.reduce((acc, item) => {
   if (item.color) {
      return acc + `%${item.color}%${item.text}`;
   }
   return acc + item.text;
}, '');

is changed into:

let asString = status.motd_json.extra.reduce((acc, item) => {
    if (typeof item === 'object' && item.color) {
        return acc + `%${item.color}%${item.text}`;
    }
    return acc + (typeof item === 'object' ? item.text : item);
}, '');

How the font/unicode stuff needs to be changed is above my head.

Edit: forgot text

ShadowThijs avatar Apr 17 '24 22:04 ShadowThijs

This was closed by #212

joshbker avatar Jul 31 '24 08:07 joshbker