Skip to content

Commit

Permalink
Team
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Nov 7, 2020
1 parent ab096b2 commit 3115a5a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/main/java/net/teamfruit/sushida/player/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +30,7 @@ public class Group {
private ImmutableList<Map.Entry<String, String>> wordRequiredList;

private Scoreboard groupScoreboard;
private Team groupTeam;
private Objective scoreLeaderboard;
private Objective tabLeaderboard;

Expand Down Expand Up @@ -62,6 +66,10 @@ public boolean hasRanking() {
return ranking != null;
}

public Team getGroupTeam() {
return groupTeam;
}

public Scoreboard getGroupScoreboard() {
return groupScoreboard;
}
Expand Down Expand Up @@ -139,6 +147,13 @@ public ImmutableList<Map.Entry<String, String>> 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();
Expand Down
13 changes: 8 additions & 5 deletions src/main/java/net/teamfruit/sushida/player/PlayerData.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3115a5a

Please sign in to comment.