From 944f5d87b71a4b93f00a295c28e09d33a5531263 Mon Sep 17 00:00:00 2001 From: sleepymalc Date: Tue, 17 Aug 2021 02:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8C[main/TeamManager]=20Change=20every?= =?UTF-8?q?=20attribute=20into=20private?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/linyuanlin/minecraft/App.java | 2 +- .../minecraft/Manager/GuildManager.java | 18 +-- .../minecraft/Manager/TeamManager.java | 110 +++++++++--------- .../minecraft/Manager/TradeManager.java | 45 +++---- .../minecraft/models/PlayerData.java | 34 +++++- .../com/linyuanlin/minecraft/models/Team.java | 9 +- .../minecraft/models/WorldData.java | 1 - 7 files changed, 124 insertions(+), 95 deletions(-) diff --git a/src/main/java/com/linyuanlin/minecraft/App.java b/src/main/java/com/linyuanlin/minecraft/App.java index ba4a2f3..2554881 100644 --- a/src/main/java/com/linyuanlin/minecraft/App.java +++ b/src/main/java/com/linyuanlin/minecraft/App.java @@ -247,7 +247,7 @@ public void onPlayerInteract(PlayerInteractEntityEvent event1) { Entity entity = event1.getRightClicked(); if (entity instanceof Player && event1.getHand() == EquipmentSlot.HAND) { p.sendMessage("他是 " + entity.getName()); - p.sendMessage("該玩家擁有財產 " + allPlayers.get(entity.getUniqueId()).getBalance() + " 元"); + p.sendMessage("該玩家擁有財產 " + allPlayers.get(entity.getUniqueId()).balance() + " 元"); TextComponent a = new TextComponent("[傳送組隊邀請]"); a.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("點擊發送組隊邀請給 " + entity.getName()))); a.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team invite " + entity.getName())); diff --git a/src/main/java/com/linyuanlin/minecraft/Manager/GuildManager.java b/src/main/java/com/linyuanlin/minecraft/Manager/GuildManager.java index 5e93546..65a8307 100644 --- a/src/main/java/com/linyuanlin/minecraft/Manager/GuildManager.java +++ b/src/main/java/com/linyuanlin/minecraft/Manager/GuildManager.java @@ -50,14 +50,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } private boolean getInvitationPaper(PlayerData senderPlayer) { - if (senderPlayer.getBalance() < 1000) { - senderPlayer.player.sendMessage( - "你的錢不夠購買公會創立卷! " + ChatColor.RED + "(" + senderPlayer.getBalance() + "/1000)"); + if (senderPlayer.balance() < 1000) { + senderPlayer.player().sendMessage( + "你的錢不夠購買公會創立卷! " + ChatColor.RED + "(" + senderPlayer.balance() + "/1000)"); return false; } senderPlayer.modifyBalance(-1000, "Buy Guild Invitation Paper"); - senderPlayer.player.sendMessage("你已成功購買公會創立卷! " + senderPlayer.getBalanceString()); - senderPlayer.player.getInventory().addItem(new ItemStack(CustomItem.guildInvitationPaper)); + senderPlayer.player().sendMessage("你已成功購買公會創立卷! " + senderPlayer.getBalanceString()); + senderPlayer.player().getInventory().addItem(new ItemStack(CustomItem.guildInvitationPaper)); return true; } @@ -71,12 +71,12 @@ private boolean second(PlayerData senderPlayer, String[] args) { } private boolean help(PlayerData senderPlayer) { - senderPlayer.player.sendMessage(ChatColor.RED + "沒有這個指令"); - senderPlayer.player.sendMessage(ChatColor.AQUA + "/guild 的使用方式:"); + senderPlayer.player().sendMessage(ChatColor.RED + "沒有這個指令"); + senderPlayer.player().sendMessage(ChatColor.AQUA + "/guild 的使用方式:"); - senderPlayer.player.sendMessage("/guild getInvitationPaper" + ChatColor.GRAY + " - 獲得公會創立卷"); + senderPlayer.player().sendMessage("/guild getInvitationPaper" + ChatColor.GRAY + " - 獲得公會創立卷"); - senderPlayer.player.sendMessage(ChatColor.GRAY + "/guild help - 取得幫助"); + senderPlayer.player().sendMessage(ChatColor.GRAY + "/guild help - 取得幫助"); return false; } } diff --git a/src/main/java/com/linyuanlin/minecraft/Manager/TeamManager.java b/src/main/java/com/linyuanlin/minecraft/Manager/TeamManager.java index cf29c6b..333f51a 100644 --- a/src/main/java/com/linyuanlin/minecraft/Manager/TeamManager.java +++ b/src/main/java/com/linyuanlin/minecraft/Manager/TeamManager.java @@ -82,54 +82,54 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command */ private boolean invite(PlayerData senderPlayer, String[] args) { if (args.length != 2) { - senderPlayer.player.sendMessage(ChatColor.RED + "邀請指令錯誤"); + senderPlayer.player().sendMessage(ChatColor.RED + "邀請指令錯誤"); this.help(senderPlayer); return false; } Player p = Bukkit.getPlayer(args[1]); if (p == null) { - senderPlayer.player.sendMessage( + senderPlayer.player().sendMessage( "你邀請的玩家 " + ChatColor.GOLD + args[1] + ChatColor.WHITE + " 不存在或是不在線上!"); return false; } PlayerData receiverPlayer = app.allPlayers.get(p.getUniqueId()); if (receiverPlayer == null) { - senderPlayer.player.sendMessage("你邀請的玩家 " + ChatColor.GOLD + args[1] + ChatColor.WHITE + senderPlayer.player().sendMessage("你邀請的玩家 " + ChatColor.GOLD + args[1] + ChatColor.WHITE + " 不存在於allPlayers中,請聯繫開發人員"); return false; } - Optional team = app.allPlayers.get(receiverPlayer.player.getUniqueId()).team; + Optional team = app.allPlayers.get(receiverPlayer.player().getUniqueId()).team(); if (receiverPlayer == senderPlayer) { - senderPlayer.player.sendMessage("不能邀請自己"); + senderPlayer.player().sendMessage("不能邀請自己"); return false; } if (team.isPresent()) { - senderPlayer.player.sendMessage( - ChatColor.GOLD + receiverPlayer.player.getName() + ChatColor.WHITE + "已經有隊伍了!"); + senderPlayer.player().sendMessage(ChatColor.GOLD + receiverPlayer.player().getName() + + ChatColor.WHITE + "已經有隊伍了!"); return false; } if (senderPlayer.isInviteCooling(receiverPlayer)) { - senderPlayer.player.sendMessage("邀請" + ChatColor.GOLD + receiverPlayer.player.getName() + senderPlayer.player().sendMessage("邀請" + ChatColor.GOLD + receiverPlayer.player().getName() + ChatColor.WHITE + "冷卻中" + ChatColor.RED + "(1分鐘)"); return false; } TextComponent msg; - msg = new TextComponent( - "[確認 " + ChatColor.GOLD + senderPlayer.player.getName() + ChatColor.WHITE + " 的組隊邀請]"); + msg = new TextComponent("[確認 " + ChatColor.GOLD + senderPlayer.player().getName() + ChatColor.WHITE + + " 的組隊邀請]"); msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("點擊接受 " + ChatColor.GOLD - + senderPlayer.player.getName() + ChatColor.WHITE + " 的組隊邀請"))); + + senderPlayer.player().getName() + ChatColor.WHITE + " 的組隊邀請"))); msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, - "/team join " + senderPlayer.player.getName())); - receiverPlayer.player.spigot().sendMessage(msg); + "/team join " + senderPlayer.player().getName())); + receiverPlayer.player().spigot().sendMessage(msg); - senderPlayer.player.sendMessage("已發送邀請給 " + ChatColor.GOLD + receiverPlayer.player.getName()); + senderPlayer.player().sendMessage("已發送邀請給 " + ChatColor.GOLD + receiverPlayer.player().getName()); senderPlayer.recordInvite(receiverPlayer); return true; @@ -158,36 +158,36 @@ private boolean invite(PlayerData senderPlayer, String[] args) { */ private boolean join(PlayerData senderPlayer, String[] args) throws Exception { if (args.length != 2) { - senderPlayer.player.sendMessage("組隊指令錯誤"); + senderPlayer.player().sendMessage("組隊指令錯誤"); this.help(senderPlayer); return false; } Player p = Bukkit.getPlayer(args[1]); if (p == null) { - senderPlayer.player.sendMessage( + senderPlayer.player().sendMessage( "你要加入的隊伍的邀請人 " + ChatColor.GOLD + args[1] + ChatColor.WHITE + " 不存在或是不在線上!"); return false; } PlayerData receiverPlayer = app.allPlayers.get(p.getUniqueId()); if (receiverPlayer == null) { - senderPlayer.player.sendMessage("你要加入的隊伍的邀請人" + ChatColor.GOLD + args[1] + ChatColor.WHITE + senderPlayer.player().sendMessage("你要加入的隊伍的邀請人" + ChatColor.GOLD + args[1] + ChatColor.WHITE + "不存在於allPlayers中, 請聯繫開發人員"); return false; } - if (senderPlayer.team.isPresent()) { - senderPlayer.player.sendMessage("你已有隊伍"); + if (senderPlayer.team().isPresent()) { + senderPlayer.player().sendMessage("你已有隊伍"); return false; } if (!senderPlayer.isInvitedBy(receiverPlayer)) { - senderPlayer.player.sendMessage("你並沒有被邀請至 " + ChatColor.GOLD + receiverPlayer.player.getName() - + ChatColor.WHITE + " 的隊伍"); + senderPlayer.player().sendMessage("你並沒有被邀請至 " + ChatColor.GOLD + + receiverPlayer.player().getName() + ChatColor.WHITE + " 的隊伍"); return false; } - Optional team = receiverPlayer.team; + Optional team = receiverPlayer.team(); TextComponent msg; if (!team.isPresent()) { @@ -199,11 +199,11 @@ private boolean join(PlayerData senderPlayer, String[] args) throws Exception { e.printStackTrace(); } - receiverPlayer.team = Optional.of(newTeam); - senderPlayer.team = Optional.of(newTeam); + receiverPlayer.replaceTeam(Optional.of(newTeam)); + senderPlayer.replaceTeam(Optional.of(newTeam)); - msg = new TextComponent(ChatColor.GOLD + senderPlayer.player.getName() + ChatColor.WHITE + "已加入" - + senderPlayer.teamCapacityStatus()); + msg = new TextComponent(ChatColor.GOLD + senderPlayer.player().getName() + ChatColor.WHITE + + "已加入" + senderPlayer.teamCapacityStatus()); receiverPlayer.destroyInvitedRecord(); } else if (!team.get().isFull()) { @@ -213,17 +213,17 @@ private boolean join(PlayerData senderPlayer, String[] args) throws Exception { e.printStackTrace(); } - senderPlayer.team = team; + senderPlayer.replaceTeam(team); - msg = new TextComponent(ChatColor.GOLD + senderPlayer.player.getName() + ChatColor.WHITE + "已加入" - + senderPlayer.teamCapacityStatus()); + msg = new TextComponent(ChatColor.GOLD + senderPlayer.player().getName() + ChatColor.WHITE + + "已加入" + senderPlayer.teamCapacityStatus()); } else { - senderPlayer.player.sendMessage("隊伍已滿"); + senderPlayer.player().sendMessage("隊伍已滿"); return false; } - receiverPlayer.team.ifPresent(t -> t.sendMessageToAll(msg)); + receiverPlayer.team().ifPresent(t -> t.sendMessageToAll(msg)); senderPlayer.destroyInvitedRecord(); @@ -243,17 +243,17 @@ private boolean join(PlayerData senderPlayer, String[] args) throws Exception { * */ private boolean list(PlayerData senderPlayer) { - Optional team = senderPlayer.team; + Optional team = senderPlayer.team(); if (!team.isPresent()) { - senderPlayer.player.sendMessage("你不在任何隊伍裡"); + senderPlayer.player().sendMessage("你不在任何隊伍裡"); return false; } - senderPlayer.player.spigot() + senderPlayer.player().spigot() .sendMessage(new TextComponent("隊伍成員:" + team.get().allTeamMemberString() + ChatColor.GRAY + " | " + ChatColor.WHITE + "隊長:" + ChatColor.GOLD - + team.get().leader().player.getName())); + + team.get().leader().player().getName())); return true; } @@ -274,19 +274,19 @@ private boolean list(PlayerData senderPlayer) { * */ private boolean leave(PlayerData senderPlayer) { - Optional team = senderPlayer.team; + Optional team = senderPlayer.team(); if (!team.isPresent()) { - senderPlayer.player.spigot().sendMessage(new TextComponent("你沒有隊伍")); + senderPlayer.player().spigot().sendMessage(new TextComponent("你沒有隊伍")); return false; } if (team.get().size() == 2) { - team.get().sendMessageToAll(new TextComponent(ChatColor.GOLD + senderPlayer.player.getName() + team.get().sendMessageToAll(new TextComponent(ChatColor.GOLD + senderPlayer.player().getName() + ChatColor.WHITE + " 離開了隊伍, 隊伍人數不足,自動解散")); try { team.get().delete(senderPlayer); team.get().delete(team.get().leader()); - team.get().leader().team = Optional.empty(); + team.get().leader().replaceTeam(Optional.empty()); } catch (Exception e) { e.printStackTrace(); } @@ -297,26 +297,28 @@ private boolean leave(PlayerData senderPlayer) { } catch (Exception e) { e.printStackTrace(); } - senderPlayer.team.ifPresent(t -> t.sendMessageToAll(new TextComponent("隊長 " - + ChatColor.GOLD + senderPlayer.player.getName() + ChatColor.WHITE - + " 離開了隊伍, 新隊長為" + ChatColor.GOLD + team.get().leader().player.getName() - + senderPlayer.teamCapacityStatus()))); + senderPlayer.team() + .ifPresent(t -> t.sendMessageToAll(new TextComponent("隊長 " + + ChatColor.GOLD + senderPlayer.player().getName() + + ChatColor.WHITE + " 離開了隊伍, 新隊長為" + ChatColor.GOLD + + team.get().leader().player().getName() + + senderPlayer.teamCapacityStatus()))); } else { try { team.get().delete(senderPlayer); } catch (Exception e) { e.printStackTrace(); } - senderPlayer.team.ifPresent(t -> t.sendMessageToAll(new TextComponent( - "隊員 " + ChatColor.GOLD + senderPlayer.player.getName() + ChatColor.WHITE - + " 離開了隊伍" + senderPlayer.teamCapacityStatus()))); + senderPlayer.team().ifPresent(t -> t.sendMessageToAll(new TextComponent("隊員 " + + ChatColor.GOLD + senderPlayer.player().getName() + ChatColor.WHITE + + " 離開了隊伍" + senderPlayer.teamCapacityStatus()))); } } else { return false; } - senderPlayer.team = Optional.empty(); - senderPlayer.player.spigot().sendMessage(new TextComponent("你離開了隊伍")); + senderPlayer.replaceTeam(Optional.empty()); + senderPlayer.player().spigot().sendMessage(new TextComponent("你離開了隊伍")); return true; } @@ -334,14 +336,14 @@ private boolean leave(PlayerData senderPlayer) { * */ private boolean help(PlayerData senderPlayer) { - senderPlayer.player.sendMessage(ChatColor.RED + "沒有這個指令"); - senderPlayer.player.sendMessage(ChatColor.AQUA + "/team 的使用方式:"); + senderPlayer.player().sendMessage(ChatColor.RED + "沒有這個指令"); + senderPlayer.player().sendMessage(ChatColor.AQUA + "/team 的使用方式:"); - senderPlayer.player.sendMessage("/team invite <對象>" + ChatColor.GRAY + " - 邀請其他玩家加入隊伍"); - senderPlayer.player.sendMessage("/team join <對象>" + ChatColor.GRAY + " - 加入其他玩家的隊伍"); - senderPlayer.player.sendMessage("/team list" + ChatColor.GRAY + " - 顯示隊伍狀態"); + senderPlayer.player().sendMessage("/team invite <對象>" + ChatColor.GRAY + " - 邀請其他玩家加入隊伍"); + senderPlayer.player().sendMessage("/team join <對象>" + ChatColor.GRAY + " - 加入其他玩家的隊伍"); + senderPlayer.player().sendMessage("/team list" + ChatColor.GRAY + " - 顯示隊伍狀態"); - senderPlayer.player.sendMessage(ChatColor.GRAY + "/team help - 取得幫助"); + senderPlayer.player().sendMessage(ChatColor.GRAY + "/team help - 取得幫助"); return false; } } diff --git a/src/main/java/com/linyuanlin/minecraft/Manager/TradeManager.java b/src/main/java/com/linyuanlin/minecraft/Manager/TradeManager.java index 9607c43..fe008f5 100644 --- a/src/main/java/com/linyuanlin/minecraft/Manager/TradeManager.java +++ b/src/main/java/com/linyuanlin/minecraft/Manager/TradeManager.java @@ -49,14 +49,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command } private boolean me(PlayerData senderPlayer) { - senderPlayer.player.sendMessage( - ChatColor.GRAY + "當前可用餘額:" + ChatColor.WHITE + senderPlayer.getBalance() + " 元"); + senderPlayer.player().sendMessage( + ChatColor.GRAY + "當前可用餘額:" + ChatColor.WHITE + senderPlayer.balance() + " 元"); return true; } private boolean pay(PlayerData senderPlayer, String[] args) { if (args.length != 3) { - senderPlayer.player.sendMessage(ChatColor.RED + "轉帳指令錯誤"); + senderPlayer.player().sendMessage(ChatColor.RED + "轉帳指令錯誤"); this.help(senderPlayer); return false; } @@ -65,52 +65,53 @@ private boolean pay(PlayerData senderPlayer, String[] args) { int amount = Integer.parseInt(amountStr); if (amount <= 0) { - senderPlayer.player.sendMessage(ChatColor.RED + "請輸入正確的轉帳金額!(轉帳金額不能為負數)"); + senderPlayer.player().sendMessage(ChatColor.RED + "請輸入正確的轉帳金額!(轉帳金額不能為負數)"); return false; } - if (senderPlayer.getBalance() < amount) { - senderPlayer.player.sendMessage(ChatColor.GOLD + "你沒那麼多錢拉,窮逼。"); + if (senderPlayer.balance() < amount) { + senderPlayer.player().sendMessage(ChatColor.GOLD + "你沒那麼多錢拉,窮逼。"); return false; } Player p = Bukkit.getPlayer(receiverName); if (p == null) { - senderPlayer.player.sendMessage( + senderPlayer.player().sendMessage( "玩家 " + ChatColor.GOLD + receiverName + ChatColor.WHITE + " 不存在或是不在線上"); return false; } PlayerData receiverPlayer = app.allPlayers.get(p.getUniqueId()); if (receiverPlayer == null) { - senderPlayer.player.sendMessage( + senderPlayer.player().sendMessage( "玩家 " + ChatColor.GOLD + receiverName + ChatColor.WHITE + " 不存在或是不在線上"); return false; } - receiverPlayer.modifyBalance(amount, "Receive transfer from " + senderPlayer.player.getName() + " (" - + senderPlayer.player.getUniqueId() + ")"); - receiverPlayer.player.sendMessage(ChatColor.GREEN + "收到來自玩家 " + ChatColor.WHITE - + senderPlayer.player.getName() + ChatColor.GREEN + " 的轉帳 " + ChatColor.WHITE + receiverPlayer.modifyBalance(amount, "Receive transfer from " + senderPlayer.player().getName() + " (" + + senderPlayer.player().getUniqueId() + ")"); + receiverPlayer.player().sendMessage(ChatColor.GREEN + "收到來自玩家 " + ChatColor.WHITE + + senderPlayer.player().getName() + ChatColor.GREEN + " 的轉帳 " + ChatColor.WHITE + amountStr + ChatColor.GREEN + " 元 " + receiverPlayer.getBalanceString()); - senderPlayer.modifyBalance(-amount, "Transfer to " + receiverPlayer.player.getName() + " (" - + receiverPlayer.player.getUniqueId() + ")"); - senderPlayer.player.sendMessage(ChatColor.GREEN + "成功轉帳 " + ChatColor.WHITE + amountStr - + ChatColor.GREEN + " 元給玩家 " + ChatColor.WHITE + receiverPlayer.player.getName() - + ChatColor.GREEN + " 了~ " + senderPlayer.getBalanceString()); + senderPlayer.modifyBalance(-amount, "Transfer to " + receiverPlayer.player().getName() + " (" + + receiverPlayer.player().getUniqueId() + ")"); + senderPlayer.player() + .sendMessage(ChatColor.GREEN + "成功轉帳 " + ChatColor.WHITE + amountStr + ChatColor.GREEN + + " 元給玩家 " + ChatColor.WHITE + receiverPlayer.player().getName() + + ChatColor.GREEN + " 了~ " + senderPlayer.getBalanceString()); return true; } private boolean help(PlayerData senderPlayer) { - senderPlayer.player.sendMessage(ChatColor.RED + "沒有這個指令"); - senderPlayer.player.sendMessage(ChatColor.AQUA + "/trade 的使用方式:"); + senderPlayer.player().sendMessage(ChatColor.RED + "沒有這個指令"); + senderPlayer.player().sendMessage(ChatColor.AQUA + "/trade 的使用方式:"); - senderPlayer.player.sendMessage("/trade pay <對象> <金額>" + ChatColor.GRAY + " - 向其他玩家轉帳"); - senderPlayer.player.sendMessage("/trade me" + ChatColor.GRAY + " - 查看自己的經濟狀況"); + senderPlayer.player().sendMessage("/trade pay <對象> <金額>" + ChatColor.GRAY + " - 向其他玩家轉帳"); + senderPlayer.player().sendMessage("/trade me" + ChatColor.GRAY + " - 查看自己的經濟狀況"); - senderPlayer.player.sendMessage(ChatColor.GRAY + "/trade help - 取得幫助"); + senderPlayer.player().sendMessage(ChatColor.GRAY + "/trade help - 取得幫助"); return false; } diff --git a/src/main/java/com/linyuanlin/minecraft/models/PlayerData.java b/src/main/java/com/linyuanlin/minecraft/models/PlayerData.java index f8905bc..9633aec 100644 --- a/src/main/java/com/linyuanlin/minecraft/models/PlayerData.java +++ b/src/main/java/com/linyuanlin/minecraft/models/PlayerData.java @@ -15,9 +15,9 @@ import java.util.concurrent.TimeUnit; public class PlayerData { - public Player player; - public Optional team; - public Optional guild; + private Player player; + private Optional team; + private Optional guild; private final HashMap invitedTimeMap; private final HashMap inviteTimeMap; private final App app; @@ -81,10 +81,26 @@ public void logOut() throws Exception { this.destroyInviteRecord(); } + /********** + * player * + *********/ + + public Player player() { + return this.player; + } + /******** * team * *******/ + public Optional team() { + return this.team; + } + + public void replaceTeam(Optional team) { + this.team = team; + } + /* * Record the invitation records when player invite p */ @@ -180,7 +196,7 @@ public void modifyBalance(int delta, String reason) { /** * Get player's balance */ - public int getBalance() { + public int balance() { return this.balance; } @@ -188,6 +204,14 @@ public int getBalance() { * Get player's balance string */ public String getBalanceString() { - return ChatColor.GRAY + "(餘額: " + this.getBalance() + ")"; + return ChatColor.GRAY + "(餘額: " + this.balance() + ")"; + } + + /********* + * guild * + ********/ + + public Optional guild() { + return this.guild; } } diff --git a/src/main/java/com/linyuanlin/minecraft/models/Team.java b/src/main/java/com/linyuanlin/minecraft/models/Team.java index c9c3d48..dd6b337 100644 --- a/src/main/java/com/linyuanlin/minecraft/models/Team.java +++ b/src/main/java/com/linyuanlin/minecraft/models/Team.java @@ -25,7 +25,7 @@ public int size() { public void sendMessageToAll(TextComponent msg) { for (PlayerData pd : this.playerList) { - pd.player.spigot().sendMessage(msg); + pd.player().spigot().sendMessage(msg); } } @@ -46,12 +46,14 @@ public void add(PlayerData p) { if (leader == null) { leader = p; } + this.playerList.add(p); } public void delete(PlayerData p) { - if (this.leader == p) + if (this.leader == p) { this.newLeader(); + } this.playerList.remove(p); } @@ -67,8 +69,9 @@ public PlayerData leader() { public String allTeamMemberString() { StringBuilder teamMemberNameString = new StringBuilder(); for (PlayerData pd : this.playerList) { - teamMemberNameString.append(pd.player.getName()).append(" "); + teamMemberNameString.append(pd.player().getName()).append(" "); } + return ChatColor.GOLD + teamMemberNameString.toString(); } } diff --git a/src/main/java/com/linyuanlin/minecraft/models/WorldData.java b/src/main/java/com/linyuanlin/minecraft/models/WorldData.java index d2aabbf..d745e08 100644 --- a/src/main/java/com/linyuanlin/minecraft/models/WorldData.java +++ b/src/main/java/com/linyuanlin/minecraft/models/WorldData.java @@ -3,7 +3,6 @@ import org.bukkit.World; public class WorldData { - private String worldId; private String worldName; private String worldDescription;