feat: prevent some commands before game start
This commit is contained in:
parent
b71afddb19
commit
fdca677698
3 changed files with 24 additions and 12 deletions
src/main/kotlin/xyz/ineanto/dragon
|
@ -19,6 +19,11 @@ class GameSubCommand {
|
||||||
|
|
||||||
when (args[0]) {
|
when (args[0]) {
|
||||||
"dim" -> {
|
"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 {
|
Bukkit.getOnlinePlayers().forEach {
|
||||||
it.teleport(WorldManager.GAME_WORLD_THE_END.spawnLocation)
|
it.teleport(WorldManager.GAME_WORLD_THE_END.spawnLocation)
|
||||||
}
|
}
|
||||||
|
@ -45,17 +50,7 @@ class GameSubCommand {
|
||||||
|
|
||||||
"start" -> {
|
"start" -> {
|
||||||
if (RunnerDragon.STATE != GameState.WAITING) {
|
if (RunnerDragon.STATE != GameState.WAITING) {
|
||||||
val errorMessage = Component
|
player.sendErrorMessage("Impossible de lancer le jeu, il a déjà démarré.")
|
||||||
.text()
|
|
||||||
.append(
|
|
||||||
Component.text(
|
|
||||||
"Impossible de lancer le jeu, il a déjà démarré.",
|
|
||||||
NamedTextColor.RED
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.appendNewline()
|
|
||||||
.build()
|
|
||||||
player.sendMessage(errorMessage)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,21 @@ class DragonPlayer(uuid: UUID) {
|
||||||
bukkitPlayer.sendMessage(message)
|
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? {
|
fun getTeam(): Team? {
|
||||||
return RunnerDragon.instance.teamManager.getPlayerTeam(bukkitPlayer)
|
return RunnerDragon.instance.teamManager.getPlayerTeam(bukkitPlayer)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package xyz.ineanto.dragon.world
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.Difficulty
|
||||||
import org.bukkit.GameRule
|
import org.bukkit.GameRule
|
||||||
import org.bukkit.Location
|
import org.bukkit.Location
|
||||||
import org.bukkit.World
|
import org.bukkit.World
|
||||||
|
@ -31,13 +32,14 @@ class WorldManager(private val instance: RunnerDragon) {
|
||||||
// Limbo is the world where players are
|
// Limbo is the world where players are
|
||||||
// held (hostage) before the game starts.
|
// held (hostage) before the game starts.
|
||||||
instance.logger.severe("Limbo world doesn't exist! Generating an emergency spawn...")
|
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 {
|
} else {
|
||||||
// Load the Limbo world
|
// Load the Limbo world
|
||||||
LIMBO_WORLD = Bukkit.createWorld(WorldCreator(LIMBO_WORLD_NAME))!!
|
LIMBO_WORLD = Bukkit.createWorld(WorldCreator(LIMBO_WORLD_NAME))!!
|
||||||
}
|
}
|
||||||
|
|
||||||
LIMBO_SPAWN = LIMBO_WORLD.spawnLocation
|
LIMBO_SPAWN = LIMBO_WORLD.spawnLocation
|
||||||
|
LIMBO_WORLD.difficulty = Difficulty.PEACEFUL
|
||||||
cleanupPreviousWorlds()
|
cleanupPreviousWorlds()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue