diff --git a/build.gradle b/build.gradle index 6ef9302..da2d223 100755 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,7 @@ repositories { } maven { url = "https://maven.enginehub.org/repo/" } + //maven { url 'https://nexus.byteandbit.cloud/repository/maven-releases/' } maven { url 'https://repo.spongepowered.org/repository/maven-public/' } /*maven { @@ -61,9 +62,10 @@ def jarArtifact = artifacts.add('archives', jarFile.get().asFile) { dependencies { compileOnly 'com.github.Minestom:Minestom:-SNAPSHOT' //compileOnly("net.pixelravens:PixelLib:b114") - implementation('com.google.guava:guava:31.1-jre') + compileOnly('com.google.guava:guava:31.1-jre') compileOnly("com.sk89q.worldedit:worldedit-core:7.2.12") compileOnly('org.spongepowered:configurate-yaml:4.1.2'); + compileOnly 'com.github.MinestomPlugins:lib-permissions:5a9310e71f' } shadowJar { diff --git a/src/main/java/io/github/openminigameserver/worldedit/MinestomWorldEdit.java b/src/main/java/io/github/openminigameserver/worldedit/MinestomWorldEdit.java index b73e683..0b689f2 100755 --- a/src/main/java/io/github/openminigameserver/worldedit/MinestomWorldEdit.java +++ b/src/main/java/io/github/openminigameserver/worldedit/MinestomWorldEdit.java @@ -10,6 +10,7 @@ import com.sk89q.worldedit.world.item.ItemType; import io.github.openminigameserver.worldedit.platform.MinestomPlatform; import io.github.openminigameserver.worldedit.platform.adapters.MinestomAdapter; +import io.github.openminigameserver.worldedit.platform.adapters.MinestomPermissionProvider; import io.github.openminigameserver.worldedit.platform.config.WorldEditConfiguration; import net.minestom.server.extensions.Extension; import net.minestom.server.instance.block.Block; @@ -49,6 +50,7 @@ public void initialize() { registerBlocks(); registerItems(); + MinestomPermissionProvider.init(); } private void loadConfig() { diff --git a/src/main/java/io/github/openminigameserver/worldedit/platform/adapters/MinestomPermissionProvider.java b/src/main/java/io/github/openminigameserver/worldedit/platform/adapters/MinestomPermissionProvider.java index c69e8a4..fccf619 100755 --- a/src/main/java/io/github/openminigameserver/worldedit/platform/adapters/MinestomPermissionProvider.java +++ b/src/main/java/io/github/openminigameserver/worldedit/platform/adapters/MinestomPermissionProvider.java @@ -1,16 +1,21 @@ package io.github.openminigameserver.worldedit.platform.adapters; +import me.window.permissions.PermissionProvider; import net.minestom.server.entity.Player; public class MinestomPermissionProvider { + + public static PermissionProvider provider; + + public static void init() { + provider = new PermissionProvider(4, "worldedit"); + } public static boolean hasPermission(Player player, String permission) { - if (player.hasPermission("*") || player.hasPermission("worldedit.*") || player.getPermissionLevel() >= 4) - return true; - return player.hasPermission(permission); + return provider.hasExtensionPermission(player, permission); } public static boolean hasWorldEditPermission(Player player) { - return player.hasPermission("*") || player.hasPermission("worldedit") || player.getPermissionLevel() >= 4; + return provider.hasExtensionPermission(player); } } diff --git a/src/main/java/io/github/openminigameserver/worldedit/platform/misc/WorldEditCommand.java b/src/main/java/io/github/openminigameserver/worldedit/platform/misc/WorldEditCommand.java index 29d97e1..b4ea920 100755 --- a/src/main/java/io/github/openminigameserver/worldedit/platform/misc/WorldEditCommand.java +++ b/src/main/java/io/github/openminigameserver/worldedit/platform/misc/WorldEditCommand.java @@ -61,7 +61,7 @@ private boolean condition(final CommandSender sender, final String command) { InjectedValueStore store = MapBackedValueStore.create(); store.injectValue(Key.of(Actor.class), context -> Optional.of(new MinestomPlayer(MinestomAdapter.platform, (Player) sender))); - return cmd.getCondition().satisfied(store); + return cmd.getCondition().satisfied(store) && MinestomPermissionProvider.hasWorldEditPermission((Player) sender); } @Override diff --git a/src/main/resources/extension.json b/src/main/resources/extension.json index 7054d23..e590b7a 100755 --- a/src/main/resources/extension.json +++ b/src/main/resources/extension.json @@ -13,11 +13,15 @@ "externalDependencies": { "repositories": [ {"name": "sponge", "url": "https://repo.spongepowered.org/repository/maven-public/" }, - {"name": "enginehub", "url": "https://maven.enginehub.org/repo/" } + {"name": "enginehub", "url": "https://maven.enginehub.org/repo/" }, + {"name": "jitpack", "url": "https://jitpack.io" }, + {"name": "Central", "url": "https://repo1.maven.org/maven2/"} ], "artifacts": [ "org.spongepowered:configurate-yaml:4.1.2", - "com.sk89q.worldedit:worldedit-core:7.2.12" + "com.sk89q.worldedit:worldedit-core:7.2.12", + "com.github.MinestomPlugins:lib-permissions:5a9310e71f", + "com.google.guava:guava:31.1-jre" ] } }