diff --git a/src/main/java/net/teamfruit/sushida/player/Group.java b/src/main/java/net/teamfruit/sushida/player/Group.java index e6d2bfd..6082f99 100644 --- a/src/main/java/net/teamfruit/sushida/player/Group.java +++ b/src/main/java/net/teamfruit/sushida/player/Group.java @@ -9,12 +9,15 @@ import net.teamfruit.sushida.mode.GameSettingType; import net.teamfruit.sushida.ranking.RankingSetting; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Scoreboard; +import org.bukkit.scoreboard.Team; import javax.annotation.Nullable; import java.util.*; +import java.util.concurrent.ThreadLocalRandom; public class Group { public PlayerData owner; @@ -27,6 +30,7 @@ public class Group { private ImmutableList> wordRequiredList; private Scoreboard groupScoreboard; + private Team groupTeam; private Objective scoreLeaderboard; private Objective tabLeaderboard; @@ -62,6 +66,10 @@ public boolean hasRanking() { return ranking != null; } + public Team getGroupTeam() { + return groupTeam; + } + public Scoreboard getGroupScoreboard() { return groupScoreboard; } @@ -139,6 +147,13 @@ public ImmutableList> getWordList() { public void init() { wordRequiredList = getMode().getWords(this); + groupTeam = groupScoreboard.getTeam("sushida"); + if (this.groupTeam != null) + this.groupTeam.unregister(); + this.groupTeam = groupScoreboard.registerNewTeam("sushida"); + this.groupTeam.setPrefix(ChatColor.RED + "[␣]" + ChatColor.RESET); + this.groupTeam.setColor(ChatColor.WHITE); + this.scoreLeaderboard = groupScoreboard.getObjective("score"); if (this.scoreLeaderboard != null) this.scoreLeaderboard.unregister(); diff --git a/src/main/java/net/teamfruit/sushida/player/PlayerData.java b/src/main/java/net/teamfruit/sushida/player/PlayerData.java index 30749a5..c032d05 100644 --- a/src/main/java/net/teamfruit/sushida/player/PlayerData.java +++ b/src/main/java/net/teamfruit/sushida/player/PlayerData.java @@ -1,8 +1,8 @@ package net.teamfruit.sushida.player; +import net.teamfruit.sushida.BelowNameManager; import net.teamfruit.sushida.SoundManager; import net.teamfruit.sushida.Sushida; -import net.teamfruit.sushida.BelowNameManager; import net.teamfruit.sushida.player.state.NoneState; import net.teamfruit.sushida.player.state.TitleState; import org.bukkit.Bukkit; @@ -69,8 +69,9 @@ public boolean leave() { return b; } - public void joinScoreboard(Scoreboard newScoreboard) { - player.setScoreboard(newScoreboard); + public void joinScoreboard(Group group) { + player.setScoreboard(group.getGroupScoreboard()); + group.getGroupTeam().addEntry(player.getName()); } public void leaveScoreboard() { @@ -104,8 +105,7 @@ public void run() { } }.runTaskLaterAsynchronously(Sushida.plugin, 40); - if (!this.group.getMembers().isEmpty()) - joinScoreboard(this.group.getGroupScoreboard()); + joinScoreboard(this.group); Sushida.belowName.spawn(this); } @@ -114,6 +114,9 @@ public void destroy() { return; session.apply(StateContainer.supply(NoneState::new)); session = null; + + if (this.group.getMembers().isEmpty()) + leaveScoreboard(); Sushida.belowName.despawn(this); } } diff --git a/src/main/java/net/teamfruit/sushida/player/state/PlayPauseState.java b/src/main/java/net/teamfruit/sushida/player/state/PlayPauseState.java index f425f28..bd4f8be 100644 --- a/src/main/java/net/teamfruit/sushida/player/state/PlayPauseState.java +++ b/src/main/java/net/teamfruit/sushida/player/state/PlayPauseState.java @@ -14,7 +14,7 @@ public IState onEnter(StateContainer state) { Player player = state.data.player; player.sendTitle(new Title( - new ComponentBuilder("「/ 」").bold(true).color(ChatColor.GREEN).create(), + new ComponentBuilder("「/␣」").bold(true).color(ChatColor.GREEN).create(), new ComponentBuilder("スラッシュ+スペースで続行").bold(false).color(ChatColor.GREEN).create(), 0, 10000, 0)); diff --git a/src/main/java/net/teamfruit/sushida/player/state/TitleState.java b/src/main/java/net/teamfruit/sushida/player/state/TitleState.java index d991131..e72ad7a 100644 --- a/src/main/java/net/teamfruit/sushida/player/state/TitleState.java +++ b/src/main/java/net/teamfruit/sushida/player/state/TitleState.java @@ -95,7 +95,7 @@ public IState onTick(StateContainer state) { player.sendTitle(new Title( new ComponentBuilder("ⓘ チャット画面を使います").bold(true).color(ChatColor.BLUE).create(), - new ComponentBuilder("「/ 」スラッシュを押してからスペースを押すとスタートします").bold(false).color(ChatColor.AQUA).create(), + new ComponentBuilder("「/␣」スラッシュを押してからスペースを押すとスタートします").bold(false).color(ChatColor.AQUA).create(), 10, 0, 10)); if (state.titleBgmCount++ >= 7) {