Compare commits
No commits in common. "d412812dcbe4759cc500c372db21d9dd49480e21" and "416c44a8f31bdb274e1ffbccaec11094fd829f7a" have entirely different histories.
d412812dcb
...
416c44a8f3
|
|
@ -39,8 +39,7 @@ public class BaseCommand implements CommandExecutor, TabExecutor {
|
|||
new NextPhase(round),
|
||||
new EndRound(round),
|
||||
new Stuck(main),
|
||||
new Stats(statService),
|
||||
new ListPlayers(roundService)
|
||||
new Stats(statService)
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
package com.alttd.hunger_games.commands.subcommands;
|
||||
|
||||
import com.alttd.hunger_games.commands.SubCommand;
|
||||
import com.alttd.hunger_games.config.Messages;
|
||||
import com.alttd.hunger_games.data_objects.PLAYER_STATE;
|
||||
import com.alttd.hunger_games.services.RoundService;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ListPlayers extends SubCommand {
|
||||
|
||||
private final RoundService roundService;
|
||||
|
||||
public ListPlayers(RoundService roundService) {
|
||||
this.roundService = roundService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||
Set<UUID> registeredUuids = roundService.getPlayers(PLAYER_STATE.REGISTERED);
|
||||
Set<UUID> spectatingUuids = roundService.getPlayers(PLAYER_STATE.SPECTATING);
|
||||
|
||||
List<Component> registeredNames = registeredUuids.stream()
|
||||
.map(Bukkit::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::name)
|
||||
.toList();
|
||||
|
||||
List<Component> spectatingNames = spectatingUuids.stream()
|
||||
.map(Bukkit::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::name)
|
||||
.toList();
|
||||
|
||||
Component inGamePlayers = Component.join(JoinConfiguration.commas(true), registeredNames);
|
||||
Component spectators = Component.join(JoinConfiguration.commas(true), spectatingNames);
|
||||
|
||||
int inGameCount = registeredNames.size();
|
||||
int totalCount = inGameCount + spectatingNames.size();
|
||||
|
||||
commandSender.sendRichMessage(Messages.COMMANDS.LIST_PLAYERS,
|
||||
Placeholder.unparsed("in_game", String.valueOf(inGameCount)),
|
||||
Placeholder.unparsed("total", String.valueOf(totalCount)),
|
||||
Placeholder.component("in_game_players", inGamePlayers),
|
||||
Placeholder.component("spectators", spectators)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "list";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Messages.HELP.LIST;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@ public class Messages extends AbstractConfig {
|
|||
public static String RELOAD = "<green>Reload config and messages: <gold>/hg reload</gold></green>";
|
||||
public static String STUCK = "<green>Teleport to safety if stuck: <gold>/hg stuck</gold></green>";
|
||||
public static String STATS = "<green>Show player stats: <gold>/hg stats [player]</gold></green>";
|
||||
public static String LIST = "<green>List all players in the game and spectators: <gold>/hg list</gold></green>";
|
||||
public static String END_ROUND = "<green>End the game: <gold>/hg end</gold></green>";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
@ -47,7 +46,6 @@ public class Messages extends AbstractConfig {
|
|||
RELOAD = config.getString(prefix, "reload", RELOAD);
|
||||
STUCK = config.getString(prefix, "stuck", STUCK);
|
||||
STATS = config.getString(prefix, "stats", STATS);
|
||||
LIST = config.getString(prefix, "list", LIST);
|
||||
END_ROUND = config.getString(prefix, "end-round", END_ROUND);
|
||||
}
|
||||
}
|
||||
|
|
@ -212,15 +210,10 @@ public class Messages extends AbstractConfig {
|
|||
private static final String prefix = "commands.";
|
||||
|
||||
public static String NEXT_PHASE_SUCCESS = "<green>Skipping to the next phase/stage.</green>";
|
||||
public static String LIST_PLAYERS = """
|
||||
<gold>HungerGames Players (<in_game>/<total>):</gold>
|
||||
<green>In Game: <white><in_game_players></white></green>
|
||||
<yellow>Spectators: <white><spectators></white></yellow>""";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
NEXT_PHASE_SUCCESS = config.getString(prefix + "next-phase", "success", NEXT_PHASE_SUCCESS);
|
||||
LIST_PLAYERS = config.getString(prefix, "list-players", LIST_PLAYERS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class StatService implements RoundListener {
|
|||
|
||||
@Override
|
||||
public void stateChange(ROUND_STATE roundState) {
|
||||
if (roundState.equals(ROUND_STATE.ENDED)) {
|
||||
if (roundState.equals(ROUND_STATE.FINALE)) {
|
||||
saveRoundStats();
|
||||
}
|
||||
if (roundState.equals(ROUND_STATE.PLAYER_REGISTRATION)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user