Fixed postInit

This commit is contained in:
Auxilor
2022-02-16 16:48:40 +00:00
parent 511a7e4830
commit ad3cb3a620
4 changed files with 20 additions and 8 deletions

View File

@@ -48,6 +48,7 @@ import com.willfp.eco.internal.items.ArgParserUnbreakable
import com.willfp.eco.internal.spigot.arrows.ArrowDataListener
import com.willfp.eco.internal.spigot.data.DataListener
import com.willfp.eco.internal.spigot.data.DataYml
import com.willfp.eco.internal.spigot.data.EcoProfileHandler
import com.willfp.eco.internal.spigot.data.PlayerBlockListener
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
@@ -215,6 +216,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
CustomItemsManager.registerAllItems()
CustomEntitiesManager.registerAllEntities()
ShopManager.registerEcoProvider()
(Eco.getHandler().profileHandler as EcoProfileHandler).runPostInit()
}
override fun loadIntegrationLoaders(): List<IntegrationLoader> {

View File

@@ -63,4 +63,8 @@ class EcoProfileHandler(
override fun save() {
handler.save()
}
fun runPostInit() {
handler.runPostInit()
}
}

View File

@@ -5,12 +5,13 @@ import org.bukkit.NamespacedKey
import java.util.UUID
interface DataHandler {
fun save() {
fun save()
fun saveAll(uuids: Iterable<UUID>)
fun runPostInit() {
}
fun saveAll(uuids: Iterable<UUID>)
fun savePlayer(uuid: UUID) {
saveKeysFor(uuid, PersistentDataKey.values())
}

View File

@@ -95,6 +95,11 @@ class MySQLDataHandler(
)
plugin.dataYml.save()
}
override fun runPostInit() {
playerHandler.runPostInit()
serverHandler.runPostInit()
}
}
@Suppress("UNCHECKED_CAST")
@@ -102,7 +107,7 @@ private class ImplementedMySQLHandler(
private val handler: EcoProfileHandler,
private val table: UUIDTable,
plugin: EcoPlugin,
knownKeys: Collection<NamespacedKey>
private val knownKeys: Collection<NamespacedKey>
) {
private val columns = mutableMapOf<String, Column<*>>()
private val threadFactory = ThreadFactoryBuilder().setNameFormat("eco-mysql-thread-%d").build()
@@ -136,11 +141,11 @@ private class ImplementedMySQLHandler(
}
}
}
}
plugin.scheduler.runLater(1) {
for (key in knownKeys) {
ensureKeyRegistration(key)
}
fun runPostInit() {
for (key in knownKeys) {
ensureKeyRegistration(key)
}
}