Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfcac5d527 | ||
|
|
40f88f0b59 | ||
|
|
105355d967 | ||
|
|
3cddff22b8 | ||
|
|
f8e930d29e | ||
|
|
9dbe088e66 | ||
|
|
6361c0e8e9 | ||
|
|
1135672241 | ||
|
|
80891e4a81 | ||
|
|
8b9e8589a0 |
@@ -10,7 +10,7 @@ buildscript {
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java-library")
|
id("java-library")
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.0"
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("java")
|
id("java")
|
||||||
kotlin("jvm") version "1.6.10"
|
kotlin("jvm") version "1.6.10"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.eco.internal.spigot
|
package com.willfp.eco.internal.spigot
|
||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.PluginProps
|
|
||||||
import com.willfp.eco.core.Handler
|
import com.willfp.eco.core.Handler
|
||||||
|
import com.willfp.eco.core.PluginProps
|
||||||
import com.willfp.eco.core.fast.FastItemStack
|
import com.willfp.eco.core.fast.FastItemStack
|
||||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration
|
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration
|
||||||
import com.willfp.eco.internal.EcoCleaner
|
import com.willfp.eco.internal.EcoCleaner
|
||||||
@@ -26,8 +26,6 @@ import com.willfp.eco.internal.proxy.EcoProxyFactory
|
|||||||
import com.willfp.eco.internal.scheduling.EcoScheduler
|
import com.willfp.eco.internal.scheduling.EcoScheduler
|
||||||
import com.willfp.eco.internal.spigot.data.EcoKeyRegistry
|
import com.willfp.eco.internal.spigot.data.EcoKeyRegistry
|
||||||
import com.willfp.eco.internal.spigot.data.EcoProfileHandler
|
import com.willfp.eco.internal.spigot.data.EcoProfileHandler
|
||||||
import com.willfp.eco.internal.spigot.data.storage.MySQLDataHandler
|
|
||||||
import com.willfp.eco.internal.spigot.data.storage.YamlDataHandler
|
|
||||||
import com.willfp.eco.internal.spigot.integrations.bstats.MetricHandler
|
import com.willfp.eco.internal.spigot.integrations.bstats.MetricHandler
|
||||||
import com.willfp.eco.internal.spigot.proxy.DummyEntityProxy
|
import com.willfp.eco.internal.spigot.proxy.DummyEntityProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
||||||
@@ -46,10 +44,7 @@ class EcoHandler : EcoSpigotPlugin(), Handler {
|
|||||||
private val requirementFactory = com.willfp.eco.internal.requirement.EcoRequirementFactory()
|
private val requirementFactory = com.willfp.eco.internal.requirement.EcoRequirementFactory()
|
||||||
private var adventure: BukkitAudiences? = null
|
private var adventure: BukkitAudiences? = null
|
||||||
private val keyRegistry = EcoKeyRegistry(this)
|
private val keyRegistry = EcoKeyRegistry(this)
|
||||||
private val playerProfileHandler = EcoProfileHandler(
|
private val playerProfileHandler = EcoProfileHandler(this.configYml.getBool("mysql.enabled"), this)
|
||||||
if (this.configYml.getBool("mysql.enabled"))
|
|
||||||
MySQLDataHandler(this) else YamlDataHandler(this)
|
|
||||||
)
|
|
||||||
|
|
||||||
@Suppress("RedundantNullableReturnType")
|
@Suppress("RedundantNullableReturnType")
|
||||||
private val keyFactory: InternalNamespacedKeyFactory? =
|
private val keyFactory: InternalNamespacedKeyFactory? =
|
||||||
|
|||||||
@@ -5,17 +5,23 @@ import com.willfp.eco.core.data.Profile
|
|||||||
import com.willfp.eco.core.data.ProfileHandler
|
import com.willfp.eco.core.data.ProfileHandler
|
||||||
import com.willfp.eco.core.data.ServerProfile
|
import com.willfp.eco.core.data.ServerProfile
|
||||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||||
|
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||||
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
import com.willfp.eco.internal.spigot.data.storage.DataHandler
|
||||||
|
import com.willfp.eco.internal.spigot.data.storage.MySQLDataHandler
|
||||||
|
import com.willfp.eco.internal.spigot.data.storage.YamlDataHandler
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
val serverProfileUUID = UUID(0, 0)
|
val serverProfileUUID = UUID(0, 0)
|
||||||
|
|
||||||
class EcoProfileHandler(
|
class EcoProfileHandler(
|
||||||
private val handler: DataHandler
|
useSql: Boolean,
|
||||||
|
plugin: EcoSpigotPlugin
|
||||||
) : ProfileHandler {
|
) : ProfileHandler {
|
||||||
private val loaded = mutableMapOf<UUID, Profile>()
|
private val loaded = mutableMapOf<UUID, Profile>()
|
||||||
|
private val handler: DataHandler = if (useSql) MySQLDataHandler(plugin, this) else
|
||||||
|
YamlDataHandler(plugin, this)
|
||||||
|
|
||||||
private fun loadGenericProfile(uuid: UUID): Profile {
|
fun loadGenericProfile(uuid: UUID): Profile {
|
||||||
val found = loaded[uuid]
|
val found = loaded[uuid]
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
return found
|
return found
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.willfp.eco.internal.spigot.data.storage
|
|||||||
|
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder
|
import com.google.common.util.concurrent.ThreadFactoryBuilder
|
||||||
import com.willfp.eco.core.Eco
|
import com.willfp.eco.core.Eco
|
||||||
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.willfp.eco.internal.spigot.data.EcoProfileHandler
|
||||||
import com.zaxxer.hikari.HikariConfig
|
import com.zaxxer.hikari.HikariConfig
|
||||||
import com.zaxxer.hikari.HikariDataSource
|
import com.zaxxer.hikari.HikariDataSource
|
||||||
import org.apache.logging.log4j.Level
|
import org.apache.logging.log4j.Level
|
||||||
@@ -30,7 +30,8 @@ import java.util.concurrent.Executors
|
|||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
class MySQLDataHandler(
|
class MySQLDataHandler(
|
||||||
plugin: EcoSpigotPlugin
|
plugin: EcoSpigotPlugin,
|
||||||
|
private val handler: EcoProfileHandler
|
||||||
) : DataHandler {
|
) : DataHandler {
|
||||||
private val columns = mutableMapOf<String, Column<*>>()
|
private val columns = mutableMapOf<String, Column<*>>()
|
||||||
private val threadFactory = ThreadFactoryBuilder().setNameFormat("eco-mysql-thread-%d").build()
|
private val threadFactory = ThreadFactoryBuilder().setNameFormat("eco-mysql-thread-%d").build()
|
||||||
@@ -104,7 +105,7 @@ class MySQLDataHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun savePlayer(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
private fun savePlayer(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
||||||
val profile = PlayerProfile.load(uuid)
|
val profile = handler.loadGenericProfile(uuid)
|
||||||
|
|
||||||
executor.submit {
|
executor.submit {
|
||||||
transaction {
|
transaction {
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ package com.willfp.eco.internal.spigot.data.storage
|
|||||||
|
|
||||||
import com.willfp.eco.core.config.BaseConfig
|
import com.willfp.eco.core.config.BaseConfig
|
||||||
import com.willfp.eco.core.config.ConfigType
|
import com.willfp.eco.core.config.ConfigType
|
||||||
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.EcoSpigotPlugin
|
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||||
|
import com.willfp.eco.internal.spigot.data.EcoProfileHandler
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
class YamlDataHandler(
|
class YamlDataHandler(
|
||||||
plugin: EcoSpigotPlugin
|
plugin: EcoSpigotPlugin,
|
||||||
|
private val handler: EcoProfileHandler
|
||||||
) : DataHandler {
|
) : DataHandler {
|
||||||
private val dataYml = DataYml(plugin)
|
private val dataYml = DataYml(plugin)
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ class YamlDataHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun saveKeysForPlayer(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
override fun saveKeysForPlayer(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
||||||
val profile = PlayerProfile.load(uuid)
|
val profile = handler.loadGenericProfile(uuid)
|
||||||
|
|
||||||
for (key in keys) {
|
for (key in keys) {
|
||||||
write(uuid, key.key, profile.read(key))
|
write(uuid, key.key, profile.read(key))
|
||||||
|
|||||||
@@ -49,13 +49,15 @@ class ShapedRecipeListener : Listener {
|
|||||||
}
|
}
|
||||||
isStackedRecipe = true
|
isStackedRecipe = true
|
||||||
} else if (inMatrix != null) {
|
} else if (inMatrix != null) {
|
||||||
val max = inMatrix.amount
|
val max = Math.floorDiv(inMatrix.amount, inRecipe.item.amount)
|
||||||
if (max < upperBound) {
|
if (max < upperBound) {
|
||||||
upperBound = max
|
upperBound = max
|
||||||
}
|
}
|
||||||
|
isStackedRecipe = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isStackedRecipe) {
|
if (!isStackedRecipe) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -66,8 +68,10 @@ class ShapedRecipeListener : Listener {
|
|||||||
upperBound--
|
upperBound--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val newMatrix = matrix;
|
||||||
|
|
||||||
for (i in 0..8) {
|
for (i in 0..8) {
|
||||||
val inMatrix = event.inventory.matrix[i]
|
val inMatrix = matrix[i]
|
||||||
val inRecipe = matched.parts[i]
|
val inRecipe = matched.parts[i]
|
||||||
|
|
||||||
if (inRecipe is TestableStack) {
|
if (inRecipe is TestableStack) {
|
||||||
@@ -76,13 +80,35 @@ class ShapedRecipeListener : Listener {
|
|||||||
for (j in 0..upperBound) {
|
for (j in 0..upperBound) {
|
||||||
amount -= inRecipe.amount
|
amount -= inRecipe.amount
|
||||||
}
|
}
|
||||||
inMatrix.amount = amount
|
inMatrix.amount = amount;
|
||||||
|
newMatrix[i] = inMatrix
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
inMatrix.amount = inMatrix.amount - (inRecipe.amount - 1)
|
inMatrix.amount = inMatrix.amount - (inRecipe.amount - 1)
|
||||||
|
newMatrix[i] = inMatrix
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
@Suppress("SENSELESS_COMPARISON")
|
||||||
|
if (inMatrix == null) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.isShiftClick) {
|
||||||
|
var amount = inMatrix.amount + 1
|
||||||
|
for (j in 0..upperBound) {
|
||||||
|
amount -= inRecipe.item.amount
|
||||||
|
}
|
||||||
|
inMatrix.amount = amount;
|
||||||
|
newMatrix[i] = inMatrix
|
||||||
|
} else {
|
||||||
|
inMatrix.amount = inMatrix.amount - (inRecipe.item.amount - 1)
|
||||||
|
newMatrix[i] = inMatrix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.inventory.matrix = newMatrix;
|
||||||
|
|
||||||
if (event.isShiftClick) {
|
if (event.isShiftClick) {
|
||||||
val result = event.inventory.result ?: return
|
val result = event.inventory.result ?: return
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.24.2
|
version = 6.24.3
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user