Phoenix616 / MineDown

A MarkDown inspired markup library for Minecraft chat components
https://wiki.phoenix616.dev/library/minedown/
MIT License
296 stars 21 forks source link

Formatting breaks when &<code>& has supported legacy code at the end. #9

Closed Andre601 closed 3 years ago

Andre601 commented 3 years ago

Used Version

Using MineDown through ServerListPlus fork 3.5.0-SNAPSHOT

Config

#      _____                     __    _     _   _____ _
#     |   __|___ ___ _ _ ___ ___|  |  |_|___| |_|  _  | |_ _ ___
#     |__   | -_|  _| | | -_|  _|  |__| |_ -|  _|   __| | | |_ -|
#     |_____|___|_|  \_/|___|_| |_____|_|___|_| |__|  |_|___|___|
# 
# ServerListPlus v3.4.8 - http://git.io/slp

# More information is available in the Wiki: http://git.io/slp-wiki

# This is the section where you can customize your server status ping!
#  - Default is the section for the status used when the player name is unknown.
#    Personalized is used if the client has already joined the server once.
#    Use %player% as placeholder for the player's name.
# 
# Features:
#  - Description (MotD): A short status message for your server, max. 2 lines.
#  - Players:
#    - Hover: The player hover message that is displayed if you hover the player count.
#    - Slots: Custom player slot formatting, see http://git.io/slp-slots
#  - Favicon:
#    - Use multiple server icons or the player's head as favicon, see http://git.io/oMhJlg
#    - Possible favicon sources: Files, Folders, URLs, Heads, Helms, Encoded
# 
#  More features are explained in the Wiki: http://git.io/slp-config
# 
# Usage:
#  - Add multiple entries for random messages.
#  - Save the file with valid UTF-8 encoding for special characters.
#  - Available placeholders:
#    - Player name: %player%
#    - Player count: %online%, %max%, %online@server% %online@world%
#    - Random online player name: %random_player%
--- !Status
Default:
  Description:
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7Join and test awesome plugins
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7Newest plugin: &#F39C12&ArmorStand Adjustor
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7MOTD provided by &#F39C12&ServerListPlus
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7The hottest server out there!
  Players:
    Hover:
    - |-
      &7Welcome to &#F39C12&PowerPlugins.net&7!
      &7
      &7We are a Public Test Server for CraftBukkit,
      &7Spigot and PaperMC plugins alike.
      &7You can test out both free and paid plugins
      &7at no costs for you!
      &7
      &7Just join this server and use &#F39C12&/pl
      &7to get started.
      &7
      &7Have fun!
Personalized:
  Description:
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7Join and test awesome plugins
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7Newest plugin: &#F39C12&ArmorStand Adjustor
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7MOTD provided by &#F39C12&ServerListPlus
  - |-
    &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net
    &7The hottest server out there!
  Players:
    Hover:
    - |-
      &7Welcome to &#F39C12&PowerPlugins.net&7!
      &7
      &7We are a Public Test Server for CraftBukkit,
      &7Spigot and PaperMC plugins alike.
      &7You can test out both free and paid plugins
      &7at no costs for you!
      &7
      &7Just join this server and use &#F39C12&/pl
      &7to get started.
      &7
      &7Have fun!

# Stats: Enable/disable sending plugin statistics.
# PlayerTracking: Enable/disable tracking of player names to their IP-Addresses.
#   - Persistence can be disabled with the toggle in the Storage section.
# Samples: Toggle using multiple player infos for the player hover message.
#     May prevent the annoying ... and x more ... message for bigger servers
#     DynamicPlayers is special and aligns the number with the number of
#     random players used in placeholders.
# Unknown: Placeholder replacement if the real value is unknown.
# Favicon: Options for the creation / downloading of favicons:
#  - RecursiveFolderSearch: Also search for favicons in sub directories.
#  - SkinSource: The URL to get the Minecraft Skins from. (%s -> player name)
#  - ResizeStrategy: The strategy used to resize too small or too big favicons.
#      NONE (keep them as is, will probably fail), SCALE (scale them to the correct size)
--- !Plugin
Stats: true
PlayerTracking:
  Enabled: true
  Storage: !JSONStorage
    Enabled: true
    SaveDelay: 5m
Samples:
  Multiple: true
  DynamicPlayers: false
Unknown:
  PlayerName: player
  PlayerCount: ???
  Date: ???
Favicon:
  Timeout: 10s
  RecursiveFolderSearch: false
  ResizeStrategy: SCALE

Environment description

Ubuntu 20.04 PaperMC 277 (MC 1.16.4

Full Log

Not needed

What other programs/plugins are you running?

What is happening?

When using the &<code>& syntax for defining colors such as HEX colors does it seem to first parse legacy colors followed by the codes, which may have been broken due to this fact.

As an example, the line &7[&#F39C12&1.16.4&7] &#F39C12&PowerPlugins.net appears like this: image

My guess is, that MineDown, if responsible at all, parses legacy colors, such as &1 first, which turns the ampersand into a section symbol (§) which therefore breaks any &<code>& color code.

What did you expect to happen?

MineDown should first parse its own custom color formats to prevent any unwanted overrides happening.

Additional context

Phoenix616 commented 3 years ago

I cannot reproduce this when testing it in MineDown and there even is a test for a similar case. (A color character after the end of the hex code) Which build of ServerListPlus are you running?

Andre601 commented 3 years ago

It was the latest dev build from the Jenkins (from 14th of november) which is 35

Also, perhaps try a test with the full hexadecimal code and not just the short one?

Also, also, this may even be an issue with SLP in the first place. Perhaps it applies chat colors before any minedown rendering is done? This issue should perhaps be transfered to the SLP fork's repo.

Phoenix616 commented 3 years ago

Also, perhaps try a test with the full hexadecimal code and not just the short one?

That is the next test after that and I also tested your exact config value which produced the correct coloring. The only thing I can think of is that this is either an issue in SLP directly like you mentioned or that the build includes some older MineDown version as I remember that there were some issues regarding the compile.

Andre601 commented 3 years ago

This is most likely the cause as when the Lib works as intended, then it has to be the plugin at the very least.

Phoenix616 commented 3 years ago

Yeah, I checked it and you are completely right, it replaces the color codes before MineDown even gets a chance to convert it itself. Gonna move this to the SLP repo (or not I guess, you can only transfer issues to repos by the same user/org :S) and see if I can find a fix for it.

Phoenix616 commented 3 years ago

Fixed with https://github.com/Minebench/ServerListPlus/commit/6b55ec8f8e0a98ea5700f95fd7e2644c197a3809