From 00e08b5943e5c9e285041f4eeac58fa40ca7431b Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 26 Aug 2023 00:30:43 +0200 Subject: [PATCH 1/2] Bau toggleall Signed-off-by: Lixfel --- .../bungeecore/commands/BauCommand.java | 17 +++++++++++++++++ .../bungeecore/commands/HelpCommand.java | 3 +-- src/de/steamwar/messages/BungeeCore.properties | 2 ++ .../steamwar/messages/BungeeCore_de.properties | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index d59ff34e..bfdb397e 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -199,6 +199,23 @@ public class BauCommand extends SWCommand { isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD"); } + @Register("toggleall") + public void toggleall(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) { + if (user == null) { + Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleall"); + return; + } + BauweltMember target = member(p, user); + if (target == null) + return; + + target.setWorldEdit(!target.isWorldEdit()); + target.setWorld(!target.isWorld()); + clearMembercache(p); + isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); + isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD"); + } + private static void clearMembercache(ProxiedPlayer p){ for(ServerInfo info : ProxyServer.getInstance().getServers().values()){ Subserver server = Subserver.getSubserver(info); diff --git a/src/de/steamwar/bungeecore/commands/HelpCommand.java b/src/de/steamwar/bungeecore/commands/HelpCommand.java index 7da1ba7b..0aa879fc 100644 --- a/src/de/steamwar/bungeecore/commands/HelpCommand.java +++ b/src/de/steamwar/bungeecore/commands/HelpCommand.java @@ -22,10 +22,8 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; -import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.protocol.packet.Chat; public class HelpCommand extends SWCommand { @@ -93,6 +91,7 @@ public class HelpCommand extends SWCommand { "HELP_BAU_DELMEMBER", "/build delmember ", "HELP_BAU_TOGGLEWE", "/build togglewe ", "HELP_BAU_TOGGLEWORLD", "/build toggleworld ", + "HELP_BAU_TOGGLEALL", "/build toggleall ", "HELP_BAU_DELETE", "/build delete ", "HELP_BAU_TESTARENA", "/build testarena ", "HELP_BAU_LOCK", "/build lock ", diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index b4e339fc..eefe90e3 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -95,6 +95,8 @@ HELP_BAU_TOGGLEWE=§8/§ebuild togglewe §8- §7Permission to use WorldEdit, /te HELP_BAU_TOGGLEWE_HOVER=§eToggles WorldEdit permission HELP_BAU_TOGGLEWORLD=§8/§ebuild toggleworld §8- §7/reset, /trace, /fire, /tnt HELP_BAU_TOGGLEWORLD_HOVER=§eToggles world permission +HELP_BAU_TOGGLEALL=§8/§ebuild toggleall §8- §7WorldEdit and world +HELP_BAU_TOGGLEALL_HOVER=§eToggles WorldEdit and world permissions HELP_BAU_DELETE=§8/§ebuild delete §8- §7Reset your entire build server HELP_BAU_DELETE_HOVER=§eReset build server HELP_BAU_TESTARENA=§8/§ebuild testarena §8- §7Start a test arena diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 275c455c..29418025 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -81,6 +81,8 @@ HELP_BAU_TOGGLEWE=§8/§ebau togglewe §8- §7Berechtigung für WorldEdit, /test HELP_BAU_TOGGLEWE_HOVER=§eStellt Spielerberechtigungen ein HELP_BAU_TOGGLEWORLD=§8/§ebau toggleworld §8- §7/reset, /trace, /fire, /tnt HELP_BAU_TOGGLEWORLD_HOVER=§eStellt Spielerberechtigungen ein +HELP_BAU_TOGGLEALL=§8/§ebuild toggleall §8- §7WorldEdit und Weltberechtigungen +HELP_BAU_TOGGLEALL_HOVER=§eStellt Spielerberechtigungen ein HELP_BAU_DELETE=§8/§ebau delete §8- §7Setzt deine Bauwelt zurück HELP_BAU_DELETE_HOVER=§eBauwelt zurücksetzen HELP_BAU_TESTARENA=§8/§ebau testarena §8- §7Starte eine Testarena From 1e9b5ead353dc73d21a543fb4e67f7c06e25dded Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 31 Aug 2023 16:30:53 +0200 Subject: [PATCH 2/2] Fix behaviour Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/BauCommand.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index bfdb397e..a57870ac 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -209,8 +209,9 @@ public class BauCommand extends SWCommand { if (target == null) return; - target.setWorldEdit(!target.isWorldEdit()); - target.setWorld(!target.isWorld()); + boolean state = !target.isWorldEdit() || !target.isWorld(); + target.setWorldEdit(state); + target.setWorld(state); clearMembercache(p); isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD");