CATboardBETA
CATboardBETA

Reputation: 530

How to add prefix/suffix commands to my spigot plugin?

I have recently started work on a plugin with a good few commands, but was unaware of how to add prefix/suffix commands (e.g. /prefix <prefix>, /suffix <suffix>).

EXAMPLE: Someone named ExampleName types /prefix &4[SomeCooLPrefix]*. When they talk in chat, it should say [SomeCoolPrefix] ExampleName: <message>, where SomeCoolPrefix is in ChatColor.RED

*&4 is the code for ChatColor.RED

Upvotes: 1

Views: 2466

Answers (1)

Attaxika
Attaxika

Reputation: 58

Consider posting Spigot related questions to the Spigot Forums, as it is more likely that people there will know the ins and outs of the Spigot API.

As for your question, although I haven't done anything with Spigot in a while, you'll have to use the

ASyncPlayerChatEvent

Event in order to process when a player is chatting and then format the chat using the event.format(); method.

Also, if you're looking to allow players to give themselves a prefix AND save it, consider using a config file. I strongly recommend looking at the Spigot API documentation before trying to make a plugin.

Check out this link, and the documentation for more regarding the ASyncPlayerChatEvent method.

Upvotes: 2

Related Questions