3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 08:30:04 +01:00

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

Datei anzeigen

@ -174,11 +174,13 @@ public class PlayerProxy extends AbstractPlayerActor {
return permActor.hasPermission(perm); return permActor.hasPermission(perm);
} }
@Override public boolean togglePermission(String permission) { @Override
return permActor.hasPermission(permission); 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); permActor.setPermission(permission, value);
} }