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


Java Player.getEffectivePermissions方法代码示例

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


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

示例1: getPermValue

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Get the maximum value of a numerical perm setting
 * @param player - the player to check
 * @param perm - the start of the perm, e.g., bskyblock.maxhomes
 * @param permValue - the default value - the result may be higher or lower than this
 * @return
 */
public static int getPermValue(Player player, String perm, int permValue) {
    for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
        if (perms.getPermission().startsWith(perm + ".")) {
            // Get the max value should there be more than one
            if (perms.getPermission().contains(perm + ".*")) {
                return permValue;
            } else {
                String[] spl = perms.getPermission().split(perm + ".");
                if (spl.length > 1) {
                    if (!NumberUtils.isDigits(spl[1])) {
                        plugin.getLogger().severe("Player " + player.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");

                    } else {
                        permValue = Math.max(permValue, Integer.valueOf(spl[1]));
                    }
                }
            }
        }
        // Do some sanity checking
        if (permValue < 1) {
            permValue = 1;
        }
    }
    return permValue;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:33,代码来源:Util.java

示例2: getMaxPermission

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static int getMaxPermission(Player p, String node) {
	int maxLimit = 0;
	for (PermissionAttachmentInfo perm : p.getEffectivePermissions()) {
		String permission = perm.getPermission();
		if (!permission.toLowerCase().startsWith(node.toLowerCase())) {
			continue;
		}
		String[] split = permission.split("\\.");
		try {
			int number = Integer.parseInt(split[split.length - 1]);
			if (number > maxLimit) {
				maxLimit = number;
			}
		} catch (NumberFormatException ignore) { }
	}
	return maxLimit;
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:18,代码来源:NeverLagUtils.java

示例3: assignRanks

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void assignRanks(Player p, int tsDbId){
	
	//Permissions
	for(PermissionAttachmentInfo pai : p.getEffectivePermissions()) {
		String perms = pai.getPermission();
		if(UltimateTs.main().getConfig().get("perms."+perms) != null){
			int gTs = UltimateTs.main().getConfig().getInt("perms."+perms);
			BotManager.getBot().addClientToServerGroup(gTs, tsDbId);
		}
    }

	//Default Ranks
	int groupToAssign = UltimateTs.main().getConfig().getInt("config.assignWhenRegister");
	if(groupToAssign > 0){
		BotManager.getBot().addClientToServerGroup(groupToAssign, tsDbId);
	}
}
 
开发者ID:DiscowZombie,项目名称:UltimateTs,代码行数:18,代码来源:PlayerManager.java

示例4: join

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void join(final PlayerJoinEvent event) {
    Player player = event.getPlayer();

    resetPlayer(player);

    event.getPlayer().addAttachment(lobby, Permissions.OBSERVER, true);

    if (player.hasPermission("lobby.overhead-news")) {
        final String datacenter = minecraftService.getLocalServer().datacenter();
        final Component news = new Component(ChatColor.GREEN)
            .extra(new TranslatableComponent(
                "lobby.news",
                new Component(ChatColor.GOLD, ChatColor.BOLD).extra(generalFormatter.publicHostname())
            ));

        final BossBar bar = bossBarFactory.createBossBar(renderer.render(news, player), BarColor.BLUE, BarStyle.SOLID);
        bar.setProgress(1);
        bar.addPlayer(player);
        bar.show();
    }

    if(!player.hasPermission("lobby.disabled-permissions-exempt")) {
        for(PermissionAttachmentInfo attachment : player.getEffectivePermissions()) {
            if(config.getDisabledPermissions().contains(attachment.getPermission())) {
                attachment.getAttachment().setPermission(attachment.getPermission(), false);
            }
        }
    }

    int count = lobby.getServer().getOnlinePlayers().size();
    if(!lobby.getServer().getOnlinePlayers().contains(event.getPlayer())) count++;
    minecraftService.updateLocalServer(new SignUpdate(count));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:35,代码来源:PlayerListener.java


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