Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /tm status command #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/main/java/dev/pgm/events/ready/ReadyCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.pgm.events.config.AppData;
import java.time.Duration;
import java.util.stream.Stream;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
Expand Down Expand Up @@ -78,6 +79,25 @@ public void unreadyCommand(CommandSender sender, Match match, MatchPlayer player
}
}

@Command(aliases = "status", desc = "Display if teams are ready")
public void status(CommandSender sender, Match match) {
Stream<? extends Party> parties = match.getCompetitors().stream();
Pablete1234 marked this conversation as resolved.
Show resolved Hide resolved
if (AppData.observersMustReady())
parties = Stream.concat(Stream.of(match.getDefaultParty()), parties);

parties
.map(
p ->
p.getColor()
+ p.getNameLegacy()
+ ChatColor.RESET
+ " is "
+ (readyParties.isReady(p)
? ChatColor.GREEN + "ready"
: ChatColor.RED + "not ready"))
.forEach(sender::sendMessage);
eudaldca marked this conversation as resolved.
Show resolved Hide resolved
}

private boolean preConditions(Match match) {
return !match.isRunning() && !match.isFinished();
}
Expand Down