How to use Parties API to support player nicknames?
kangarko opened this issue · 11 comments
I am a developer of a chat plugin adding nicknames, how can I show them in Parties?
On nickname change you can use get the PartyPlayer then set the nickname:
PartiesAPI api = Parties.getApi();
PartyPlayer player = api.getPartyPlayer(playerUUID);
player.setNickname(nickname);
This can be done via both Spigot and BungeeCord Parties API.
Otherwise, in Spigot Parties you can use PlaceholderAPI support to add any PAPI placeholder in the party chat format.
PS. The nickname system is disabled by default so if the server administrator wanna use it, it must be enabled in parties.yml
and set %player_nickname%
in party chat format.
We use parties only on the bungee and we did indeed enable the nickname system of Parties in parties.yml as well for setting the %player_nickname% placeholder in the party chat format. [In case the info was needed]
@Sikatsu you could just use PlaceholderAPI to show a nickname from Parties in ChatControl then. You'd have to use this on Spigot, not BungeeCord.
BungeeControl does not pass data for Spigot servers to change. It only listens to incoming data from Spigot and stores it on Bungee to show.
If you're using party chat from Parties on Bungee then should you not see nicknames in their party chat right?
Correct me if I am misunderstanding - how would you like this integration to work exactly? Thanks.
I would like it to work when parties is installed on the bungee, NOT on the spigot servers. I know I can make it work with making a bungee plugin that hooks into chatcontrol's database and then passes on the nickname to parties. Though I was hoping it could be done in a better and safer way.. @kangarko
Okay just to clarify for me, you want ChatControl's nicknames to show up in Parties party chat?
Correct! @kangarko
@AlessioDP I am trying to inject ChatControls nicknames into your plugin, I tried listening to BungeePartiesPlayerPreChatEvent and set calling PartyPlayer#setNickname but it is not working as expected:
My ChatControl nick is lolo.
When I change my nickname, I have to send two messages for this to get reflected. Can you please adjust your API to take the new nickname from the event other plugins catch, or instruct me how to do this properly?
Thanks.
When you listen to BungeePartiesPlayerPreChatEvent
the chat message is already parsed.
Instead of setting the player nickname on send message, you should set it on nickname change so it will reflect in every nickname placeholder.
If you just wanna change the nickname only in the chat (the nickname can be used somewhere else too), you need to use event.setMessage()
and replace the player name with the nickname.
@kangarko How does it work?
Edit: It seems to work, but delayed. It takes a few seconds before it updates in party chat.
If that's normal then disregard what I said ^^