當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。