aboutsummaryrefslogtreecommitdiff
path: root/spark-forge/src/main/java
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2022-12-10 10:01:58 +0000
committerLuck <git@lucko.me>2022-12-10 10:01:58 +0000
commit521cf8889ea4938b93691233178640fea06db69e (patch)
tree5b52a478dbabb9e8d4b46d1109bcffd7f8985acf /spark-forge/src/main/java
parent1536537473aa5dead4c7353444e217df30d2ad96 (diff)
downloadspark-521cf8889ea4938b93691233178640fea06db69e.tar.gz
spark-521cf8889ea4938b93691233178640fea06db69e.tar.bz2
spark-521cf8889ea4938b93691233178640fea06db69e.zip
Give integrated server host all permissions
Diffstat (limited to 'spark-forge/src/main/java')
-rw-r--r--spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
index 8ac0c7c..8737057 100644
--- a/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
+++ b/spark-forge/src/main/java/me/lucko/spark/forge/plugin/ForgeServerSparkPlugin.java
@@ -78,6 +78,19 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
plugin.enable();
}
+ private static final PermissionResolver<Boolean> DEFAULT_PERMISSION_VALUE = (player, playerUUID, context) -> {
+ if (player == null) {
+ return false;
+ }
+
+ MinecraftServer server = player.getServer();
+ if (server != null && server.isSingleplayerOwner(player.getGameProfile())) {
+ return true;
+ }
+
+ return player.hasPermissions(4);
+ };
+
private final MinecraftServer server;
private final ThreadDumper gameThreadDumper;
private Map<String, PermissionNode<Boolean>> registeredPermissions = Collections.emptyMap();
@@ -116,8 +129,6 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
@SubscribeEvent
public void onPermissionGather(PermissionGatherEvent.Nodes e) {
- PermissionResolver<Boolean> defaultValue = (player, playerUUID, context) -> player != null && player.hasPermissions(4);
-
// collect all possible permissions
List<String> permissions = this.platform.getCommands().stream()
.map(me.lucko.spark.common.command.Command::primaryAlias)
@@ -143,7 +154,7 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command<
continue;
}
- PermissionNode<Boolean> node = new PermissionNode<>("spark", permission, PermissionTypes.BOOLEAN, defaultValue);
+ PermissionNode<Boolean> node = new PermissionNode<>("spark", permission, PermissionTypes.BOOLEAN, DEFAULT_PERMISSION_VALUE);
e.addNodes(node);
builder.put(permissionString, node);
}