From 5efc840c11fdcf33ed5e6c6d3d0cd3fa07fd6df8 Mon Sep 17 00:00:00 2001 From: Yuanlin Date: Mon, 9 Aug 2021 02:18:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[team]=20trying=20to=20fix=20tea?= =?UTF-8?q?m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/linyuanlin/minecraft/App.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/linyuanlin/minecraft/App.java b/src/main/java/com/linyuanlin/minecraft/App.java index 1762868..9863f57 100644 --- a/src/main/java/com/linyuanlin/minecraft/App.java +++ b/src/main/java/com/linyuanlin/minecraft/App.java @@ -170,18 +170,21 @@ public boolean onCommand(CommandSender sender, Command cmd, String cmdlable, Str } case "list": { StringBuilder teamMemberNameString = new StringBuilder(); - for (int i = 0; i < allPlayers.get(p1.getUniqueId()).team.get().size(); i++) { - teamMemberNameString - .append(allPlayers.get(p1.getUniqueId()).team.get().playerList.get(i).player.getName()) - .append(" "); + Optional team = allPlayers.get(p1.getUniqueId()).team; + + if (!team.isPresent()) { + p1.sendMessage("你沒隊伍拉"); + return false; } - TextComponent msg = new TextComponent("隊伍成員:" + teamMemberNameString); - for (int i = 0; i < allPlayers.get(p1.getUniqueId()).team.get().size(); i++) { - allPlayers.get(p1.getUniqueId()).team.get().playerList.get(i).player.spigot().sendMessage(msg); + + for (PlayerData pd : team.get().playerList) { + teamMemberNameString.append(pd.player.getName()).append(" "); } + TextComponent msg = new TextComponent("隊伍成員:" + teamMemberNameString); + p1.spigot().sendMessage(msg); } - break; + break; default: break; }