diff --git a/build.gradle.kts b/build.gradle.kts index 511de1dc..ebc57776 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -151,7 +151,6 @@ allprojects { relocate("com.google.protobuf", "com.willfp.eco.libs.google.protobuf") // No I don't know either relocate("google.protobuf", "com.willfp.eco.libs.protobuf") // Still don't know relocate("com.zaxxer.hikari", "com.willfp.eco.libs.hikari") - relocate("javassist", "com.willfp.eco.libs.javassist") //relocate("com.mysql", "com.willfp.eco.libs.mysql") /* diff --git a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java b/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java index 223e34d7..a6843fdb 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java +++ b/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java @@ -256,20 +256,6 @@ public interface FastItemStack extends PersistentDataHolder { */ void setCustomModelData(@Nullable Integer data); - /** - * Get the speed multiplier. - * - * @return The multiplier. - */ - double getDestroySpeedMultiplier(); - - /** - * Set the speed multiplier. - * - * @param multiplier The multiplier. - */ - void setDestroySpeedMultiplier(double multiplier); - /** * Get the Bukkit ItemStack again. * diff --git a/eco-api/src/main/java/com/willfp/eco/core/items/Items.java b/eco-api/src/main/java/com/willfp/eco/core/items/Items.java index 87644359..87df7608 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/items/Items.java +++ b/eco-api/src/main/java/com/willfp/eco/core/items/Items.java @@ -18,6 +18,7 @@ import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,6 +27,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -528,7 +530,9 @@ public final class Items { public static ItemStack setDestroySpeedMultiplier(@NotNull final ItemStack itemStack, final double multiplier) { FastItemStack fis = FastItemStack.wrap(itemStack); - fis.setDestroySpeedMultiplier(multiplier); + PersistentDataContainer tag = fis.getBaseTag(); + tag.set(NamespacedKeyUtils.createEcoKey("break_speed"), PersistentDataType.DOUBLE, multiplier); + fis.setBaseTag(tag); return fis.unwrap(); } @@ -540,7 +544,11 @@ public final class Items { */ public static double getDestroySpeedMultiplier(@NotNull final ItemStack itemStack) { FastItemStack fis = FastItemStack.wrap(itemStack); - return fis.getDestroySpeedMultiplier(); + PersistentDataContainer tag = fis.getBaseTag(); + return Objects.requireNonNullElse( + tag.get(NamespacedKeyUtils.createEcoKey("break_speed"), PersistentDataType.DOUBLE), + 1.0 + ); } private Items() { diff --git a/eco-core/core-nms/build.gradle.kts b/eco-core/core-nms/build.gradle.kts index 1af150d5..cfd0e1f0 100644 --- a/eco-core/core-nms/build.gradle.kts +++ b/eco-core/core-nms/build.gradle.kts @@ -8,6 +8,5 @@ subprojects { compileOnly(project(":eco-core:core-backend")) // libraries.minecraft.net machine broke compileOnly("com.github.Mojang:brigadier:1.0.18") - compileOnly("org.javassist:javassist:3.28.0-GA") } } \ No newline at end of file diff --git a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/item/EcoFastItemStack.kt b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/item/EcoFastItemStack.kt index 923f5d71..4eaec315 100644 --- a/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/item/EcoFastItemStack.kt +++ b/eco-core/core-nms/nms-common/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/common/item/EcoFastItemStack.kt @@ -247,15 +247,6 @@ class EcoFastItemStack( apply() } - override fun getDestroySpeedMultiplier(): Double = - handle.getTag()?.getDouble("DestroySpeedMultiplier") ?: 1.0 - - override fun setDestroySpeedMultiplier(multiplier: Double) { - handle.getOrCreateTag().putDouble("DestroySpeedMultiplier", multiplier) - - apply() - } - override fun equals(other: Any?): Boolean { if (other !is EcoFastItemStack) { return false diff --git a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R2/CommonsInitializer.kt b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R2/CommonsInitializer.kt index 94bef213..ff011987 100644 --- a/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R2/CommonsInitializer.kt +++ b/eco-core/core-nms/v1_18_R2/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R2/CommonsInitializer.kt @@ -1,9 +1,7 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R2 -import com.willfp.eco.core.Eco import com.willfp.eco.internal.spigot.proxy.CommonsInitializerProxy import com.willfp.eco.internal.spigot.proxy.common.CommonsProvider -import javassist.ClassPool import net.minecraft.nbt.CompoundTag import net.minecraft.nbt.Tag import net.minecraft.resources.ResourceLocation @@ -27,35 +25,6 @@ import java.lang.reflect.Field class CommonsInitializer : CommonsInitializerProxy { override fun init() { CommonsProvider.setIfNeeded(CommonsProviderImpl) - - allowItemModification() - } - - private fun allowItemModification() { - val cp = ClassPool.getDefault() - val clazz = cp.get("net.minecraft.world.item.ItemStack") - val method = clazz.getDeclaredMethod( - "a", - arrayOf(cp.get("net.minecraft.world.level.block.state.IBlockData")) - ) - - method.setBody( - """ - { - double destroySpeed = this.c().a(this, $1); - - if (this.s()) { - return destroySpeed * this.t().k("DestroySpeedMultiplier"); - } else { - return destroySpeed; - } - } - """.trimIndent() - ) - - Eco.getHandler().ecoPlugin.logger.info("Patching server jar...") - clazz.writeFile(clazz.classFile.sourceFile) - Eco.getHandler().ecoPlugin.logger.info("Patched jar! If this is the first time you see this message, make sure to restart the server.") } object CommonsProviderImpl : CommonsProvider {