Java Code Examples for org.bukkit.permissions.Permission#getName()

The following examples show how to use org.bukkit.permissions.Permission#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static Permission registerPermission(Permission perm, boolean withLegacy) {
    Permission result = perm;

    try {
        Bukkit.getPluginManager().addPermission(perm);
    } catch (IllegalArgumentException ex) {
        result = Bukkit.getPluginManager().getPermission(perm.getName());
    }

    if (withLegacy) {
        Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
        legacy.getChildren().put(result.getName(), true);
        registerPermission(perm, false);
    }

    return result;
}
 
Example 2
Source File: MySubCommand.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
void setupPermissions(String name, Permission parent) {
	String permName = parent.getName();
	if (permName.endsWith(".*")) {
		permName = permName.substring(0, permName.length() - 2);
	}
	_perm = new Permission(permName + "." + name);
	_perm.addParent(parent, true);
	for (Entry<String, MySubCommand> entry : _subCommands.entrySet()) {
		entry.getValue().setupPermissions(entry.getKey(), _perm);
	}
	Bukkit.getPluginManager().addPermission(_perm);
	parent.recalculatePermissibles();
}