Chat Tutorial
Using the chat system is really easy to do. You just grab the player data using their name and then change their data with the bountiful methods available!
Getting Player Data
ChatData playerData = Chat.getPlayerData(player);
Creating a prefix
Prefix prefix = new Prefix("MyPlugin", "Prefix", ChatColor.RED);
Unlocking A Prefix
Unlocked prefixes are for most prefixes that you will use such as achievements or classes if you don't need to show them.
playerData.unlockPrefix(prefix, false);
Setting A Plugin Prefix
Plugin prefixes are special prefixes that the player doesn't choose. You could use these for important prefixes such as faction alignment or rank. Try to use this sparingly to avoid excessively long display names.
playerData.setPluginPrefix(prefix);
Besides just controlling player names, there's also options for sending messages to certain players. There are four different methods for this in the Chat class:
Permission-Based Messages
Usage: Chat.sendMessage(String permission, String message)
This sends the message to all players with the permission
This can be useful for sending messages to factions if based off of permissions or to admins for admin chat
Location-Based Messages
Usage: There are three different methods for this
Chat.sendMessage(Location point1, Location point2, String message)
This method sends a message to all players within the cuboid defined by the two points
Chat.sendMessage(Location point, int width, int height, int depth, String message)
This is an alternative to the previous one, again sending a message to all players in a cuboid
Chat.sendMessage(Location center, int radius, boolean sphere, String message)
If 'sphere' is set to true, this will send a message to all players within the given distance (radius) of the center location. Could be useful for filtering chat to certain areas on large servers
If 'sphere' is set to false, this will not count the y coordinate when checking the distance, but otherwise behaves the same as the first case
That's about all you really need from the chat system. There are other methods you may tap into, but aren't necessary. Check out the javadocs, source code, or fool around with auto-complete in your IDE if you want to use some of the extras.
Comments