From a61f1e2c8c6f002aacb401e0aee06dd0a9efa7a6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Dec 2023 18:08:48 +0100 Subject: [PATCH] Fix Permission for ServerLib.getBlockAt and setBlockAt and exec --- BauSystem_Main/src/de/steamwar/bausystem/Permission.java | 2 +- .../de/steamwar/bausystem/features/bau/InfoCommand.java | 5 +++-- .../bausystem/features/script/lua/SteamWarLuaPlugin.java | 1 + .../bausystem/features/script/lua/libs/ServerLib.java | 7 +++++++ .../bausystem/features/world/AxiomPermissionCheck.java | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java index b25e0fb1..50251be3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/Permission.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/Permission.java @@ -56,7 +56,7 @@ public enum Permission { return this != SPECTATOR; } BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId()); - if (bauweltMember == null) return false; + if (bauweltMember == null) return this == SPECTATOR; return permissionPredicate.test(bauweltMember); } } \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index cdd481ea..1a7e1551 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -47,10 +47,11 @@ public class InfoCommand extends SWCommand { StringBuilder membermessage = new StringBuilder(); membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); - for (BauweltMember member : members) { - if (!membermessage.isEmpty()) { + for (int i = 0; i < members.size(); i++) { + if (i != 0) { membermessage.append(", "); } + BauweltMember member = members.get(i); if (Permission.SUPERVISOR.hasPermission(member)) { membermessage.append("§c").append(SteamwarUser.get(member.getMemberID()).getUserName()); } else if (Permission.BUILD.hasPermission(member)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java index b2bf51cc..4aefce8f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/SteamWarLuaPlugin.java @@ -123,6 +123,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction { return LuaValue.NIL; } + command = preprocessEvent.getMessage().substring(1); Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); String[] commandSplit = command.split(" "); if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java index 80134fba..be55dcdd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/lua/libs/ServerLib.java @@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.script.lua.libs; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.core.TPSWatcher; import de.steamwar.inventory.SWItem; @@ -50,6 +51,9 @@ public class ServerLib implements LuaLib { serverLib.set("getBlockAt", new OneArgFunction() { @Override public LuaValue call(LuaValue arg1) { + if (!Permission.SUPERVISOR.hasPermission(player)) { + return LuaValue.NIL; + } LuaTable pos = arg1.checktable(); return valueOf(player.getWorld().getBlockAt(pos.get("x").checkint(), pos.get("y").checkint(), pos.get("z").checkint()).getType().name()); } @@ -57,6 +61,9 @@ public class ServerLib implements LuaLib { serverLib.set("setBlockAt", new TwoArgFunction() { @Override public LuaValue call(LuaValue arg1, LuaValue arg2) { + if (!Permission.SUPERVISOR.hasPermission(player)) { + return LuaValue.NIL; + } LuaTable pos = arg1.checktable(); LuaString material = arg2.checkstring(); Material mat = SWItem.getMaterial(material.tojstring()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java index e006e184..bdfe3d40 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AxiomPermissionCheck.java @@ -32,7 +32,7 @@ public class AxiomPermissionCheck implements Listener { @EventHandler public void onAxiomHandshake(AxiomHandshakeEvent event) { - if (Permission.BUILD.hasPermission(event.getPlayer())) return; + if (!Permission.BUILD.hasPermission(event.getPlayer())) return; event.setCancelled(true); } }