Register online players without auto-join-bypass permission during ROUND_STATE.PLAYER_REGISTRATION or ROUND_STATE.ENDED.
This commit is contained in:
parent
e9e7c1cc80
commit
d5266b659b
|
|
@ -3,10 +3,12 @@ package com.alttd.hunger_games.commands.subcommands;
|
||||||
import com.alttd.hunger_games.commands.SubCommand;
|
import com.alttd.hunger_games.commands.SubCommand;
|
||||||
import com.alttd.hunger_games.config.Messages;
|
import com.alttd.hunger_games.config.Messages;
|
||||||
import com.alttd.hunger_games.data_objects.ROUND_STATE;
|
import com.alttd.hunger_games.data_objects.ROUND_STATE;
|
||||||
|
import com.alttd.hunger_games.services.PlayerService;
|
||||||
import com.alttd.hunger_games.services.Round;
|
import com.alttd.hunger_games.services.Round;
|
||||||
import com.alttd.hunger_games.services.RoundService;
|
import com.alttd.hunger_games.services.RoundService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -16,11 +18,15 @@ public class StartRound extends SubCommand {
|
||||||
|
|
||||||
private final Round round;
|
private final Round round;
|
||||||
private final RoundService roundService;
|
private final RoundService roundService;
|
||||||
|
private final PlayerService playerService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender commandSender, String[] args) {
|
public boolean onCommand(CommandSender commandSender, String[] args) {
|
||||||
ROUND_STATE roundState = roundService.getRoundState();
|
ROUND_STATE roundState = roundService.getRoundState();
|
||||||
if (roundState == ROUND_STATE.PLAYER_REGISTRATION || roundState == ROUND_STATE.ENDED) {
|
if (roundState == ROUND_STATE.PLAYER_REGISTRATION || roundState == ROUND_STATE.ENDED) {
|
||||||
|
Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(player -> !player.hasPermission("hungergames.auto-join-bypass"))
|
||||||
|
.forEach(playerService::registerPlayer);
|
||||||
round.startRound();
|
round.startRound();
|
||||||
} else {
|
} else {
|
||||||
commandSender.sendRichMessage(Messages.START_ROUND.CAN_NOT_START_ROUND,
|
commandSender.sendRichMessage(Messages.START_ROUND.CAN_NOT_START_ROUND,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user