From 3752f3f14570e791ce3bdae2ca214f95d9ce7e09 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 22 Dec 2023 17:06:39 +0100 Subject: [PATCH 1/4] Update BauMemberPermission --- CommonCore | 2 +- src/de/steamwar/bungeecore/ServerStarter.java | 23 ++++++--- .../bungeecore/commands/BauCommand.java | 51 ++++++++----------- .../steamwar/messages/BungeeCore.properties | 14 ++--- .../messages/BungeeCore_de.properties | 14 ++--- 5 files changed, 53 insertions(+), 51 deletions(-) diff --git a/CommonCore b/CommonCore index e664c6cf..c8be79ed 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit e664c6cf4e3e9a056918cf15030c247e7bc6fe19 +Subproject commit c8be79ed73f13746882a461914cc031f1ed6da24 diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index a2b4ea84..e2ab6079 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -1,9 +1,6 @@ package de.steamwar.bungeecore; -import de.steamwar.sql.EventFight; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.Team; -import de.steamwar.sql.Tutorial; +import de.steamwar.sql.*; import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -128,14 +125,26 @@ public class ServerStarter { // Send players to existing server startCondition = () -> { + boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> { + BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId()); + if (bauweltMember == null) return false; + return bauweltMember.isSupervisor() || player.getUniqueId().equals(owner); + }); for(Subserver subserver : Subserver.getServerList()) { if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)) { - for(ProxiedPlayer p : playersToSend) - SubserverSystem.sendPlayer(subserver, p); + if (!subserver.getServer().getPlayers().isEmpty() || atLeastOneSupervisor) { + for(ProxiedPlayer p : playersToSend) + SubserverSystem.sendPlayer(subserver, p); + } return false; } } - return true; + if (!atLeastOneSupervisor) { + for (ProxiedPlayer p : playersToSend) { + ChatSender.of(p).system("BAU_START_NOT_ALLOWED"); + } + } + return atLeastOneSupervisor; }; return this; diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 097423e4..3df6a91d 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -174,52 +174,52 @@ public class BauCommand extends SWCommand { Chat19.chat(p, "/bauinfo"); } - @Register("togglewe") - public void togglewe(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { + @Register("setspectator") + public void setSpectator(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { if (user == null) { - Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe"); + Message.send("BAU_MEMBER_SET_USAGE", p, "setspectator"); return; } BauweltMember target = member(p, user); if (target == null) return; - target.setWorldEdit(!target.isWorldEdit()); + target.setBuild(false); + target.setSupervisor(false); clearMembercache(p); - isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); + sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SPECTATOR"); } - @Register("toggleworld") - public void toggleworld(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { + @Register("setbuild") + public void setBuild(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { if (user == null) { - Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld"); + Message.send("BAU_MEMBER_SET_USAGE", p, "setbuild"); return; } BauweltMember target = member(p, user); if (target == null) return; - target.setWorld(!target.isWorld()); + target.setBuild(true); + target.setSupervisor(false); clearMembercache(p); - isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD"); + sendPermissionUpdate(p, target, "BAU_MEMBER_SET_BUILDER"); } - @Register("toggleall") - public void toggleall(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { + @Register("setsupervisor") + public void setSupervisor(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) { if (user == null) { - Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleall"); + Message.send("BAU_MEMBER_SET_USAGE", p, "setsupervisor"); return; } BauweltMember target = member(p, user); if (target == null) return; - boolean state = !target.isWorldEdit() || !target.isWorld(); - target.setWorldEdit(state); - target.setWorld(state); + target.setBuild(true); + target.setSupervisor(true); clearMembercache(p); - isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); - isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD"); + sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SUPERVISOR"); } private static void clearMembercache(ProxiedPlayer p){ @@ -337,17 +337,10 @@ public class BauCommand extends SWCommand { return target; } - private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){ + private static void sendPermissionUpdate(ProxiedPlayer p, BauweltMember target, String what){ ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID()); - - if(permission){ - if(player != null) - Message.send("BAU_MEMBER_TOGGLE_TARGET", player, p.getName(), Message.parse(what, player)); - Message.send("BAU_MEMBER_TOGGLE", p, Message.parse(what, p)); - }else{ - if(player != null) - Message.send("BAU_MEMBER_TOGGLE_TARGET_OFF", player, p.getName(), Message.parse(what, player)); - Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p)); - } + if(player != null) + Message.send("BAU_MEMBER_SET_TARGET", player, p.getName(), Message.parse(what, player)); + Message.send("BAU_MEMBER_SET", p, Message.parse(what, p)); } } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 88210e5e..05b8528e 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -226,13 +226,13 @@ BAU_DELETE_GUI_CANCEL=§cCancel BAU_DELETE_GUI_DELETE=§aDelete BAU_START_ALREADY=§cThis server is already starting. BAU_MEMBER_NOMEMBER=§cThis player is no member of your world! -BAU_MEMBER_TOGGLE_USAGE=§8/§7build {0} §8[§eplayer§8] -BAU_MEMBER_TOGGLE_TARGET=§aYou are now allowed to §a{1}§e on the world of §e{0}. -BAU_MEMBER_TOGGLE=§aThe player is now allowed to {0}. -BAU_MEMBER_TOGGLE_TARGET_OFF=§cYou are no longer allowed to §a{1}§e on the world of §e{0}. -BAU_MEMBER_TOGGLE_OFF=§cThe player no longer can {0}. -BAU_MEMBER_TOGGLE_WORLD_EDIT = use WorldEdit -BAU_MEMBER_TOGGLE_WORLD = change Settings +BAU_MEMBER_SET_USAGE=§8/§7build {0} §8[§eplayer§8] +BAU_MEMBER_SET_TARGET=§aYou are now §a{1}§e on the world of §e{0}. +BAU_MEMBER_SET=§aThe player is now {0}. +BAU_MEMBER_SET_SPECTATOR = a spectator +BAU_MEMBER_SET_BUILDER = a builder +BAU_MEMBER_SET_SUPERVISOR = a supervisor +BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 9274e247..043b1fe9 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -209,13 +209,13 @@ BAU_DELETE_GUI_CANCEL=§cAbbrechen BAU_DELETE_GUI_DELETE=§aLöschen BAU_START_ALREADY=§cDer Server startet bereits. BAU_MEMBER_NOMEMBER=§cDer Spieler ist kein Mitglied deiner Welt! -BAU_MEMBER_TOGGLE_USAGE=§8/§7bau {0} §8[§eSpieler§8] -BAU_MEMBER_TOGGLE_TARGET=§aDu kannst nun auf der Welt von §e{0}§a {1}. -BAU_MEMBER_TOGGLE=§aDer Spieler darf nun {0}. -BAU_MEMBER_TOGGLE_TARGET_OFF=§cDu kannst nun nicht mehr auf der Welt von §e{0}§c {1}. -BAU_MEMBER_TOGGLE_OFF=§cDer Spieler darf nun nicht mehr {0}. -BAU_MEMBER_TOGGLE_WORLD_EDIT = WorldEdit verwenden -BAU_MEMBER_TOGGLE_WORLD = Einstellungen vornehmen +BAU_MEMBER_SET_USAGE=§8/§7bau {0} §8[§eSpieler§8] +BAU_MEMBER_SET_TARGET=§aDu bist nun {1} auf der Welt von §e{0}§a. +BAU_MEMBER_SET=§aDer Spieler ist nun {0}. +BAU_MEMBER_SET_SPECTATOR = ein Zuschauer +BAU_MEMBER_SET_BUILDER = ein Builder +BAU_MEMBER_SET_SUPERVISOR = ein Supervisor +BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8] From 443a1b29c96c32b54d484706edbba8309fa052c5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 16:30:47 +0100 Subject: [PATCH 2/4] Fix messages Fix ServerStarter condition --- src/de/steamwar/bungeecore/ServerStarter.java | 4 +++- src/de/steamwar/messages/BungeeCore.properties | 11 ++++++----- src/de/steamwar/messages/BungeeCore_de.properties | 11 ++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index e2ab6079..371045b6 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -127,7 +127,6 @@ public class ServerStarter { startCondition = () -> { boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> { BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId()); - if (bauweltMember == null) return false; return bauweltMember.isSupervisor() || player.getUniqueId().equals(owner); }); for(Subserver subserver : Subserver.getServerList()) { @@ -135,6 +134,9 @@ public class ServerStarter { if (!subserver.getServer().getPlayers().isEmpty() || atLeastOneSupervisor) { for(ProxiedPlayer p : playersToSend) SubserverSystem.sendPlayer(subserver, p); + } else { + for(ProxiedPlayer p : playersToSend) + ChatSender.of(p).system("BAU_JOIN_NOT_ALLOWED"); } return false; } diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 05b8528e..08a8ba13 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -227,12 +227,13 @@ BAU_DELETE_GUI_DELETE=§aDelete BAU_START_ALREADY=§cThis server is already starting. BAU_MEMBER_NOMEMBER=§cThis player is no member of your world! BAU_MEMBER_SET_USAGE=§8/§7build {0} §8[§eplayer§8] -BAU_MEMBER_SET_TARGET=§aYou are now §a{1}§e on the world of §e{0}. -BAU_MEMBER_SET=§aThe player is now {0}. -BAU_MEMBER_SET_SPECTATOR = a spectator -BAU_MEMBER_SET_BUILDER = a builder -BAU_MEMBER_SET_SUPERVISOR = a supervisor +BAU_MEMBER_SET_TARGET=§7You are now a §e{1}§7 on the world of §e{0}§7. +BAU_MEMBER_SET=§7The player is now a §e{0}§7. +BAU_MEMBER_SET_SPECTATOR = spectator +BAU_MEMBER_SET_BUILDER = builder +BAU_MEMBER_SET_SUPERVISOR = supervisor BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server +BAU_JOIN_NOT_ALLOWED = §cYou are not allowed to join this build server. No supervisor is present. #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 043b1fe9..44d6f928 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -210,12 +210,13 @@ BAU_DELETE_GUI_DELETE=§aLöschen BAU_START_ALREADY=§cDer Server startet bereits. BAU_MEMBER_NOMEMBER=§cDer Spieler ist kein Mitglied deiner Welt! BAU_MEMBER_SET_USAGE=§8/§7bau {0} §8[§eSpieler§8] -BAU_MEMBER_SET_TARGET=§aDu bist nun {1} auf der Welt von §e{0}§a. -BAU_MEMBER_SET=§aDer Spieler ist nun {0}. -BAU_MEMBER_SET_SPECTATOR = ein Zuschauer -BAU_MEMBER_SET_BUILDER = ein Builder -BAU_MEMBER_SET_SUPERVISOR = ein Supervisor +BAU_MEMBER_SET_TARGET=§7Du bist nun ein §e{1}§7 auf der Welt von §e{0}§7. +BAU_MEMBER_SET=§7Der Spieler ist nun §e{0}§7. +BAU_MEMBER_SET_SPECTATOR = Zuschauer +BAU_MEMBER_SET_BUILDER = Builder +BAU_MEMBER_SET_SUPERVISOR = Supervisor BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten +BAU_JOIN_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht betreten. Kein Supervisor auf dem Server. #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8] From 9688c3895437648538c24b61d163f50a899288c6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 16:44:52 +0100 Subject: [PATCH 3/4] Revert ServerStarter.builder startCondition --- src/de/steamwar/bungeecore/ServerStarter.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/ServerStarter.java b/src/de/steamwar/bungeecore/ServerStarter.java index 5a5a7197..fdea7c1c 100644 --- a/src/de/steamwar/bungeecore/ServerStarter.java +++ b/src/de/steamwar/bungeecore/ServerStarter.java @@ -131,16 +131,17 @@ public class ServerStarter { // Send players to existing server startCondition = () -> { - boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> { - BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId()); - return bauweltMember.isSupervisor() || player.getUniqueId().equals(owner); - }); Bauserver subserver = Bauserver.get(owner); if(subserver != null) { for(ProxiedPlayer p : playersToSend) SubserverSystem.sendPlayer(subserver, p); return false; } + boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> { + if (player.getUniqueId().equals(owner)) return true; + BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId()); + return bauweltMember.isSupervisor(); + }); if (!atLeastOneSupervisor) { for (ProxiedPlayer p : playersToSend) { ChatSender.of(p).system("BAU_START_NOT_ALLOWED"); @@ -198,12 +199,11 @@ public class ServerStarter { // Send players to existing server startCondition = () -> { - for(Subserver subserver : Subserver.getServerList()) { - if(subserver.getType() == Servertype.BUILDER && ((Builderserver)subserver).getMap().equals(worldName)) { - for(ProxiedPlayer p : playersToSend) - SubserverSystem.sendPlayer(subserver, p); - return false; - } + Builderserver subserver = Builderserver.get(worldName); + if (subserver != null) { + for(ProxiedPlayer p : playersToSend) + SubserverSystem.sendPlayer(subserver, p); + return false; } return true; }; From 04ebed15d3231da987124811bc66ee1c66df74ba Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 19 Jan 2024 16:47:53 +0100 Subject: [PATCH 4/4] Revert ServerStarter.builder startCondition Fix CommonCore --- CommonCore | 2 +- src/de/steamwar/messages/BungeeCore.properties | 3 +-- src/de/steamwar/messages/BungeeCore_de.properties | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CommonCore b/CommonCore index c8be79ed..e7952685 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit c8be79ed73f13746882a461914cc031f1ed6da24 +Subproject commit e7952685d279b9e59a668e31c9466cd426521a14 diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 08a8ba13..62711c3d 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -232,8 +232,7 @@ BAU_MEMBER_SET=§7The player is now a §e{0}§7. BAU_MEMBER_SET_SPECTATOR = spectator BAU_MEMBER_SET_BUILDER = builder BAU_MEMBER_SET_SUPERVISOR = supervisor -BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server -BAU_JOIN_NOT_ALLOWED = §cYou are not allowed to join this build server. No supervisor is present. +BAU_START_NOT_ALLOWED = §cYou are not allowed to start this build server. #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eplayer§8] diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 44d6f928..31989cd2 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -215,8 +215,7 @@ BAU_MEMBER_SET=§7Der Spieler ist nun §e{0}§7. BAU_MEMBER_SET_SPECTATOR = Zuschauer BAU_MEMBER_SET_BUILDER = Builder BAU_MEMBER_SET_SUPERVISOR = Supervisor -BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten -BAU_JOIN_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht betreten. Kein Supervisor auf dem Server. +BAU_START_NOT_ALLOWED = §cDu darfst diesen Bauserver nicht starten. #ChallengeCommand CHALLENGE_USAGE=§8/§7challenge §8[§eSpieler§8]