Fix toggle permission (#644)

* Fixes #529
* fix superperms perm toggling

Co-authored-by: @weaondara <wea_ondara@alpenblock.net>
Dieser Commit ist enthalten in:
Aurora 2020-09-21 17:07:35 +02:00 committet von GitHub
Ursprung 806916d6e8
Commit 3b2fe2ffde
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 18 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -60,6 +60,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.permissions.PermissionAttachment;
import java.util.concurrent.ConcurrentHashMap;
import java.util.HashMap;
@ -73,16 +74,19 @@ public class BukkitPlayer extends AbstractPlayerActor {
private Player player;
private WorldEditPlugin plugin;
private PermissionAttachment permAttachment;
public BukkitPlayer(Player player) {
super(getExistingMap(WorldEditPlugin.getInstance(), player));
this.plugin = WorldEditPlugin.getInstance();
this.player = player;
this.permAttachment = player.addAttachment(plugin);
}
public BukkitPlayer(WorldEditPlugin plugin, Player player) {
this.plugin = plugin;
this.player = player;
this.permAttachment = player.addAttachment(plugin);
if (Settings.IMP.CLIPBOARD.USE_DISK) {
loadClipboardFromDisk();
}
@ -239,16 +243,20 @@ public class BukkitPlayer extends AbstractPlayerActor {
* Permissions are used to managing WorldEdit region restrictions
* - The `/wea` command will give/remove the required bypass permission
*/
boolean usesuperperms = VaultResolver.perms == null;
if (VaultResolver.perms != null) {
if (value) {
if (!VaultResolver.perms.playerAdd(player, permission)) {
player.addAttachment(plugin).setPermission(permission, value);
}
} else if (!VaultResolver.perms.playerRemove(player, permission)) {
player.addAttachment(plugin).setPermission(permission, value);
usesuperperms = true;
}
} else {
player.addAttachment(plugin).setPermission(permission, value);
if (!VaultResolver.perms.playerRemove(player, permission)) {
usesuperperms = true;
}
}
}
if (usesuperperms) {
permAttachment.setPermission(permission, value);
}
}

Datei anzeigen

@ -174,11 +174,13 @@ public class PlayerProxy extends AbstractPlayerActor {
return permActor.hasPermission(perm);
}
@Override public boolean togglePermission(String permission) {
return permActor.hasPermission(permission);
@Override
public boolean togglePermission(String permission) {
return permActor.togglePermission(permission);
}
@Override public void setPermission(String permission, boolean value) {
@Override
public void setPermission(String permission, boolean value) {
permActor.setPermission(permission, value);
}