SQLPerms API
-
SQLPerms (API)Overview:
This page is part of a series of SQLPerms documentation pages
SQLPerms has an API to allow other plugins to interact with it in various ways. Below is the documentation on each part of the API.
Getting the SQLPerms instance:
To use the SQLPerms API in your plugin, you first need to get an instance of the main class like so:
Code (Text):
for(Plugin plugin : Bukkit.getServer().getPluginManager().getPlugins()){
if(plugin instanceof SQLPerms){
sqlPerms = ((SQLPerms) plugin); break;
}
}
Getting a player's rank:
To get a player's rank, you need the channel that you wish to check. Once you have this, get a player's rank like so:
Code (Text):String rank = sqlPerms.getDataStore().getRank(player.getUniqueId(), "channel");
Setting a player's rank:
To set a player's rank, you need the channel in which you want to set their rank, and the name of the rank you would like to set. The first step in setting a player's rank is to call the following DataStore method:
Code (Text):sqlPerms.getDataStore().setRank(player.getUniqueId(), "channel", "rank");
Code (Text):
PlayerChangeRankEvent playerChangeRankEvent = new PlayerChangeRankEvent(player, newRank, previousRank);Bukkit.getServer().getPluginManager().callEvent(playerChangeRankEvent);
Note:
When setting or getting a player's rank you can pass in a UUID that represents a currently offline player. To get a UUID from a name (online or offline) run the following code:
Code (Text):UUID uuid = sqlPerms.getUtil().getUUID("john01dav");
To get the prefix of a rank, you need a string with the rank's name in it. Once you have this, do the following:
Code (Text):String prefix = sqlPerms.getConfigManager().getPermissionsConfigurationManager().getPrefix(rank)
Code (Text):String formattedPrefix = ChatColor.translateAlternateColorCodes('&', prefix); - Loading...
- Loading...
XenCarta PRO
© Jason Axelrod from 8WAYRUN.COM