Minecrell / ServerListPlus

A flexible Minecraft plugin to customize the appearance of your server in the server list
https://git.io/slp
GNU General Public License v3.0
235 stars 60 forks source link

Some placeholders from PAPI not rendered properly #389

Closed MaHl111 closed 1 year ago

MaHl111 commented 2 years ago

Summary

I encountered this bug when I was trying to use state placeholders from CMI in SLP. While using some other placeholders like {server_version} works just fine, placeholder like {cmi_maintenance_state} does not parse (even though it parse on server or when tested with /papi parse, should result in True/False). Instead I'm getting blank space where placeholder should be parsed. I'm trying to use this placeholder with TAB's placeholder replace to achieve custom formatting instead of True/False. However, both variants are not being parsed in SLP.

Result

obrázok

Versions

PaperSpigot - 1.18.1, Build 68 CMI - 9.1.3.0 PlaceholderAPI - 2.11.1 ServerListPlus - v3.5.0-SNAPSHOT

Config

# ServerListPlus v3.5.0-SNAPSHOT - https://git.io/slp
# More information is available in the wiki: https://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.
#  - You can use formatting codes (&c, &l etc) and hex RGB color codes (&#rrggbb).
#  - 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%
#    - Ban reason: %ban_reason%
#    - Ban operator: %ban_operator%
#    - Ban experiation date: %ban_expiration_date%, %ban_expiration_datetime%
---
!Status
Default:
  Description:
    - |-
      &8&m                       &8[&5&lEndless&6&lCraft&8]&m                       
      &eServer již navštívilo &6{server_unique_joins} &eunikátních hráčů! # {server_unique_joins} is parsed properly
    - |-
      &8&m                       &8[&5&lEndless&6&lCraft&8]&m                       
      &eServer je {tab_replace_cmi_maintenance_state}, na verzi 8&l[%gradient#ffbe00#f4511e%&l{server_version}%gradient%&8&l]&e! # {server_version} is parsed properly, {tab_replace_cmi_maintenance_state} is not. Neither is {cmi_maintenance_state}
  Players:
    Hover:
      - |-
        &aVítej &lNa našem serveru&a!
        &aCurrently &e&l%online%/%max% &aplayers are playing on our server!
Personalized:
  Description:
    - |-
      &8&m                       &8[&5&lEndless&6&lCraft&8]&m                       
      &eServer již navštívilo &6{server_unique_joins} &eunikátních hráčů! # Same here
    - |-
      &8&m                       &8[&5&lEndless&6&lCraft&8]&m                       
      &eServer je {tab_replace_cmi_maintenance_state} na verzi &8&l[%gradient#ffbe00#f4511e%&l{server_version}%gradient%&8&l]&e! # Same here
  Players:
    Slots:
      - "&8» &7&l%online%&8&l/&7&l%max%"
    Hover:
      - |-
        &aVítej zpět, &l%player%&a!
        &aPrávě hraje na serveru &e&l%online%/%max% &ahráčů!

# PlayerTracking: Enable/disable tracking of player names to their IP-Addresses.
#   - Persistence can be disabled with the toggle in the Storage section.
# StripRGBIfOutdated: Strip RGB color codes for outdated clients.
#   - With this enabled you can put an old color code (e.g. &c) before RGB codes/gradients
#     and they will be shown for outdated clients.
# 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
PlayerTracking:
  Enabled: true
  Storage: !JSONStorage
    Enabled: true
    SaveDelay: 5m
StripRGBIfOutdated: true
Unknown:
  PlayerName: player
  PlayerCount: ???
  Date: ???
  BanReason: some reason
  BanOperator: somebody
  BanExpirationDate: never
Favicon:
  Timeout: 10s
  RecursiveFolderSearch: false
  ResizeStrategy: SCALE

# This section is only for the Bukkit plugin of ServerListPlus.
# ProtocolLib: (DISABLE|AUTO|ENABLE) Decides if ProtocolLib should be used by ServerListPlus.
#   Generally, AUTO (the default) is a good choice: ProtocolLib is used on Spigot for
#   full functionality, but disabled on Paper because it is not needed there.
#   Note that this might cause other plugins that make use of ProtocolLib to overwrite
#   the changes made by ServerListPlus. In that case, try setting ENABLE instead.
---
!Bukkit
ProtocolLib: AUTO

Conclusion

It's not really big deal for me but some people might heavily depend on placeholders to customize MOTD, assuring correct parsing and support for PlaceholderAPI is must in that case.

stephan-gh commented 2 years ago

This sounds like a limitation of the placeholder implementation in the other plugins, rather than a bug in ServerListPlus. SLP simply forwards all placeholder handling to PlaceholderAPI, so I don't see any reason why some placeholders would be handled differently than others.

However, there is one fundamental limitation for the server list that you need to keep in mind: Many placeholders using PlaceholderAPI assume that the identity of the player is known and that they are currently online (playing) on the server. For placeholders in SLP, the player is usually not onlline and even the identity is only sometimes known (since this is just a guess based on the player IP address).

And indeed, the TAB plugin you mentioned always returns an empty string if the player is not online. This would need to be fixed there.

I was not able to find the source code for the "CMI" plugin. If it is a premium plugin, please ask them for commercial support.

MaHl111 commented 2 years ago

Fair points. I've been tinkering with placeholders in these two plugins and they were outputing intended values in the end, so I assumed they should be accessible in global scope and dynamically change, regardless if player is on server or not, as server version (even though they are not related, but similar) and other values like that were parsed without a problem. I'll try to talk this out with CMI stuff if this can be outputted without player being online so I can put state in to MOTD and such. I'll post update when I get it sorted and close the thread. Thanks for your help.