1.15.2 Best way to update scoreboard's placeholder

Discussion in 'Spigot Plugin Development' started by i998979, Jun 9, 2020.

  1. So recently I'm working on scoreboard related stuff, it is fine until I am,trying to update placeholders in scoreboard.

    Assume the scoreboard looks like this
    Code (Text):
    TITLE
    dungeon: %dungeon%
    Owner: %player%
    Status: %status%
    Assume the plugin only know what value to replace but not where the placeholder is since the line text can be modified from config

    My way to update the scoreboard is
    - Loop through string list which contains all raw line text
    - Find the lines which contains the placeholder specified
    - Replace the placeholders with value
    - Update that line in scoreboard ONLY

    But this looks dumb, so I'm wondering is there any way to achieve this in a smarter way?

    Edit: Also the scoreboard is animated, dunno if it helps but...yeah, extra information
     
  2. Prob the smartest way would be to intercept the scoreboard packets and replace the placeholders for everyone dynamically.