From 7d5d8bd7575cafc067c26f9a57b9445f064175ea Mon Sep 17 00:00:00 2001 From: wea_ondara Date: Thu, 8 Jun 2023 14:33:00 +0200 Subject: [PATCH] essentials bridge: update to essentialsX 2.20.0 --- pom.xml | 916 +++++++++--------- .../essentials/BungeePermsHandler.java | 67 +- 2 files changed, 521 insertions(+), 462 deletions(-) diff --git a/pom.xml b/pom.xml index 7514d47..cd0c41f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,459 +1,459 @@ - - 4.0.0 - net.alpenblock - BungeePerms - 4.0 - - - UTF-8 - 1.8 - 1.8 - ${project.version} - SNAPSHOT - 1 - ${build.major}-${build.type}-${build.number} - ${build.major} ${build.type} #${build.number} - ${project.artifactId}-${build.fullversion.file} - ${build.name}.${project.packaging} - ${build.name}-sources.${project.packaging} - ${build.name}-javadoc.${project.packaging} - - - - - localdeployrepo - wea_ondara's Repository - https://repo.wea-ondara.net/repository/maven-releases/ - - - - - - bungee-repo - https://oss.sonatype.org/content/groups/public/ - - - md5-snapshot - https://repo.md-5.net/content/repositories/snapshots/ - - - md_5-releases - https://repo.md-5.net/content/repositories/releases/ - - - md_5-public - https://repo.md-5.net/content/groups/public/ - - - spigot-repo - https://hub.spigotmc.org/nexus/content/groups/public/ - - - essentials-repo - https://repo.essentialsx.net/releases/ - - - sk89q-repo - https://maven.enginehub.org/repo/ - - - vault-repo - https://nexus.hc.to/content/repositories/pub_releases - - - placeholderapi - https://repo.extendedclip.com/content/repositories/placeholderapi/ - - - CodeMC - https://repo.codemc.org/repository/maven-public - - - velocity - https://repo.velocitypowered.com/snapshots/ - - - repository - - true - ignore - always - - - true - ignore - always - - file://${project.basedir}/lib/repository/ - - - - - java9plus - - [1.9,) - - - 8 - - - - java11plus - - [1.11,) - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - true - - -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED - -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED - - - - - maven-surefire-plugin - 2.12.4 - - - --illegal-access=permit - - - - - - - - - ${build.name} - src/main/java - - - src/main/resources - true - - - - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - add-source - generate-sources - - add-source - - - - target/generated-sources/velocity - - - - - - - maven-compiler-plugin - 3.7.0 - - - default-compile - compile - - compile - - - ${maven.compiler.source} - ${maven.compiler.target} - ${project.build.sourceEncoding} - - net/alpenblock/bungeeperms/platform/velocity/VelocityPlugin.java - - - - - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-shade-plugin - 3.1.1 - - - - com.mojang:AccountsClient - com.google.code.gson:gson - org.bstats:bstats-bukkit - org.bstats:bstats-bungeecord - org.yaml:snakeyaml - mysql:mysql-connector-java - - - - - org.bstats.bukkit - net.alpenblock.bungeeperms.metrics.bukkit - - - org.bstats.bungeecord - net.alpenblock.bungeeperms.metrics.bungee - - - com.mojang - net.alpenblock.bungeeperms.libs.com.mojang - - - com.google.gson - net.alpenblock.bungeeperms.libs.com.google.gson - - - com.mysql - net.alpenblock.bungeeperms.libs.com.mysql - - - org.yaml - net.alpenblock.bungeeperms.libs.org.yaml - - - - - - package - - shade - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.1.0 - - ${build.name} - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - default-install - none - - - - install-file - - install - - target/${build.filename} - false - pom.xml - ${build.fullversion.file} - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - - default-deploy - none - - - deploy - deploy - - deploy-file - - - ${project.distributionManagement.repository.id} - ${project.distributionManagement.repository.url} - ${project.groupId} - ${project.artifactId} - ${build.fullversion.file} - target/${build.filename} - - - - - - - - - - com.google.code.maven-replacer-plugin - maven-replacer-plugin - 1.4.0 - - - generate-sources - - replace - - - src/main/java/net/alpenblock/bungeeperms/platform/velocity/VelocityPlugin.java - target/generated-sources/velocity/VelocityPlugin.java - - - @version@ - ${build.fullversion.resource} - - - - - - - - - - - net.md-5 - bungeecord-api - 1.12-SNAPSHOT - - - com.velocitypowered - velocity-api - 3.0.0-SNAPSHOT - - - org.projectlombok - lombok - 1.18.0 - - - com.mojang - AccountsClient - 0.0.1-SNAPSHOT - - - org.spigotmc - spigot-api - 1.12-R0.1-SNAPSHOT - - - com.sk89q - worldedit - 5.6.2 - - - net.milkbowl.vault - Vault - 1.2.32 - - - net.ess3 - EssentialsX - 2.18.0 - - - me.clip - placeholderapi - 2.10.3 - provided - - - org.bstats - bstats-bukkit - 1.5 - compile - - - org.bstats - bstats-bungeecord - 1.5 - compile - - - org.yaml - snakeyaml - 1.18 - - - mysql - mysql-connector-java - 8.0.16 - - - net.kyori - adventure-api - 4.8.1 - jar - - + + 4.0.0 + net.alpenblock + BungeePerms + 4.0 + + + UTF-8 + 1.8 + 1.8 + ${project.version} + SNAPSHOT + 1 + ${build.major}-${build.type}-${build.number} + ${build.major} ${build.type} #${build.number} + ${project.artifactId}-${build.fullversion.file} + ${build.name}.${project.packaging} + ${build.name}-sources.${project.packaging} + ${build.name}-javadoc.${project.packaging} + + + + + localdeployrepo + wea_ondara's Repository + https://repo.wea-ondara.net/repository/maven-releases/ + + + + + + bungee-repo + https://oss.sonatype.org/content/groups/public/ + + + md5-snapshot + https://repo.md-5.net/content/repositories/snapshots/ + + + md_5-releases + https://repo.md-5.net/content/repositories/releases/ + + + md_5-public + https://repo.md-5.net/content/groups/public/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + essentials-repo + https://repo.essentialsx.net/releases/ + + + sk89q-repo + https://maven.enginehub.org/repo/ + + + vault-repo + https://nexus.hc.to/content/repositories/pub_releases + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + CodeMC + https://repo.codemc.org/repository/maven-public + + + velocity + https://repo.velocitypowered.com/snapshots/ + + + repository + + true + ignore + always + + + true + ignore + always + + file://${project.basedir}/lib/repository/ + + + + + java9plus + + [1.9,) + + + 8 + + + + java11plus + + [1.11,) + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED + + + + + maven-surefire-plugin + 2.12.4 + + + --illegal-access=permit + + + + + + + + + ${build.name} + src/main/java + + + src/main/resources + true + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-source + generate-sources + + add-source + + + + target/generated-sources/velocity + + + + + + + maven-compiler-plugin + 3.7.0 + + + default-compile + compile + + compile + + + ${maven.compiler.source} + ${maven.compiler.target} + ${project.build.sourceEncoding} + + net/alpenblock/bungeeperms/platform/velocity/VelocityPlugin.java + + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.1 + + + + com.mojang:AccountsClient + com.google.code.gson:gson + org.bstats:bstats-bukkit + org.bstats:bstats-bungeecord + org.yaml:snakeyaml + mysql:mysql-connector-java + + + + + org.bstats.bukkit + net.alpenblock.bungeeperms.metrics.bukkit + + + org.bstats.bungeecord + net.alpenblock.bungeeperms.metrics.bungee + + + com.mojang + net.alpenblock.bungeeperms.libs.com.mojang + + + com.google.gson + net.alpenblock.bungeeperms.libs.com.google.gson + + + com.mysql + net.alpenblock.bungeeperms.libs.com.mysql + + + org.yaml + net.alpenblock.bungeeperms.libs.org.yaml + + + + + + package + + shade + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + ${build.name} + + + + org.apache.maven.plugins + maven-install-plugin + 2.5.2 + + + default-install + none + + + + install-file + + install + + target/${build.filename} + false + pom.xml + ${build.fullversion.file} + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.7 + + + default-deploy + none + + + deploy + deploy + + deploy-file + + + ${project.distributionManagement.repository.id} + ${project.distributionManagement.repository.url} + ${project.groupId} + ${project.artifactId} + ${build.fullversion.file} + target/${build.filename} + + + + + + + + + + com.google.code.maven-replacer-plugin + maven-replacer-plugin + 1.4.0 + + + generate-sources + + replace + + + src/main/java/net/alpenblock/bungeeperms/platform/velocity/VelocityPlugin.java + target/generated-sources/velocity/VelocityPlugin.java + + + @version@ + ${build.fullversion.resource} + + + + + + + + + + + net.md-5 + bungeecord-api + 1.12-SNAPSHOT + + + com.velocitypowered + velocity-api + 3.0.0-SNAPSHOT + + + org.projectlombok + lombok + 1.18.0 + + + com.mojang + AccountsClient + 0.0.1-SNAPSHOT + + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + + + com.sk89q + worldedit + 5.6.2 + + + net.milkbowl.vault + Vault + 1.2.32 + + + net.essentialsx + EssentialsX + 2.20.0 + + + me.clip + placeholderapi + 2.10.3 + provided + + + org.bstats + bstats-bukkit + 1.5 + compile + + + org.bstats + bstats-bungeecord + 1.5 + compile + + + org.yaml + snakeyaml + 1.18 + + + mysql + mysql-connector-java + 8.0.16 + + + net.kyori + adventure-api + 4.8.1 + jar + + \ No newline at end of file diff --git a/src/main/java/net/alpenblock/bungeeperms/platform/bukkit/bridge/bridges/essentials/BungeePermsHandler.java b/src/main/java/net/alpenblock/bungeeperms/platform/bukkit/bridge/bridges/essentials/BungeePermsHandler.java index fb8326b..7464682 100644 --- a/src/main/java/net/alpenblock/bungeeperms/platform/bukkit/bridge/bridges/essentials/BungeePermsHandler.java +++ b/src/main/java/net/alpenblock/bungeeperms/platform/bukkit/bridge/bridges/essentials/BungeePermsHandler.java @@ -16,16 +16,21 @@ */ package net.alpenblock.bungeeperms.platform.bukkit.bridge.bridges.essentials; +import com.earth2me.essentials.Essentials; import com.earth2me.essentials.perm.IPermissionsHandler; import java.util.ArrayList; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; +import java.util.stream.Collectors; + +import com.earth2me.essentials.utils.TriState; import net.alpenblock.bungeeperms.BungeePerms; import net.alpenblock.bungeeperms.Group; import net.alpenblock.bungeeperms.Statics; import net.alpenblock.bungeeperms.User; import net.alpenblock.bungeeperms.platform.bukkit.BukkitSender; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; class BungeePermsHandler implements IPermissionsHandler @@ -39,7 +44,41 @@ public BungeePermsHandler() } @Override - public String getGroup(Player player) + public boolean addToGroup(OfflinePlayer player, String group) { + User u = perms.getPermissionsManager().getUser(player.getName()); + if (u == null) + return false; + + Group g = perms.getPermissionsManager().getGroup(group); + if (g == null) + return false; + + if (u.getGroups().contains(g)) + return false; + + perms.getPermissionsManager().addUserGroup(u, g, null, null); + return true; + } + + @Override + public boolean removeFromGroup(OfflinePlayer player, String group) { + User u = perms.getPermissionsManager().getUser(player.getName()); + if (u == null) + return false; + + Group g = perms.getPermissionsManager().getGroup(group); + if (g == null) + return false; + + if (!u.getGroups().contains(g)) + return false; + + perms.getPermissionsManager().removeUserGroup(u, g, null, null); + return true; + } + + @Override + public String getGroup(OfflinePlayer player) { User u = perms.getPermissionsManager().getUser(player.getName()); if (u == null) @@ -51,7 +90,7 @@ public String getGroup(Player player) } @Override - public List getGroups(Player player) + public List getGroups(OfflinePlayer player) { User u = perms.getPermissionsManager().getUser(player.getName()); if (u == null) @@ -60,6 +99,11 @@ public List getGroups(Player player) return new ArrayList(u.getGroupsString()); } + @Override + public List getGroups() { + return perms.getPermissionsManager().getGroups().stream().map(Group::getName).collect(Collectors.toList()); + } + @Override public boolean canBuild(Player player, String group) { @@ -119,13 +163,28 @@ public boolean isPermissionSet(Player player, String string) } @Override - public boolean tryProvider() + public TriState isPermissionSetExact(Player player, String string) { + User u = perms.getPermissionsManager().getUser(player.getName()); + if (u == null) + return TriState.FALSE; + + BukkitSender sender = new BukkitSender(player); + return u.getEffectivePerms(sender.getServer(), sender.getWorld()).stream() + .filter(e -> e.getPermission().equals(string.toLowerCase())) + .findFirst() + .map(e -> e.getPermission().equalsIgnoreCase(string)) + .map(e -> e ? TriState.TRUE : TriState.FALSE) + .orElse(TriState.UNSET); + } + + @Override + public boolean tryProvider(Essentials ess) { return true; } @Override - public void registerContext(String context, Function> calculator, Supplier> suggestions) + public void registerContext(String context, Function> calculator, Supplier> suggestions) { }