Merge branch 'daily-restart-support' into 'master'
Add daily restart functionality See merge request 2009scape/2009scape!81
This commit is contained in:
@@ -173,6 +173,9 @@ class ServerConstants {
|
||||
@JvmField
|
||||
var MODULUS = BigInteger("96982303379631821170939875058071478695026608406924780574168393250855797534862289546229721580153879336741968220328805101128831071152160922518190059946555203865621183480223212969502122536662721687753974815205744569357388338433981424032996046420057284324856368815997832596174397728134370577184183004453899764051")
|
||||
|
||||
@JvmField
|
||||
var DAILY_RESTART = false
|
||||
|
||||
/**
|
||||
* Parses a JSONObject and retrieves the values for all settings in this file.
|
||||
* @author Ceikry
|
||||
@@ -211,6 +214,10 @@ class ServerConstants {
|
||||
DATABASE_PORT = data["database_port"].toString()
|
||||
|
||||
DATABASE = Database(DATABASE_ADDRESS, DATABASE_NAME, DATABASE_USER, DATABASE_PASS)
|
||||
|
||||
if(data.containsKey("daily_restart")){
|
||||
DAILY_RESTART = data["daily_restart"] as Boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,22 @@
|
||||
package rs09.worker
|
||||
|
||||
import api.ContentAPI
|
||||
import core.game.system.SystemManager
|
||||
import core.game.system.SystemState
|
||||
import core.game.system.task.Pulse
|
||||
import core.plugin.CorePluginTypes.Managers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import rs09.Server
|
||||
import rs09.ServerConstants
|
||||
import rs09.game.world.GameWorld
|
||||
import rs09.game.world.repository.Repository
|
||||
import rs09.game.world.update.UpdateSequence
|
||||
import rs09.tools.stringtools.colorize
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
/**
|
||||
* Handles the running of pulses and writing of masks, etc
|
||||
@@ -17,6 +25,7 @@ import rs09.game.world.update.UpdateSequence
|
||||
class MajorUpdateWorker {
|
||||
var started = false
|
||||
val sequence = UpdateSequence()
|
||||
val sdf = SimpleDateFormat("HH")
|
||||
fun start() = GlobalScope.launch {
|
||||
started = true
|
||||
while(true){
|
||||
@@ -46,6 +55,24 @@ class MajorUpdateWorker {
|
||||
//tick all manager plugins
|
||||
Managers.tick()
|
||||
Server.heartbeat()
|
||||
|
||||
//Handle daily restart if enabled
|
||||
if(ServerConstants.DAILY_RESTART && sdf.format(Date()).toInt() == 0){
|
||||
Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN 5 MINUTES!"))
|
||||
ServerConstants.DAILY_RESTART = false
|
||||
ContentAPI.submitWorldPulse(object : Pulse(100) {
|
||||
var counter = 0
|
||||
override fun pulse(): Boolean {
|
||||
counter++
|
||||
if(counter == 5){
|
||||
SystemManager.flag(SystemState.TERMINATED)
|
||||
return true
|
||||
}
|
||||
Repository.sendNews(colorize("%RSERVER GOING DOWN FOR DAILY RESTART IN ${5 - counter} MINUTE${if(counter < 4) "S" else ""}!"))
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user