From 8b18636a6e1d6b0fd1db7fb031d702b8ce137fca Mon Sep 17 00:00:00 2001 From: david Date: Sun, 18 Aug 2024 18:54:28 +0200 Subject: [PATCH] Add VaultGroupManager for GroupManager integration This commit introduces the VaultGroupManager class for integrating the GroupManager plugin with Vault permissions. It implements various methods for managing player and group permissions, enabling seamless permission handling within different worlds. This ensures compatibility and enhanced functionality between Vault and GroupManager. --- .../hook/permission/VaultSuperPerms.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 plugin/src/main/java/net/thenextlvl/services/hook/permission/VaultSuperPerms.java diff --git a/plugin/src/main/java/net/thenextlvl/services/hook/permission/VaultSuperPerms.java b/plugin/src/main/java/net/thenextlvl/services/hook/permission/VaultSuperPerms.java new file mode 100644 index 0000000..c368865 --- /dev/null +++ b/plugin/src/main/java/net/thenextlvl/services/hook/permission/VaultSuperPerms.java @@ -0,0 +1,90 @@ +package net.thenextlvl.services.hook.permission; + +import lombok.Getter; +import net.milkbowl.vault.permission.Permission; +import org.bukkit.plugin.Plugin; + +@Getter +public class VaultSuperPerms extends Permission { + private final String name = "SuperPerms"; + + public VaultSuperPerms(Plugin plugin) { + this.plugin = plugin; + } + + @Override + public boolean isEnabled() { + return true; + } + + @Override + public boolean playerHas(String world, String name, String permission) { + var player = plugin.getServer().getPlayer(name); + return player != null && player.hasPermission(permission); + } + + @Override + public boolean playerAdd(String world, String player, String permission) { + return false; + } + + @Override + public boolean playerRemove(String world, String player, String permission) { + return false; + } + + @Override + public boolean groupHas(String world, String group, String permission) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean groupAdd(String world, String group, String permission) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean groupRemove(String world, String group, String permission) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean playerInGroup(String world, String player, String group) { + return playerHas(world, player, "groups." + group); + } + + @Override + public boolean playerAddGroup(String world, String player, String group) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean playerRemoveGroup(String world, String player, String group) { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getPlayerGroups(String world, String player) { + throw new UnsupportedOperationException(); + } + + @Override + public String getPrimaryGroup(String world, String player) { + throw new UnsupportedOperationException(); + } + + @Override + public String[] getGroups() { + return new String[0]; + } + + @Override + public boolean hasSuperPermsCompat() { + return true; + } + + @Override + public boolean hasGroupSupport() { + return false; + } +}