1
0
Fork 0

feat: prevent some commands before game start

This commit is contained in:
ineanto 2024-07-09 15:20:35 +02:00
parent b71afddb19
commit fdca677698
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84
3 changed files with 24 additions and 12 deletions
src/main/kotlin/xyz/ineanto/dragon

View file

@ -19,6 +19,11 @@ class GameSubCommand {
when (args[0]) {
"dim" -> {
if (RunnerDragon.STATE == GameState.WAITING) {
player.sendErrorMessage("Impossible de vous téléporter : le jeu n'a pas démarré.")
return
}
Bukkit.getOnlinePlayers().forEach {
it.teleport(WorldManager.GAME_WORLD_THE_END.spawnLocation)
}
@ -45,17 +50,7 @@ class GameSubCommand {
"start" -> {
if (RunnerDragon.STATE != GameState.WAITING) {
val errorMessage = Component
.text()
.append(
Component.text(
"Impossible de lancer le jeu, il a déjà démarré.",
NamedTextColor.RED
)
)
.appendNewline()
.build()
player.sendMessage(errorMessage)
player.sendErrorMessage("Impossible de lancer le jeu, il a déjà démarré.")
return
}

View file

@ -73,6 +73,21 @@ class DragonPlayer(uuid: UUID) {
bukkitPlayer.sendMessage(message)
}
fun sendErrorMessage(message: String) {
val message = Component
.text()
.append(RunnerDragon.PREFIX)
.appendSpace()
.append(
Component.text(
message,
NamedTextColor.RED
)
)
.build()
bukkitPlayer.sendMessage(message)
}
fun getTeam(): Team? {
return RunnerDragon.instance.teamManager.getPlayerTeam(bukkitPlayer)
}

View file

@ -2,6 +2,7 @@ package xyz.ineanto.dragon.world
import org.apache.commons.io.FileUtils
import org.bukkit.Bukkit
import org.bukkit.Difficulty
import org.bukkit.GameRule
import org.bukkit.Location
import org.bukkit.World
@ -31,13 +32,14 @@ class WorldManager(private val instance: RunnerDragon) {
// Limbo is the world where players are
// held (hostage) before the game starts.
instance.logger.severe("Limbo world doesn't exist! Generating an emergency spawn...")
LIMBO_WORLD = createWorld(LIMBO_WORLD_NAME, World.Environment.NETHER, false)
LIMBO_WORLD = createWorld(LIMBO_WORLD_NAME, World.Environment.NORMAL, false)
} else {
// Load the Limbo world
LIMBO_WORLD = Bukkit.createWorld(WorldCreator(LIMBO_WORLD_NAME))!!
}
LIMBO_SPAWN = LIMBO_WORLD.spawnLocation
LIMBO_WORLD.difficulty = Difficulty.PEACEFUL
cleanupPreviousWorlds()
return true
}