org.bukkit.permissions.PermissionAttachmentInfo Java Examples
The following examples show how to use
org.bukkit.permissions.PermissionAttachmentInfo.
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: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public int getPurgeLimit(Player player) { int limit = RedProtect.get().config.configRoot().purge.canpurge_limit; List<Integer> limits = new ArrayList<>(); Set<PermissionAttachmentInfo> perms = player.getEffectivePermissions(); if (limit > 0) { for (PermissionAttachmentInfo perm : perms) { if (perm.getPermission().startsWith("redprotect.canpurge-limit.")) { String pStr = perm.getPermission().replaceAll("[^-?0-9]+", ""); if (!pStr.isEmpty()) { limits.add(Integer.parseInt(pStr)); } } } } if (limits.size() > 0) { limit = Collections.max(limits); } return limit; }
Example #2
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 6 votes |
private int getBlockLimit(Player player) { int limit = RedProtect.get().config.configRoot().region_settings.limit_amount; List<Integer> limits = new ArrayList<>(); Set<PermissionAttachmentInfo> perms = player.getEffectivePermissions(); if (limit > 0) { if (!hasVaultPerm(player, "redprotect.limits.blocks.unlimited")) { for (PermissionAttachmentInfo perm : perms) { if (perm.getPermission().startsWith("redprotect.limits.blocks.")) { if (RedProtect.get().config.configRoot().region_settings.blocklimit_per_world && !hasVaultPerm(player, perm.getPermission())) continue; String pStr = perm.getPermission().replaceAll("[^-?0-9]+", ""); if (!pStr.isEmpty()) { limits.add(Integer.parseInt(pStr)); } } } } else { return -1; } } if (limits.size() > 0) { limit = Collections.max(limits); } return limit; }
Example #3
Source File: PermissionHandler.java From RedProtect with GNU General Public License v3.0 | 6 votes |
private int getClaimLimit(Player player) { int limit = RedProtect.get().config.configRoot().region_settings.claim.amount_per_player; List<Integer> limits = new ArrayList<>(); Set<PermissionAttachmentInfo> perms = player.getEffectivePermissions(); if (limit > 0) { if (!hasVaultPerm(player, "redprotect.limits.claim.unlimited")) { for (PermissionAttachmentInfo perm : perms) { if (perm.getPermission().startsWith("redprotect.limits.claim.")) { if (RedProtect.get().config.configRoot().region_settings.claim.claimlimit_per_world && !hasVaultPerm(player, perm.getPermission())) continue; String pStr = perm.getPermission().replaceAll("[^-?0-9]+", ""); if (!pStr.isEmpty()) { limits.add(Integer.parseInt(pStr)); } } } } else { return -1; } } if (limits.size() > 0) { limit = Collections.max(limits); } return limit; }
Example #4
Source File: SuperPermsPreProcessor.java From BungeePerms with GNU General Public License v3.0 | 6 votes |
private List<String> getSuperPerms(Sender s) { BukkitSender bs = (BukkitSender) s; CommandSender sender = bs.getSender(); if (!(sender instanceof Player)) { return new ArrayList(); } Player p = (Player) sender; Permissible base = Injector.getPermissible(p); if (!(base instanceof BPPermissible)) { return new ArrayList(); } BPPermissible perm = (BPPermissible) base; List<String> l = new ArrayList(perm.getEffectiveSuperPerms().size()); for (PermissionAttachmentInfo e : perm.getEffectiveSuperPerms()) { l.add((e.getValue() ? "" : "-") + e.getPermission().toLowerCase()); } return l; }
Example #5
Source File: LimitsModule.java From Modern-LWC with MIT License | 5 votes |
/** * Search permissions for an integer and if found, return it * * @param player * @param prefix * @return */ public int searchPermissionsForInteger(Player player, String prefix) { PermissionAttachmentInfo attachment = searchPermissions(player, prefix); // Not found if (attachment == null) { return -1; } // Found return Integer.parseInt(attachment.getPermission().substring(prefix.length())); }
Example #6
Source File: ShopUtils.java From ShopChest with MIT License | 5 votes |
/** * Get the shop limits of a player * @param p Player, whose shop limits should be returned * @return The shop limits of the given player */ public int getShopLimit(Player p) { int limit = 0; boolean useDefault = true; for (PermissionAttachmentInfo permInfo : p.getEffectivePermissions()) { if (permInfo.getPermission().startsWith("shopchest.limit.") && p.hasPermission(permInfo.getPermission())) { if (permInfo.getPermission().equalsIgnoreCase(Permissions.NO_LIMIT)) { limit = -1; useDefault = false; break; } else { String[] spl = permInfo.getPermission().split("shopchest.limit."); if (spl.length > 1) { try { int newLimit = Integer.valueOf(spl[1]); if (newLimit < 0) { limit = -1; break; } limit = Math.max(limit, newLimit); useDefault = false; } catch (NumberFormatException ignored) { /* Ignore and continue */ } } } } } if (limit < -1) limit = -1; return (useDefault ?Config.defaultLimit : limit); }
Example #7
Source File: PermissionCommands.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@Command( aliases = {"list"}, desc = "List all permissions", usage = "[player] [prefix]", min = 0, max = 2 ) public void list(CommandContext args, CommandSender sender) throws CommandException { CommandSender player = CommandUtils.getCommandSenderOrSelf(args, sender, 0); String prefix = args.getString(1, ""); sender.sendMessage(ChatColor.WHITE + "Permissions for " + player.getName() + ":"); List<PermissionAttachmentInfo> perms = new ArrayList<>(player.getEffectivePermissions()); Collections.sort(perms, new Comparator<PermissionAttachmentInfo>() { @Override public int compare(PermissionAttachmentInfo a, PermissionAttachmentInfo b) { return a.getPermission().compareTo(b.getPermission()); } }); for(PermissionAttachmentInfo perm : perms) { if(perm.getPermission().startsWith(prefix)) { sender.sendMessage((perm.getValue() ? ChatColor.GREEN : ChatColor.RED) + " " + perm.getPermission() + (perm.getAttachment() == null ? "" : " (" + perm.getAttachment().getPlugin().getName() + ")")); } } }
Example #8
Source File: Permission.java From VaultAPI with GNU Lesser General Public License v3.0 | 5 votes |
/** * Add transient permission to a player. * This operation adds a permission onto the player object in bukkit via Bukkit's permission interface. * * @param player Player Object * @param permission Permission node * @return Success or Failure */ public boolean playerAddTransient(Player player, String permission) { for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { paInfo.getAttachment().setPermission(permission, true); return true; } } PermissionAttachment attach = player.addAttachment(plugin); attach.setPermission(permission, true); return true; }
Example #9
Source File: Permission.java From VaultAPI with GNU Lesser General Public License v3.0 | 5 votes |
/** * Remove transient permission from a player. * * @param player Player Object * @param permission Permission node * @return Success or Failure */ public boolean playerRemoveTransient(Player player, String permission) { for (PermissionAttachmentInfo paInfo : player.getEffectivePermissions()) { if (paInfo.getAttachment() != null && paInfo.getAttachment().getPlugin().equals(plugin)) { paInfo.getAttachment().unsetPermission(permission); return true; } } return false; }
Example #10
Source File: ExprPermissions.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable protected String[] get(Event e) { final Set<String> permissions = new HashSet<>(); for (Player player : players.getArray(e)) for (final PermissionAttachmentInfo permission : player.getEffectivePermissions()) permissions.add(permission.getPermission()); return permissions.toArray(new String[permissions.size()]); }
Example #11
Source File: PlayerListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@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)); }
Example #12
Source File: LimitsModule.java From Modern-LWC with MIT License | 5 votes |
/** * Search the player's permissions for a permission and return it * Depending on this is used, this can become O(scary) * * @param player * @param prefix * @return */ public PermissionAttachmentInfo searchPermissions(Player player, String prefix) { for (PermissionAttachmentInfo attachment : player.getEffectivePermissions()) { String permission = attachment.getPermission(); // check for the perm node if (attachment.getValue() && permission.startsWith(prefix)) { // Bingo! return attachment; } } return null; }
Example #13
Source File: SuperPermsPermissions.java From Modern-LWC with MIT License | 5 votes |
@Override public List<String> getGroups(Player player) { LWC.getInstance(); List<String> groups = new ArrayList<>(); for (PermissionAttachmentInfo pai : player.getEffectivePermissions()) { if (pai.getPermission().startsWith(groupPrefix)) { groups.add(pai.getPermission().substring(groupPrefix.length())); } } return groups; }
Example #14
Source File: VaultPermissions.java From Modern-LWC with MIT License | 5 votes |
@Override public List<String> getGroups(Player player) { RegisteredServiceProvider<Permission> serviceProvider = Bukkit.getServer().getServicesManager() .getRegistration(Permission.class); groupPrefix = LWC.getInstance().getConfiguration().getString("core.groupPrefix", "group."); if (serviceProvider == null) { return super.getGroups(player); } Permission perm = serviceProvider.getProvider(); try { // the player's groups String[] groups = perm.getPlayerGroups(player); // fallback to superperms if it appears that they have no groups if (groups == null || groups.length == 0) { return super.getGroups(player); } List<String> groupss = Arrays.asList(groups); for (PermissionAttachmentInfo pai : player.getEffectivePermissions()) { if (pai.getPermission().startsWith(groupPrefix)) { groupss.add(pai.getPermission().substring(groupPrefix.length())); } } return groupss; } catch (UnsupportedOperationException e) { // Can be thrown by vault or asList. Thrown by Vault when using SuperPerms - // getPlayerGroups() will throw it :-( return super.getGroups(player); } }
Example #15
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
private List<PermissionAttachmentInfo> addChildPerms(List<BPPermission> perms) { Map<String, Boolean> map = new LinkedHashMap(); for (BPPermission perm : perms) { map.put(perm.getPermission().startsWith("-") ? perm.getPermission().substring(1) : perm.getPermission(), !perm.getPermission().startsWith("-")); } return addChildPerms(map); }
Example #16
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
private List<PermissionAttachmentInfo> addChildPerms(Map<String, Boolean> perms) { List<PermissionAttachmentInfo> permlist = new LinkedList(); for (Map.Entry<String, Boolean> perm : perms.entrySet()) { PermissionAttachmentInfo pai = new PermissionAttachmentInfo(oldPermissible, perm.getKey().toLowerCase(), null, perm.getValue()); permlist.add(pai); Permission permission = Bukkit.getPluginManager().getPermission(pai.getPermission()); if (permission != null && !permission.getChildren().isEmpty()) { permlist.addAll(addChildPerms(permission.getChildren())); } } return permlist; }
Example #17
Source File: LuckPermsPermissible.java From LuckPerms with MIT License | 5 votes |
@Override public @NonNull Set<PermissionAttachmentInfo> getEffectivePermissions() { Map<String, Boolean> permissionMap = this.user.getCachedData().getPermissionData(this.queryOptionsSupplier.getQueryOptions()).getPermissionMap(); ImmutableSet.Builder<PermissionAttachmentInfo> builder = ImmutableSet.builder(); permissionMap.forEach((key, value) -> builder.add(new PermissionAttachmentInfo(this.player, key, null, value))); return builder.build(); }
Example #18
Source File: SpleefPlayer.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { validateOnline(); return getBukkitPlayer().getEffectivePermissions(); }
Example #19
Source File: ServerCommandSender.java From Thermos with GNU General Public License v3.0 | 4 votes |
public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); }
Example #20
Source File: CraftMinecartCommand.java From Thermos with GNU General Public License v3.0 | 4 votes |
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); }
Example #21
Source File: CraftHumanEntity.java From Thermos with GNU General Public License v3.0 | 4 votes |
public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); }
Example #22
Source File: LevelCalcByChunk.java From askyblock with GNU General Public License v2.0 | 4 votes |
private void tidyUp() { // Cancel task.cancel(); // Finalize calculations result.rawBlockCount += (long)(result.underWaterBlockCount * Settings.underWaterMultiplier); // Set the death penalty result.deathHandicap = plugin.getPlayers().getDeaths(island.getOwner()); // Set final score result.score = (result.rawBlockCount / Settings.levelCost) - result.deathHandicap - island.getLevelHandicap(); // Run any modifications // Get the permission multiplier if it is available int levelMultiplier = 1; Player player = plugin.getServer().getPlayer(targetPlayer); if (player != null) { // Get permission multiplier for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) { if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.multiplier.")) { String spl[] = perms.getPermission().split(Settings.PERMPREFIX + "island.multiplier."); 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 { // Get the max value should there be more than one levelMultiplier = Math.max(levelMultiplier, Integer.valueOf(spl[1])); } } } // Do some sanity checking if (levelMultiplier < 1) { levelMultiplier = 1; } } } // Calculate how many points are required to get to the next level long pointsToNextLevel = (Settings.levelCost * (result.score + 1 + island.getLevelHandicap())) - ((result.rawBlockCount * levelMultiplier) - (result.deathHandicap * Settings.deathpenalty)); // Sometimes it will return 0, so calculate again to make sure it will display a good value if(pointsToNextLevel == 0) pointsToNextLevel = (Settings.levelCost * (result.score + 2 + island.getLevelHandicap()) - ((result.rawBlockCount * levelMultiplier) - (result.deathHandicap * Settings.deathpenalty))); // All done. informPlayers(saveLevel(island, targetPlayer, pointsToNextLevel)); }
Example #23
Source File: CraftHumanEntity.java From Kettle with GNU General Public License v3.0 | 4 votes |
public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); }
Example #24
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 4 votes |
public BPPermissible(CommandSender sender, User u, Permissible oldPermissible) { super(sender); this.sender = sender; this.oldPermissible = oldPermissible; permissions = new LinkedHashMap<String, PermissionAttachmentInfo>() { @Override public PermissionAttachmentInfo put(String k, PermissionAttachmentInfo v) { PermissionAttachmentInfo existing = this.get(k); if (existing != null) { return existing; } return super.put(k, v); } }; superperms = new LinkedHashMap<String, PermissionAttachmentInfo>() { @Override public PermissionAttachmentInfo put(String k, PermissionAttachmentInfo v) { PermissionAttachmentInfo existing = this.get(k); if (existing != null) { return existing; } return super.put(k, v); } }; //inject an opable oldOpable = Statics.getField(PermissibleBase.class, oldPermissible, ServerOperator.class, "opable"); opable = new ServerOperator() { @Override public boolean isOp() { BukkitConfig config = (BukkitConfig) BungeePerms.getInstance().getConfig(); if (opdisabled) { if (!config.isAllowops()) { return false; } } if (config.isDebug()) { BungeePerms.getLogger().info("op check: " + BPPermissible.this.sender.getName() + " has OP: " + oldOpable.isOp()); } return oldOpable.isOp(); } @Override public void setOp(boolean value) { oldOpable.setOp(value); } }; init = true; recalculatePermissions(); }
Example #25
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 4 votes |
public Set<PermissionAttachmentInfo> getEffectiveSuperPerms() { return new LinkedHashSet<>(superperms.values()); }
Example #26
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 4 votes |
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { return new LinkedHashSet<>(permissions.values()); }
Example #27
Source File: SSHDCommandSender.java From Bukkit-SSHD with Apache License 2.0 | 4 votes |
public Set<PermissionAttachmentInfo> getEffectivePermissions() { return this.perm.getEffectivePermissions(); }
Example #28
Source File: NullPermissible.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public Collection<PermissionAttachmentInfo> getAttachments() { return Collections.emptyList(); }
Example #29
Source File: NullSender.java From mcspring-boot with MIT License | 4 votes |
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { return null; }
Example #30
Source File: CraftMinecartCommand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { return perm.getEffectivePermissions(); }