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