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