From 521cf8889ea4938b93691233178640fea06db69e Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 10 Dec 2022 10:01:58 +0000 Subject: Give integrated server host all permissions --- .../spark/forge/plugin/ForgeServerSparkPlugin.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'spark-forge/src/main/java/me') 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 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> registeredPermissions = Collections.emptyMap(); @@ -116,8 +129,6 @@ public class ForgeServerSparkPlugin extends ForgeSparkPlugin implements Command< @SubscribeEvent public void onPermissionGather(PermissionGatherEvent.Nodes e) { - PermissionResolver defaultValue = (player, playerUUID, context) -> player != null && player.hasPermissions(4); - // collect all possible permissions List 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 node = new PermissionNode<>("spark", permission, PermissionTypes.BOOLEAN, defaultValue); + PermissionNode node = new PermissionNode<>("spark", permission, PermissionTypes.BOOLEAN, DEFAULT_PERMISSION_VALUE); e.addNodes(node); builder.put(permissionString, node); } -- cgit