Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from Window5000/dev
Browse files Browse the repository at this point in the history
Update permission handling
  • Loading branch information
Codestech1 authored Dec 11, 2022
2 parents 35872c0 + 26a7fdf commit 82e51c0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,6 +50,7 @@ public void initialize() {

registerBlocks();
registerItems();
MinestomPermissionProvider.init();
}

private void loadConfig() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/main/resources/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}

0 comments on commit 82e51c0

Please sign in to comment.