本文整理匯總了Java中org.bukkit.permissions.PermissionAttachmentInfo類的典型用法代碼示例。如果您正苦於以下問題:Java PermissionAttachmentInfo類的具體用法?Java PermissionAttachmentInfo怎麽用?Java PermissionAttachmentInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PermissionAttachmentInfo類屬於org.bukkit.permissions包,在下文中一共展示了PermissionAttachmentInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPermValue
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的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.permissions.PermissionAttachmentInfo; //導入依賴的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.permissions.PermissionAttachmentInfo; //導入依賴的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: getVaultCapacity
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
public int getVaultCapacity(Player p)
{
int capacity = getVaultCapacity();
if(isVaultCapacityPermissionControl())
{
for(PermissionAttachmentInfo pai : p.getEffectivePermissions())
{
String per = pai.getPermission();
if(!per.toLowerCase().startsWith("wowsuchcleaner.vault.capacity.")) continue;
String capacityString = per.split("\\.")[3];
capacity = Integer.parseInt(capacityString);
continue;
}
}
return capacity;
}
示例5: LimitHandler
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
private int LimitHandler(Player p){
int limit = RPConfig.getInt("region-settings.limit-amount");
List<Integer> limits = new ArrayList<>();
Set<PermissionAttachmentInfo> perms = p.getEffectivePermissions();
if (limit > 0){
if (!p.hasPermission("redprotect.limit.blocks.unlimited")){
for (PermissionAttachmentInfo perm:perms){
if (perm.getPermission().startsWith("redprotect.limit.blocks.")){
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;
}
示例6: ClaimLimitHandler
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
private int ClaimLimitHandler(Player p){
int limit = RPConfig.getInt("region-settings.claim-amount");
List<Integer> limits = new ArrayList<>();
Set<PermissionAttachmentInfo> perms = p.getEffectivePermissions();
if (limit > 0){
if (!p.hasPermission("redprotect.limit.claim.unlimited")){
for (PermissionAttachmentInfo perm:perms){
if (perm.getPermission().startsWith("redprotect.limit.claim.")){
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;
}
示例7: getMaxGreenhouses
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
/**
* Returns the maximum number of greenhouses this player can make
* @param player
* @return number of greenhouses or -1 to indicate unlimited
*/
public int getMaxGreenhouses(Player player) {
// -1 is unimited
int maxGreenhouses = Settings.maxGreenhouses;
for (PermissionAttachmentInfo perms : player.getEffectivePermissions()) {
if (perms.getPermission().startsWith("greenhouses.limit")) {
logger(2,"Permission is = " + perms.getPermission());
try {
int max = Integer.valueOf(perms.getPermission().split("greenhouses.limit.")[1]);
if (max > maxGreenhouses) {
maxGreenhouses = max;
}
} catch (Exception e) {} // Do nothing
}
// Do some sanity checking
if (maxGreenhouses < 0) {
maxGreenhouses = -1;
}
}
return maxGreenhouses;
}
示例8: getSuperpermsGroup
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
/**
* Superperms has no group support, but we fake it (this is slow and stupid
* since it has to iterate through ALL permissions a player has). But if
* you're attached to superperms and not using a nice plugin like bPerms
* and Vault then this is as good as it gets.
*
* @param player
* @return the group name or null
*/
private String getSuperpermsGroup(Player player) {
if( player == null )
return null;
String group = null;
// this code shamelessly adapted from WorldEdit's WEPIF support for superperms
Permissible perms = getPermissible(player);
if (perms != null) {
for (PermissionAttachmentInfo permAttach : perms.getEffectivePermissions()) {
String perm = permAttach.getPermission();
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
continue;
}
// we just grab the first "group.X" permission we can find
group = perm.substring(GROUP_PREFIX.length(), perm.length());
break;
}
}
return group;
}
示例9: updatePermissible
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
/**
* Update all permissions and op state of the provided permissible.
*
* @param permissible the permissible
*/
private void updatePermissible(final CommandSender permissible) {
final boolean isPlayer = permissible instanceof Player;
if (isPlayer && !((Player)permissible).isOnline()) {
this.forgetPlayer((Player)permissible);
} else {
final String name = (isPlayer ? "" : "_") + permissible.getName();
if (permissible.isOp()) {
this.ops.add(name);
} else {
this.ops.remove(name);
}
Set<String> perms = this.permissions.get(name);
if (perms == null) {
perms = new HashSet<>();
} else {
perms.clear();
}
for (final PermissionAttachmentInfo perm : permissible.getEffectivePermissions()) {
if (perm.getValue()) {
perms.add(perm.getPermission());
}
}
this.permissions.put(name, perms);
}
}
示例10: getSuperPerms
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
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;
}
示例11: playerAddTransient
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
@Override
public boolean playerAddTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
paInfo.getAttachment().setPermission(permission, true);
return true;
}
}
PermissionAttachment attach = p.addAttachment(plugin);
attach.setPermission(permission, true);
return true;
}
示例12: playerRemoveTransient
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
@Override
public boolean playerRemoveTransient(String world, String player, String permission) {
if (world != null) {
throw new UnsupportedOperationException(getName() + " does not support World based transient permissions!");
}
Player p = plugin.getServer().getPlayer(player);
if (p == null) {
throw new UnsupportedOperationException(getName() + " does not support offline player transient permissions!");
}
for (PermissionAttachmentInfo paInfo : p.getEffectivePermissions()) {
if (paInfo.getAttachment().getPlugin().equals(plugin)) {
return paInfo.getAttachment().getPermissions().remove(permission);
}
}
return false;
}
示例13: listPerms
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
/**
* List all effective permissions for this player.
*
* @param player
* @return List<String> of permissions
*/
public List<String> listPerms(Player player)
{
List<String> perms = new ArrayList<String>();
/*
* // All permissions registered with Bukkit for this player
* PermissionAttachment attachment = this.attachments.get(player);
*
* // List perms for this player perms.add("Attachment Permissions:");
* for(Map.Entry<String, Boolean> entry :
* attachment.getPermissions().entrySet()){ perms.add(" " +
* entry.getKey() + " = " + entry.getValue()); }
*/
perms.add("Effective Permissions:");
for (PermissionAttachmentInfo info : player.getEffectivePermissions())
{
if (info.getValue() == true)
{
perms.add(" " + info.getPermission() + " = " + info.getValue());
}
}
return perms;
}
示例14: join
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的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));
}
示例15: list
import org.bukkit.permissions.PermissionAttachmentInfo; //導入依賴的package包/類
@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() + ")"));
}
}
}