make start and end time for blood moon configurable

master
ALI Hamza 2020-04-03 07:37:29 +07:00
parent cc9c14329b
commit cd1e00c78c
No known key found for this signature in database
GPG Key ID: BCA8A46C87798C4C
4 changed files with 10 additions and 4 deletions

@ -15,7 +15,7 @@ object BMData {
val creepers = mutableListOf<Creeper>() val creepers = mutableListOf<Creeper>()
fun ticksLeft(): Int { fun ticksLeft(): Int {
return (23460 - Config.world.time).toInt() return (Config.endTime - Config.world.time).toInt()
} }
fun begin() { fun begin() {

@ -23,7 +23,7 @@ class BloodMoon : JavaPlugin(), Listener {
initListeners() initListeners()
schedule(async = false, period = 1, delay = 1) { schedule(async = false, period = 1, delay = 1) {
if (Bukkit.getWorlds().first().fullTime - 13000 in 0..20) { if (Bukkit.getWorlds().first().fullTime - Config.startTime in 0..20) {
val chance = Random.nextDouble() val chance = Random.nextDouble()
if (!BMData.running && chance < Config.chance) BMData.begin() if (!BMData.running && chance < Config.chance) BMData.begin()
else Bukkit.getOnlinePlayers().filter { it.hasPermission("bloodmoon.admin") || it.isOp }.forEach { else Bukkit.getOnlinePlayers().filter { it.hasPermission("bloodmoon.admin") || it.isOp }.forEach {

@ -6,8 +6,12 @@ import org.bukkit.Bukkit
import org.bukkit.ChatColor import org.bukkit.ChatColor
object Config : ConfigFile(BloodMoon.pl.dataFolder["config.yml"]) { object Config : ConfigFile(BloodMoon.pl.dataFolder["config.yml"]) {
private val _world by string("world", "world") private val w by string("world", "world")
val world get() = Bukkit.getWorld(_world) val world get() = Bukkit.getWorld(w)!!
val startTime by int("start_time")
val endTime by int("end_time")
val chance by double("chance", 0.2) val chance by double("chance", 0.2)
val enabledMobs by stringList("transformed_mobs") val enabledMobs by stringList("transformed_mobs")

@ -1,5 +1,7 @@
# Which world will the blood moon be enabled for? # Which world will the blood moon be enabled for?
world: "world" world: "world"
start_time: 14000
end_time: 23460
# WHat is the chance that the blood moon will occur on any specific night? # WHat is the chance that the blood moon will occur on any specific night?
chance: 0.2 chance: 0.2