From 3752f3f14570e791ce3bdae2ca214f95d9ce7e09 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 22 Dec 2023 17:06:39 +0100 Subject: [PATCH] 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]