Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f35d5d16e | ||
|
|
3a7315d728 | ||
|
|
6f193f70b0 | ||
|
|
bab3f078f6 | ||
|
|
5b4b17b97f | ||
|
|
f0e02ca25e | ||
|
|
7426e9adba |
@@ -28,6 +28,9 @@ import java.lang.annotation.Target;
|
||||
* }
|
||||
* }</pre>
|
||||
* <p>
|
||||
* If using kotlin, you have to annotate the method with {@code @JvmStatic}
|
||||
* in order to prevent null pointer exceptions.
|
||||
* <p>
|
||||
* Config update methods in all classes in a plugin jar will be called
|
||||
* on reload.
|
||||
* <p>
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CustomItem implements TestableItem {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
return item.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,9 @@ dependencies {
|
||||
compileOnly 'com.github.TechFortress:GriefPrevention:16.17.1'
|
||||
compileOnly 'com.massivecraft:Factions:1.6.9.5-U0.5.10'
|
||||
compileOnly 'com.github.cryptomorin:kingdoms:1.11.9'
|
||||
compileOnly 'com.github.TownyAdvanced:Towny:0.97.2.6'
|
||||
compileOnly('com.github.TownyAdvanced:Towny:0.97.2.6') {
|
||||
exclude group: 'com.zaxxer', module: 'HikariCP'
|
||||
}
|
||||
compileOnly 'com.github.angeschossen:LandsAPI:5.15.2'
|
||||
compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT'
|
||||
compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd'
|
||||
@@ -30,6 +32,7 @@ dependencies {
|
||||
compileOnly 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
||||
compileOnly 'mysql:mysql-connector-java:8.0.25'
|
||||
compileOnly 'com.zaxxer:HikariCP:5.0.0'
|
||||
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
||||
compileOnly 'com.github.EssentialsX:Essentials:2.19.0'
|
||||
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:latest'
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.willfp.eco.internal.data
|
||||
package com.willfp.eco.internal.spigot.data
|
||||
|
||||
import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
class EcoPlayerProfile(
|
||||
val data: MutableMap<PersistentDataKey<*>, Any>,
|
||||
val uuid: UUID
|
||||
val uuid: UUID,
|
||||
private val handler: DataHandler
|
||||
) : PlayerProfile {
|
||||
override fun <T : Any> write(key: PersistentDataKey<T>, value: T) {
|
||||
this.data[key] = value
|
||||
@@ -19,7 +21,12 @@ class EcoPlayerProfile(
|
||||
|
||||
override fun <T : Any> read(key: PersistentDataKey<T>): T {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return this.data[key] as T? ?: key.defaultValue
|
||||
if (this.data.containsKey(key)) {
|
||||
return this.data[key] as T
|
||||
}
|
||||
|
||||
this.data[key] = handler.read(uuid, key.key) ?: key.defaultValue
|
||||
return read(key)
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -3,7 +3,6 @@ package com.willfp.eco.internal.spigot.data
|
||||
import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.core.data.PlayerProfileHandler
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.internal.data.EcoPlayerProfile
|
||||
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
||||
import java.util.UUID
|
||||
|
||||
@@ -20,11 +19,7 @@ class EcoPlayerProfileHandler(
|
||||
|
||||
val data = mutableMapOf<PersistentDataKey<*>, Any>()
|
||||
|
||||
for (key in PersistentDataKey.values()) {
|
||||
data[key] = handler.read(uuid, key.key) ?: key.defaultValue
|
||||
}
|
||||
|
||||
val profile = EcoPlayerProfile(data, uuid)
|
||||
val profile = EcoPlayerProfile(data, uuid, handler)
|
||||
loaded[uuid] = profile
|
||||
return profile
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import org.apache.logging.log4j.Level
|
||||
import org.bukkit.NamespacedKey
|
||||
import org.jetbrains.exposed.dao.id.UUIDTable
|
||||
@@ -35,15 +37,18 @@ class MySQLDataHandler(
|
||||
private val executor = Executors.newFixedThreadPool(plugin.configYml.getInt("mysql.threads"), threadFactory)
|
||||
|
||||
init {
|
||||
Database.connect(
|
||||
"jdbc:mysql://" +
|
||||
"${plugin.configYml.getString("mysql.host")}:" +
|
||||
"${plugin.configYml.getString("mysql.port")}/" +
|
||||
plugin.configYml.getString("mysql.database"),
|
||||
driver = "com.mysql.cj.jdbc.Driver",
|
||||
user = plugin.configYml.getString("mysql.user"),
|
||||
password = plugin.configYml.getString("mysql.password")
|
||||
)
|
||||
val config = HikariConfig()
|
||||
config.driverClassName = "com.mysql.cj.jdbc.Driver"
|
||||
config.username = plugin.configYml.getString("mysql.user")
|
||||
config.password = plugin.configYml.getString("mysql.password")
|
||||
config.jdbcUrl = "jdbc:mysql://" +
|
||||
"${plugin.configYml.getString("mysql.host")}:" +
|
||||
"${plugin.configYml.getString("mysql.port")}/" +
|
||||
plugin.configYml.getString("mysql.database")
|
||||
config.maximumPoolSize = plugin.configYml.getInt("mysql.connections")
|
||||
|
||||
Database.connect(HikariDataSource(config))
|
||||
|
||||
|
||||
transaction {
|
||||
SchemaUtils.create(Players)
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.willfp.eco.internal.spigot.data.storage
|
||||
|
||||
import com.willfp.eco.core.Eco
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.internal.data.EcoPlayerProfile
|
||||
import com.willfp.eco.internal.spigot.data.EcoPlayerProfile
|
||||
|
||||
class ProfileSaver(plugin: EcoPlugin) {
|
||||
init {
|
||||
|
||||
@@ -9,6 +9,8 @@ mysql:
|
||||
# very high numbers can cause issues with OS configuration. If writes are taking
|
||||
# too long, increase this value.
|
||||
threads: 2
|
||||
# The maximum number of MySQL connections.
|
||||
connections: 10
|
||||
# If read operations should be ran in the thread pool. Runs on main thread by default.
|
||||
async-reads: false
|
||||
host: localhost
|
||||
|
||||
@@ -51,4 +51,5 @@ libraries:
|
||||
- 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
||||
- 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
||||
- 'mysql:mysql-connector-java:8.0.25'
|
||||
- 'com.google.guava:guava:31.0.1-jre'
|
||||
- 'com.google.guava:guava:31.0.1-jre'
|
||||
- 'com.zaxxer:HikariCP:5.0.0'
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.17.1
|
||||
version = 6.17.3
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
Reference in New Issue
Block a user