Fixed MySQL changes
This commit is contained in:
@@ -5,6 +5,7 @@ import com.willfp.eco.core.data.Profile
|
||||
import com.willfp.eco.core.data.ProfileHandler
|
||||
import com.willfp.eco.core.data.ServerProfile
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.core.data.profile
|
||||
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||
import com.willfp.eco.internal.spigot.ServerLocking
|
||||
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
||||
@@ -113,6 +114,7 @@ class EcoProfileHandler(
|
||||
fun <T : Any> migrateKey(uuid: UUID, key: PersistentDataKey<T>, from: DataHandler, to: DataHandler) {
|
||||
val previous: T? = from.read(uuid, key)
|
||||
if (previous != null) {
|
||||
Bukkit.getOfflinePlayer(uuid).profile.write(key, previous) // Nope, no idea.
|
||||
to.write(uuid, key, previous)
|
||||
}
|
||||
}
|
||||
@@ -129,7 +131,7 @@ class EcoProfileHandler(
|
||||
try {
|
||||
migrateKey(uuid, key, previousHandler, handler)
|
||||
} catch (e: Exception) {
|
||||
plugin.logger.info("Could not migrate ${key.key} for $uuid!")
|
||||
plugin.logger.info("Could not migrate ${key.key} for $uuid! This is probably because they do not have any data.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ class LegacyMySQLDataHandler(
|
||||
private class ImplementedMySQLHandler(
|
||||
private val handler: EcoProfileHandler,
|
||||
private val table: UUIDTable,
|
||||
plugin: EcoPlugin
|
||||
private val plugin: EcoPlugin
|
||||
) {
|
||||
private val rows = Caffeine.newBuilder()
|
||||
.expireAfterWrite(3, TimeUnit.SECONDS)
|
||||
@@ -241,11 +241,15 @@ private class ImplementedMySQLHandler(
|
||||
}
|
||||
|
||||
SchemaUtils.createMissingTablesAndColumns(table, withLogs = false)
|
||||
} catch (_: Exception) {
|
||||
} catch (e: Exception) {
|
||||
plugin.logger.info("MySQL Error 1!")
|
||||
e.printStackTrace()
|
||||
// What's that? Two enormous exception catches? That's right! This code sucks.
|
||||
}
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
} catch (e: Exception) {
|
||||
plugin.logger.info("MySQL Error 2!")
|
||||
e.printStackTrace()
|
||||
// It might fail. Who cares? This is legacy.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,12 +90,10 @@ class MySQLDataHandler(
|
||||
}
|
||||
|
||||
override fun <T : Any> write(uuid: UUID, key: PersistentDataKey<T>, value: T) {
|
||||
executor.submit {
|
||||
val data = getData(uuid)
|
||||
data.set(key.key.toString(), value)
|
||||
val data = getData(uuid)
|
||||
data.set(key.key.toString(), value)
|
||||
|
||||
setData(uuid, data)
|
||||
}
|
||||
setData(uuid, data)
|
||||
}
|
||||
|
||||
override fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
||||
|
||||
Reference in New Issue
Block a user