|
|
|
@ -8,14 +8,12 @@ import org.bstats.bukkit.Metrics
|
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin
|
|
|
|
|
import org.bukkit.scheduler.BukkitTask
|
|
|
|
|
import java.lang.Exception
|
|
|
|
|
import java.sql.Connection
|
|
|
|
|
import java.sql.DriverManager
|
|
|
|
|
|
|
|
|
|
class Chunkmaster: JavaPlugin() {
|
|
|
|
|
lateinit var sqliteManager: SqliteManager
|
|
|
|
|
lateinit var generationManager: GenerationManager
|
|
|
|
|
private lateinit var tpsTask: BukkitTask
|
|
|
|
|
var mspt = 50L // keep track of the milliseconds per tick
|
|
|
|
|
var mspt = 20 // keep track of the milliseconds per tick
|
|
|
|
|
private set
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -36,12 +34,18 @@ class Chunkmaster: JavaPlugin() {
|
|
|
|
|
|
|
|
|
|
server.pluginManager.registerEvents(ChunkmasterEvents(this, server), this)
|
|
|
|
|
|
|
|
|
|
tpsTask = server.scheduler.runTaskTimer(this, Runnable {
|
|
|
|
|
val start = System.currentTimeMillis()
|
|
|
|
|
server.scheduler.runTaskLater(this, Runnable {
|
|
|
|
|
mspt = System.currentTimeMillis() - start
|
|
|
|
|
}, 1)
|
|
|
|
|
}, 1, 300)
|
|
|
|
|
if (PaperLib.isPaper() && PaperLib.getMinecraftPatchVersion() >= 225) {
|
|
|
|
|
tpsTask = server.scheduler.runTaskTimer(this, Runnable {
|
|
|
|
|
mspt = 1000/server.currentTick // use papers exposed tick rather than calculating it
|
|
|
|
|
}, 1, 300)
|
|
|
|
|
} else {
|
|
|
|
|
tpsTask = server.scheduler.runTaskTimer(this, Runnable {
|
|
|
|
|
val start = System.currentTimeMillis()
|
|
|
|
|
server.scheduler.runTaskLater(this, Runnable {
|
|
|
|
|
mspt = (System.currentTimeMillis() - start).toInt()
|
|
|
|
|
}, 1)
|
|
|
|
|
}, 1, 300)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -64,6 +68,7 @@ class Chunkmaster: JavaPlugin() {
|
|
|
|
|
config.addDefault("generation.pause-on-join", true)
|
|
|
|
|
config.addDefault("generation.max-pending-chunks", 10)
|
|
|
|
|
config.addDefault("generation.max-loaded-chunks", 10)
|
|
|
|
|
config.addDefault("generation.ignore-worldborder", false)
|
|
|
|
|
config.addDefault("database.filename", "chunkmaster.db")
|
|
|
|
|
config.options().copyDefaults(true)
|
|
|
|
|
saveConfig()
|
|
|
|
|