Refuse /start-game if already active

This commit is contained in:
Mathieu Strypsteen 2024-09-14 19:31:40 +02:00
parent c0751511a5
commit bb4b47e84a

View file

@ -11,12 +11,17 @@ import org.bukkit.potion.PotionEffect;
import gent.zeus.mc13dtl.MC13DTL;
import io.papermc.paper.command.brigadier.BasicCommand;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import net.md_5.bungee.api.ChatColor;
public class GameStateCommand implements BasicCommand {
@Override
public void execute(CommandSourceStack stack, String[] args) {
World world = Bukkit.getWorld("world");
NamespacedKey key = new NamespacedKey(MC13DTL.instance, "game-state");
if (!world.getPersistentDataContainer().get(key, PersistentDataType.STRING).equals("lobby")) {
stack.getSender().sendMessage(ChatColor.RED + "Game is already active");
return;
}
world.getPersistentDataContainer().set(key, PersistentDataType.STRING, "active");
GameStateUtil.loadWorld(world);
for (OfflinePlayer i : Bukkit.getOfflinePlayers()) {