This repository was archived by the owner on Sep 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
2.1 API Example (WIP :p)
Kev edited this page Jul 4, 2017
·
2 revisions
import org.bukkit.Bukkit;
import kevslashnull.permissions.KevsPermissions;
import kevslashnull.permissions.data.PermissionsGroup;
import kevslashnull.permissions.data.PermissionsList;
import kevslashnull.permissions.data.PermissionsPlayer;
import kevslashnull.permissions.io.PermissionsMeta;
import kevslashnull.permissions.permissible.KPermission;
/**
* @author KevSlashNull
*/
public class HookExample {
public void method() {
// The class KevsPermissions is the key to access all KevsPermissions
// functions and modify them
PermissionsPlayer player = KevsPermissions.getPlayer(Bukkit.getPlayer("KevSlashNull"));
player.setGroup("admin"); // Set the group of the player
PermissionsList list = player.getPermissions(); // This is a
// PermissionsList
// (obviously.)
// This list ist the same as a Iterator<KPermission>. That is a
// read-only list.
for (KPermission kPermission : list) {
if (kPermission.getType()) { // if true, the permission is true
kPermission.getName(); // the name of the permission
}
kPermission.toString(); // if the permission is an "anti"-permission
// (type == false), there is a - in front of
// the string
}
PermissionsMeta meta = player.getMeta(); // This is the meta of the
// player
// The meta contains a bunch of information about the player
meta.setOption("prefix", "ADMIN"); // This is how to set the
// prefix/suffix
player.getPrefix(); // You can get the prefix directly via the player
player.addPermission("test.permission"); // Add permissions
player.removePermission("test.permission"); // Remove permissions
player.getGroup(); // player's group
PermissionsGroup group = KevsPermissions.getGroup("admin");
group = KevsPermissions.getDefaultGroup(); // default group
// the group meta is the same as the player
}
}