Compare commits

..

12 Commits

Author SHA1 Message Date
Auxilor
dfcac5d527 PR Changes 2022-02-14 13:28:37 +00:00
Auxilor
40f88f0b59 Revert "refactor(nms): Change checking if value is initialized to a lazy val"
This reverts commit 6361c0e8e9.
2022-02-14 13:28:25 +00:00
Auxilor
105355d967 Updated to 6.24.3 2022-02-14 13:15:55 +00:00
Will FP
3cddff22b8 Merge pull request #73
Bump com.github.johnrengelman.shadow from 7.1.0 to 7.1.2
2022-02-14 13:15:39 +00:00
Will FP
f8e930d29e Merge pull request #91
Update ShapedRecipeListener.kt
2022-02-14 13:15:28 +00:00
Will FP
9dbe088e66 Merge pull request #92
refactor(nms): Change checking if value is initialized to a lazy val
2022-02-14 13:15:17 +00:00
Racci
6361c0e8e9 refactor(nms): Change checking if value is initialized to a lazy val 2022-02-14 17:32:12 +11:00
casper
1135672241 Update ShapedRecipeListener.kt
| ShapedRecipeListener.kt Modified to change matrix at the end of the crafting to prevent duplication of items
2022-02-13 12:55:05 -05:00
Auxilor
80891e4a81 Fixed profile saveAll not working 2022-02-11 10:14:33 +00:00
Auxilor
3e0be3a629 Updated to 6.24.2 2022-02-09 15:20:30 +00:00
Auxilor
17819de2ea Fixed adult/baby parsers 2022-02-09 15:20:21 +00:00
dependabot[bot]
8b9e8589a0 Bump com.github.johnrengelman.shadow from 7.1.0 to 7.1.2
Bumps com.github.johnrengelman.shadow from 7.1.0 to 7.1.2.

---
updated-dependencies:
- dependency-name: com.github.johnrengelman.shadow
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-03 18:54:34 +00:00
9 changed files with 55 additions and 26 deletions

View File

@@ -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"

View File

@@ -2,7 +2,7 @@ package com.willfp.eco.internal.entities
import com.willfp.eco.core.entities.args.EntityArgParseResult
import com.willfp.eco.core.entities.args.EntityArgParser
import org.bukkit.entity.Animals
import org.bukkit.entity.Ageable
class EntityArgParserAdult : EntityArgParser {
override fun parseArguments(args: Array<out String>): EntityArgParseResult? {
@@ -20,14 +20,14 @@ class EntityArgParserAdult : EntityArgParser {
return EntityArgParseResult(
{
if (it !is Animals) {
if (it !is Ageable) {
return@EntityArgParseResult false
}
it.isAdult
},
{
(it as? Animals)?.setAdult()
(it as? Ageable)?.setAdult()
}
)
}

View File

@@ -2,7 +2,7 @@ package com.willfp.eco.internal.entities
import com.willfp.eco.core.entities.args.EntityArgParseResult
import com.willfp.eco.core.entities.args.EntityArgParser
import org.bukkit.entity.Animals
import org.bukkit.entity.Ageable
class EntityArgParserBaby : EntityArgParser {
override fun parseArguments(args: Array<out String>): EntityArgParseResult? {
@@ -20,14 +20,14 @@ class EntityArgParserBaby : EntityArgParser {
return EntityArgParseResult(
{
if (it !is Animals) {
if (it !is Ageable) {
return@EntityArgParseResult false
}
!it.isAdult
},
{
(it as? Animals)?.setBaby()
(it as? Ageable)?.setBaby()
}
)
}

View File

@@ -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? =

View File

@@ -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

View File

@@ -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 {

View File

@@ -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))

View File

@@ -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

View File

@@ -1,3 +1,3 @@
version = 6.24.1
version = 6.24.3
plugin-name = eco
kotlin.code.style = official