Random weather and time every game
This commit is contained in:
parent
78f023f1fa
commit
c3abf3a687
1 changed files with 15 additions and 0 deletions
|
@ -10,6 +10,7 @@ import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.shop.Shop
|
import de.moritzruth.spigot_ttt.shop.Shop
|
||||||
import de.moritzruth.spigot_ttt.shop.ShopListener
|
import de.moritzruth.spigot_ttt.shop.ShopListener
|
||||||
import org.bukkit.GameRule
|
import org.bukkit.GameRule
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
object GameManager {
|
object GameManager {
|
||||||
var phase: GamePhase? = null
|
var phase: GamePhase? = null
|
||||||
|
@ -76,6 +77,13 @@ object GameManager {
|
||||||
fun resetWorld() {
|
fun resetWorld() {
|
||||||
CorpseManager.destroyAll()
|
CorpseManager.destroyAll()
|
||||||
ItemManager.reset()
|
ItemManager.reset()
|
||||||
|
|
||||||
|
world.run {
|
||||||
|
setStorm(false)
|
||||||
|
time = 0
|
||||||
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
|
||||||
|
setGameRule(GameRule.DO_WEATHER_CYCLE, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun abortGame(broadcast: Boolean = false) {
|
fun abortGame(broadcast: Boolean = false) {
|
||||||
|
@ -94,6 +102,13 @@ object GameManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startPreparingPhase() {
|
fun startPreparingPhase() {
|
||||||
|
world.run {
|
||||||
|
setStorm(Random.nextInt(4) == 1)
|
||||||
|
time = Random.nextLong(0, 23999)
|
||||||
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true)
|
||||||
|
setGameRule(GameRule.DO_WEATHER_CYCLE, true)
|
||||||
|
}
|
||||||
|
|
||||||
ensurePhase(null)
|
ensurePhase(null)
|
||||||
|
|
||||||
if (PlayerManager.availablePlayers.count() < plugin.config.getInt("min-players", 4)) {
|
if (PlayerManager.availablePlayers.count() < plugin.config.getInt("min-players", 4)) {
|
||||||
|
|
Reference in a new issue