本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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));
}