org.bukkit.permissions.PermissionAttachment Java Examples

The following examples show how to use org.bukkit.permissions.PermissionAttachment. 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: NicknameCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void enable() {
    final PermissionAttachment attachment = Bukkit.getConsoleSender().addAttachment(plugin);
    Stream.of(
        PERMISSION,
        PERMISSION_GET,
        PERMISSION_SET,
        PERMISSION_ANY,
        PERMISSION_ANY_GET,
        PERMISSION_ANY_SET,
        PERMISSION_IMMEDIATE
    ).forEach(name -> {
        final Permission permission = new Permission(name, PermissionDefault.FALSE);
        pluginManager.addPermission(permission);
        attachment.setPermission(permission, true);
    });
}
 
Example #2
Source File: LoginListener.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void applyPermissions(Player player, UserDoc.Login userDoc) {
    boolean op = false;

    final Server localServer = minecraftService.getLocalServer();
    if(localServer.operators().containsKey(player.getUniqueId())) {
        logger.info("Opping " + player.getName() + " because they are in the server op list");
        op = true;
    }

    if(localServer.team() != null && localServer.team().members().contains(userDoc)) {
        logger.info("Opping " + player.getName() + " because they are on the team that owns the server");
        op = true;
    }

    PermissionAttachment attachment = player.addAttachment(this.plugin);
    PermissionUtils.setPermissions(attachment, Permissions.mergePermissions(localServer.realms(), userDoc.mc_permissions_by_realm()));
    player.recalculatePermissions();

    if(player.hasPermission("op")) {
        op = true;
        logger.info("Opping " + player.getName() + " because they have the op permission node");
    }

    player.setOp(op); // This is always explicitly set to true or false on login
}
 
Example #3
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public boolean addAll(@NonNull Collection<? extends PermissionAttachment> c) {
    boolean modified = false;
    for (PermissionAttachment e : c) {
        if (add(e)) {
            modified = true;
        }
    }
    return modified;
}
 
Example #4
Source File: LuckPermsPermissionAttachment.java    From LuckPerms with MIT License 5 votes vote down vote up
public LuckPermsPermissionAttachment(LuckPermsPermissible permissible, PermissionAttachment source) {
    super(source.getPlugin(), null);
    this.permissible = permissible;
    this.owner = source.getPlugin();

    // copy
    this.perms.putAll(source.getPermissions());
    this.source = source;

    injectFakeMap();
}
 
Example #5
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public boolean add(PermissionAttachment attachment) {
    if (LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment)) {
        return false;
    }

    new LuckPermsPermissionAttachment(LuckPermsPermissible.this, attachment).hook();
    return true;
}
 
Example #6
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 5 votes vote down vote up
@Override
public @NonNull PermissionAttachment addAttachment(@NonNull Plugin plugin, @NonNull String permission, boolean value) {
    Objects.requireNonNull(plugin, "plugin");
    Objects.requireNonNull(permission, "permission");

    PermissionAttachment attachment = addAttachment(plugin);
    attachment.setPermission(permission, value);
    return attachment;
}
 
Example #7
Source File: SingleCommandSender.java    From DiscordSRV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin arg0) {
    return sender.addAttachment(arg0);
}
 
Example #8
Source File: CraftHumanEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
    return perm.addAttachment(plugin, name, value);
}
 
Example #9
Source File: ServerCommandSender.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void removeAttachment(PermissionAttachment attachment) {
    perm.removeAttachment(attachment);
}
 
Example #10
Source File: SingleCommandSender.java    From DiscordSRV with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin arg0, String arg1, boolean arg2, int arg3) {
    return sender.addAttachment(arg0, arg1, arg2, arg3);
}
 
Example #11
Source File: SSHDCommandSender.java    From Bukkit-SSHD with Apache License 2.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
    return this.perm.addAttachment(plugin, name, value);
}
 
Example #12
Source File: PlayerStat.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public PermissionAttachment getPerms() {
	return perms;
}
 
Example #13
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public boolean contains(Object o) {
    PermissionAttachment attachment = (PermissionAttachment) o;
    return LuckPermsPermissible.this.hookedAttachments.stream().anyMatch(at -> at.getSource() == attachment);
}
 
Example #14
Source File: LuckPermsPermissionAttachment.java    From LuckPerms with MIT License 4 votes vote down vote up
PermissionAttachment getSource() {
    return this.source;
}
 
Example #15
Source File: SSHDCommandSender.java    From Bukkit-SSHD with Apache License 2.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
    return this.perm.addAttachment(plugin, ticks);
}
 
Example #16
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public @NonNull ListIterator<PermissionAttachment> listIterator(int index) { throw new UnsupportedOperationException(); }
 
Example #17
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public @NonNull List<PermissionAttachment> subList(int fromIndex, int toIndex) { throw new UnsupportedOperationException(); }
 
Example #18
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public @NonNull <T> T[] toArray(@NonNull T[] a) {
    return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray(a);
}
 
Example #19
Source File: ServerCommandSender.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
    return perm.addAttachment(plugin, name, value);
}
 
Example #20
Source File: ServerCommandSender.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
    return perm.addAttachment(plugin, name, value, ticks);
}
 
Example #21
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public Iterator<PermissionAttachment> iterator() {
    return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).iterator();
}
 
Example #22
Source File: LuckPermsPermissible.java    From LuckPerms with MIT License 4 votes vote down vote up
@Override
public @NonNull Object[] toArray() {
    return ImmutableList.<PermissionAttachment>copyOf(LuckPermsPermissible.this.hookedAttachments).toArray();
}
 
Example #23
Source File: CraftMinecartCommand.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
    return perm.addAttachment(plugin, name, value);
}
 
Example #24
Source File: CraftMinecartCommand.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
    return perm.addAttachment(plugin, name, value, ticks);
}
 
Example #25
Source File: SSHDCommandSender.java    From Bukkit-SSHD with Apache License 2.0 4 votes vote down vote up
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
    return this.perm.addAttachment(plugin, name, value, ticks);
}
 
Example #26
Source File: BPPermissible.java    From BungeePerms with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, int ticks)
{
    return oldPermissible.addAttachment(plugin, ticks);
}
 
Example #27
Source File: BPPermissible.java    From BungeePerms with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value)
{
    return oldPermissible.addAttachment(plugin, name, value);
}
 
Example #28
Source File: CraftHumanEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public void removeAttachment(PermissionAttachment attachment) {
    perm.removeAttachment(attachment);
}
 
Example #29
Source File: PermissionUtils.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void setPermissions(PermissionAttachment attachment,  Map<String, Boolean> permissions) {
    for(Map.Entry<String, Boolean> entry : permissions.entrySet()) {
        attachment.setPermission(entry.getKey(), entry.getValue());
    }
}
 
Example #30
Source File: NullPermissible.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void removeAttachment(PermissionAttachment attachment) {
}