当前位置: 首页>>代码示例>>Java>>正文


Java PluginManager.getPermission方法代码示例

本文整理汇总了Java中org.bukkit.plugin.PluginManager.getPermission方法的典型用法代码示例。如果您正苦于以下问题:Java PluginManager.getPermission方法的具体用法?Java PluginManager.getPermission怎么用?Java PluginManager.getPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.plugin.PluginManager的用法示例。


在下文中一共展示了PluginManager.getPermission方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addParent

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
/**
 * Adds this permission to the specified parent permission.
 * <p>
 * If the parent permission does not exist, it will be created and
 * registered.
 *
 * @param name Name of the parent permission
 * @param value The value to set this permission to
 * @return Parent permission it created or loaded
 */
public Permission addParent(String name, boolean value) {
    PluginManager pm = Bukkit.getServer().getPluginManager();
    String lname = name.toLowerCase();

    Permission perm = pm.getPermission(lname);

    if (perm == null) {
        perm = new Permission(lname);
        pm.addPermission(perm);
    }

    addParent(perm, value);

    return perm;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:26,代码来源:Permission.java

示例2: registerPermissions

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
/**
 * Registers permissions that depend on the user's configuration file (for MultipleAchievements; for instance for
 * stone breaks, achievement.count.breaks.stone will be registered).
 */
private void registerPermissions() {
	getLogger().info("Registering permissions...");

	PluginManager pluginManager = getServer().getPluginManager();
	for (MultipleAchievements category : MultipleAchievements.values()) {
		for (String section : config.getConfigurationSection(category.toString()).getKeys(false)) {
			int startOfMetadata = section.indexOf(':');
			if (startOfMetadata > -1) {
				// Permission ignores metadata (eg. sand:1) for Breaks, Places and Crafts categories.
				section = section.substring(0, startOfMetadata);
			}
			if (category == MultipleAchievements.PLAYERCOMMANDS) {
				// Permissions don't take spaces into account for this category.
				section = StringUtils.replace(section, " ", "");
			}

			// Bukkit only allows permissions to be set once, check to ensure they were not previously set when
			// performing /aach reload.
			if (pluginManager.getPermission(category.toPermName() + "." + section) == null) {
				pluginManager.addPermission(
						new Permission(category.toPermName() + "." + section, PermissionDefault.TRUE));
			}
		}
	}
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:30,代码来源:AdvancedAchievements.java

示例3: addParent

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
/**
 * Adds this permission to the specified parent permission.
 * <p>
 * If the parent permission does not exist, it will be created and registered.
 *
 * @param name Name of the parent permission
 * @param value The value to set this permission to
 * @return Parent permission it created or loaded
 */
public Permission addParent(String name, boolean value) {
    PluginManager pm = Bukkit.getServer().getPluginManager();
    String lname = name.toLowerCase();

    Permission perm = pm.getPermission(lname);

    if (perm == null) {
        perm = new Permission(lname);
        pm.addPermission(perm);
    }

    addParent(perm, value);

    return perm;
}
 
开发者ID:AlmuraDev,项目名称:Almura-API,代码行数:25,代码来源:Permission.java

示例4: generatePermissions

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
public static void generatePermissions() {
	PluginManager pm = Bukkit.getServer().getPluginManager();
	for (Permission perm : Permission.values()) {
		if (pm.getPermission(perm.getPermission()) == null) {
			pm.addPermission(perm.registerPermission());
		}
	}
}
 
开发者ID:NJDaeger,项目名称:EssentialCommands,代码行数:9,代码来源:Util.java

示例5: sendPermissionInfo

import org.bukkit.plugin.PluginManager; //导入方法依赖的package包/类
void sendPermissionInfo(String name, CommandSender sender) {
    PluginManager pm = sender.getServer().getPluginManager();
    Permission permission = pm.getPermission(name);

    if(permission == null) {
        sender.sendMessage(ChatColor.RED + "Permission " + name + " is unregistered");
    } else {
        sender.sendMessage(ChatColor.GOLD + "Permission " + ChatColor.WHITE + permission.getName());
        sender.sendMessage(ChatColor.WHITE.toString() + ChatColor.ITALIC + permission.getDescription());
        sender.sendMessage(ChatColor.GOLD + "Default: " + ChatColor.WHITE + permission.getDefault());

        boolean first = true;
        for(Permission parent : pm.getPermissions()) {
            Boolean value = parent.getChildren().get(permission.getName());
            if(value != null) {
                if(first) {
                    first = false;
                    sender.sendMessage(ChatColor.GOLD + "Parents:");
                }

                if(value) {
                    sender.sendMessage(ChatColor.GREEN + "  +" + parent.getName());
                } else {
                    sender.sendMessage(ChatColor.RED + "  -" + parent.getName());
                }
            }
        }

        first = true;
        for(Map.Entry<String, Boolean> child : permission.getChildren().entrySet()) {
            if(first) {
                first = false;
                sender.sendMessage(ChatColor.GOLD + "Children:");
            }

            if(child.getValue()) {
                sender.sendMessage(ChatColor.GREEN + "  +" + child.getKey());
            } else {
                sender.sendMessage(ChatColor.RED + "  -" + child.getKey());
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:44,代码来源:PermissionCommands.java


注:本文中的org.bukkit.plugin.PluginManager.getPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。