From 7f62ad8005c40bcc660145ccb6e45dbda906d25e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Feb 2024 15:22:48 +0100 Subject: [PATCH] Update InfoCommand output --- BauSystem_Main/src/BauSystem.properties | 2 +- BauSystem_Main/src/BauSystem_de.properties | 2 +- .../bausystem/features/bau/InfoCommand.java | 43 ++++++++++++------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 0f85ca56..c2210163 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -150,7 +150,7 @@ BAU_INFO_ITEM_LORE_ITEMS = §7Items§8: §e{0} BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Information regarding this build server BAU_INFO_COMMAND_OWNER = §7Owner§8: §e{0} -BAU_INFO_COMMAND_MEMBER = §7Member §8[§7{0}§8]§8: §e +BAU_INFO_COMMAND_MEMBER = §7{0} §8[§7{1}§8]§8: §e{2} BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1} BAU_INFO_COMMAND_TPS = §7TPS§8:§e diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 346e1dd1..43a2ba56 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -149,7 +149,7 @@ BAU_INFO_ITEM_LORE_PROTECT = §7Protect§8: §e{0} BAU_INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Gibt Informationen über den Bau BAU_INFO_COMMAND_OWNER = §7Besitzer§8: §e{0} -BAU_INFO_COMMAND_MEMBER = §7Mitglieder §8[§7{0}§8]§8: §e +BAU_INFO_COMMAND_MEMBER = §7{0} §8[§7{1}§8]§8: §e{2} BAU_INFO_COMMAND_FLAG = §7{0}§8: §7{1} BAU_INFO_COMMAND_TPS = §7TPS§8:§e 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 19d8aab5..b89c43b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -13,7 +13,7 @@ import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; -import java.util.List; +import java.util.*; @Linked public class InfoCommand extends SWCommand { @@ -41,24 +41,25 @@ public class InfoCommand extends SWCommand { if (Permission.BUILD.hasPermission(p)) { List members = BauweltMember.getMembers(bauServer.getOwnerID()); - StringBuilder membermessage = new StringBuilder(); - membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU_INFO_COMMAND_MEMBER", p, members.size())); - - for (int i = 0; i < members.size(); i++) { - if (i != 0) { - membermessage.append("§8, "); - } - BauweltMember member = members.get(i); + Map> memberByPermission = new HashMap<>(); + members.forEach(member -> { if (Permission.SUPERVISOR.hasPermission(member)) { - membermessage.append("§e"); + memberByPermission.computeIfAbsent(Permission.SUPERVISOR, __ -> new ArrayList<>()).add(member); } else if (Permission.BUILD.hasPermission(member)) { - membermessage.append("§6"); + memberByPermission.computeIfAbsent(Permission.BUILD, __ -> new ArrayList<>()).add(member); } else { - membermessage.append("§7"); + memberByPermission.computeIfAbsent(Permission.MEMBER, __ -> new ArrayList<>()).add(member); } - membermessage.append(SteamwarUser.get(member.getMemberID()).getUserName()); - } - p.sendMessage(membermessage.toString()); + }); + + List supervisor = memberByPermission.getOrDefault(Permission.SUPERVISOR, Collections.emptyList()); + BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§eSupervisor", supervisor.size(), supervisor.isEmpty() ? "§8" : joining(supervisor)); + + List builder = memberByPermission.getOrDefault(Permission.BUILD, Collections.emptyList()); + BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§6Builder", builder.size(), builder.isEmpty() ? "§8" : joining(builder)); + + List spectator = memberByPermission.getOrDefault(Permission.MEMBER, Collections.emptyList()); + BauSystem.MESSAGE.send("BAU_INFO_COMMAND_MEMBER", p, "§7Spectator", spectator.size(), spectator.isEmpty() ? "§8" : joining(spectator)); } StringBuilder tpsMessage = new StringBuilder(); @@ -70,4 +71,16 @@ public class InfoCommand extends SWCommand { tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); p.sendMessage(tpsMessage.toString()); } + + private String joining(List bauweltMembers) { + StringBuilder st = new StringBuilder(); + for (int i = 0; i < bauweltMembers.size(); i++) { + if (i != 0) { + st.append("§8, "); + } + st.append("§f"); + st.append(SteamwarUser.get(bauweltMembers.get(i).getMemberID()).getUserName()); + } + return st.toString(); + } }