API for prefixes
RoboMWM opened this issue ยท 12 comments
I know it's a tad outside the scope of this plugin but I was wondering if it'd be possible to add an API/hook for adding prefixes to tablist/players since I can't really do that with the way healthbar works... would this be possible or would it also override healthbar's scoreboards...
As for what I'm trying to do, I'm trying to set the SimpleClans tag as the player's prefix while also using the healthbar plugin.
I think you can modify the prefix using the Bukkit API but you have to use the same scoreboard instance which is as far as I know the global one.
Yea I know you'd set a player to a team and set the prefix there but healthbar assigns players to teams depending on how much health (percentage-wise) they have - hence I'm not aware if it is possible to use something similar to what you do here to remain compatible with healthbar (I guess I could also decompile Colored tags and see how he does it).
As far as I know it's only possible that a player is associated to only one team.
healthbar assigns players to teams depending on how much health (percentage-wise)
So I see only two options here:
- Display the healthbar only below the name, so you can use teams again.
- Use personal HealthBars (/scoreboards instances) -> each player has a different scoreboard instance.
Then you have to update the scoreboard of every online player if the player health changes. This have to be done in order other players can see the changes (->receives the changes as packets).
I think this is what AnimatedNames does to be compatible with Featherboard.
The latter which requires an overhaul of healthbar...
I took a brief look at colored tags and it seems to hook into healthbar...
The latter which requires an overhaul of healthbar...
That's correct ๐
I took a brief look at colored tags and it seems to hook into healthbar...
I think it should also work without the hook if HealthBar displays the health only below the player name, because the prefix and suffix feature uses (scoreboard) teams and the display below the name uses a scoreboard objective with the display slot 'below name'
Maybe I could make a PR to the HealthBar if the author is still active.
The author isn't active but I do have a fork (of a fork) of it which has it mavenized: https://github.com/MLG-Fortress/HealthBar
While I assume having an individual scoreboard per player would be ideal, I think I've been able to at least have each player be on their own team without much refactoring. I never worked with scoreboards before so I'm assuming there's no limits on teams, yes? MLG-Fortress/HealthBar@2c7e3fe
I'm currently not at home but I think you can create as many teams as you want, but you may want to remove the player team if the player leaves the servers in order to prevent memory leaks for the clients.
I think you found a really good solution with creating individual teams.
Yes, it does. I'm actually wondering if there's a way to show different text per player for the BELOW_NAME display slot, unsure if this is possible since objectives seem to work a little differently (only one objective viewable for the client?)
I think the players can only view one objective per display slot. A new objective would override the old one.
It looks like that if the client knows this objective it display it for all players regardless if the have a score set. So there can be only one objective. ๐