mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Merge branch 'v2.x.x' into feature/v2/itemType_group
# Conflicts: # build.gradle.kts # src/main/java/xyz/alexcrea/cuanvil/enchant/wrapped/CABukkitEnchantment.java # src/main/kotlin/xyz/alexcrea/cuanvil/dependency/gui/GuiTesterSelector.kt # src/main/kotlin/xyz/alexcrea/cuanvil/dependency/plugins/DisenchantmentDependency.kt
This commit is contained in:
commit
147d5887e5
7 changed files with 32 additions and 37 deletions
|
|
@ -27,13 +27,16 @@ repositories {
|
||||||
// EcoEnchants
|
// EcoEnchants
|
||||||
maven(url = "https://repo.auxilor.io/repository/maven-public/")
|
maven(url = "https://repo.auxilor.io/repository/maven-public/")
|
||||||
|
|
||||||
|
// ExcellentEnchants
|
||||||
|
maven(url = "https://repo.nightexpressdev.com/releases")
|
||||||
|
|
||||||
// ProtocoLib
|
// ProtocoLib
|
||||||
maven(url = "https://repo.dmulloy2.net/repository/public/")
|
maven(url = "https://repo.dmulloy2.net/repository/public/")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Paper
|
// Paper
|
||||||
paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT")
|
paperweight.paperDevBundle("1.21.8-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
// Gui library
|
// Gui library
|
||||||
val inventoryFramework = "xyz.alexcrea.cuanvil.inventoryframework:IF-CustomAnvil:0.10.18.2"
|
val inventoryFramework = "xyz.alexcrea.cuanvil.inventoryframework:IF-CustomAnvil:0.10.18.2"
|
||||||
|
|
@ -48,8 +51,9 @@ dependencies {
|
||||||
compileOnly("com.willfp:eco:6.74.5")
|
compileOnly("com.willfp:eco:6.74.5")
|
||||||
|
|
||||||
// ExcellentEnchants
|
// ExcellentEnchants
|
||||||
compileOnly(files("libs/nightcore-2.7.3.jar"))
|
compileOnly("su.nightexpress.excellentenchants:Core:5.1.0") {
|
||||||
compileOnly(files("libs/ExcellentEnchants-5.0.0.jar"))
|
exclude("org.spigotmc")
|
||||||
|
}
|
||||||
|
|
||||||
// Disenchantment
|
// Disenchantment
|
||||||
compileOnly(files("libs/Disenchantment-6.1.5.jar"))
|
compileOnly(files("libs/Disenchantment-6.1.5.jar"))
|
||||||
|
|
|
||||||
BIN
libs/ExcellentEnchants-4.3.3-striped.jar
Normal file
BIN
libs/ExcellentEnchants-4.3.3-striped.jar
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -1,10 +1,8 @@
|
||||||
package xyz.alexcrea.cuanvil.enchant.wrapped;
|
package xyz.alexcrea.cuanvil.enchant.wrapped;
|
||||||
|
|
||||||
import io.delilaheve.CustomAnvil;
|
|
||||||
import io.delilaheve.util.ConfigOptions;
|
import io.delilaheve.util.ConfigOptions;
|
||||||
import io.delilaheve.util.ItemUtil;
|
import io.delilaheve.util.ItemUtil;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.enchantments.EnchantmentTarget;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
@ -14,13 +12,8 @@ import xyz.alexcrea.cuanvil.enchant.CAEnchantmentBase;
|
||||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentProperties;
|
import xyz.alexcrea.cuanvil.enchant.EnchantmentProperties;
|
||||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom Anvil enchantment implementation for vanilla registered enchantment.
|
* Custom Anvil enchantment implementation for vanilla registered enchantment.
|
||||||
|
|
@ -114,25 +107,6 @@ public class CABukkitEnchantment extends CAEnchantmentBase {
|
||||||
return this.bukkit;
|
return this.bukkit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<EnchantmentTarget, String> targetToGroup = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
targetToGroup.put(EnchantmentTarget.ARMOR, "armors");
|
|
||||||
targetToGroup.put(EnchantmentTarget.ARMOR_HEAD, "helmets");
|
|
||||||
targetToGroup.put(EnchantmentTarget.ARMOR_TORSO, "chestplate");
|
|
||||||
targetToGroup.put(EnchantmentTarget.ARMOR_LEGS, "leggings");
|
|
||||||
targetToGroup.put(EnchantmentTarget.ARMOR_FEET, "boots");
|
|
||||||
targetToGroup.put(EnchantmentTarget.BOW, "bow");
|
|
||||||
targetToGroup.put(EnchantmentTarget.BREAKABLE, "can_unbreak");
|
|
||||||
targetToGroup.put(EnchantmentTarget.CROSSBOW, "crossbow");
|
|
||||||
targetToGroup.put(EnchantmentTarget.FISHING_ROD, "fishing_rod");
|
|
||||||
targetToGroup.put(EnchantmentTarget.TOOL, "tools");
|
|
||||||
targetToGroup.put(EnchantmentTarget.TRIDENT, "trident");
|
|
||||||
targetToGroup.put(EnchantmentTarget.VANISHABLE, "can_vanish");
|
|
||||||
targetToGroup.put(EnchantmentTarget.WEAPON, "swords");
|
|
||||||
targetToGroup.put(EnchantmentTarget.WEARABLE, "wearable");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static EnchantmentRarity findRarity(Enchantment enchantment) {
|
private static EnchantmentRarity findRarity(Enchantment enchantment) {
|
||||||
return EnchantmentRarity.getRarity(enchantment.getAnvilCost());
|
return EnchantmentRarity.getRarity(enchantment.getAnvilCost());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,7 @@ object GuiTesterSelector {
|
||||||
|
|
||||||
return when (versionParts[1]) {
|
return when (versionParts[1]) {
|
||||||
21 -> when (versionParts[2]) {
|
21 -> when (versionParts[2]) {
|
||||||
0, 1 -> "1_21_R1"
|
8 -> "1_21_R5"
|
||||||
2, 3 -> "1_21_R2"
|
|
||||||
4 -> "1_21_R3"
|
|
||||||
5 -> "1_21_R4"
|
|
||||||
6, 7, 8 -> "1_21_R5"
|
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,18 @@ import com.jankominek.disenchantment.events.DisenchantClickEvent
|
||||||
import com.jankominek.disenchantment.events.DisenchantEvent
|
import com.jankominek.disenchantment.events.DisenchantEvent
|
||||||
import com.jankominek.disenchantment.events.ShatterClickEvent
|
import com.jankominek.disenchantment.events.ShatterClickEvent
|
||||||
import com.jankominek.disenchantment.events.ShatterEvent
|
import com.jankominek.disenchantment.events.ShatterEvent
|
||||||
|
import com.jankominek.disenchantment.listeners.ShatterClickListener
|
||||||
import io.delilaheve.CustomAnvil
|
import io.delilaheve.CustomAnvil
|
||||||
import org.bukkit.entity.HumanEntity
|
import org.bukkit.entity.HumanEntity
|
||||||
|
import org.bukkit.event.Listener
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.view.AnvilView
|
import org.bukkit.inventory.view.AnvilView
|
||||||
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
|
||||||
import xyz.alexcrea.cuanvil.util.AnvilXpUtil
|
import xyz.alexcrea.cuanvil.util.AnvilXpUtil
|
||||||
|
import java.util.logging.Level
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
@Suppress("unstableApiUsage")
|
@Suppress("unstableApiUsage")
|
||||||
class DisenchantmentDependency {
|
class DisenchantmentDependency {
|
||||||
|
|
@ -24,7 +27,25 @@ class DisenchantmentDependency {
|
||||||
|
|
||||||
fun redirectListeners() {
|
fun redirectListeners() {
|
||||||
PrepareAnvilEvent.getHandlerList().unregister(Disenchantment.plugin)
|
PrepareAnvilEvent.getHandlerList().unregister(Disenchantment.plugin)
|
||||||
InventoryClickEvent.getHandlerList().unregister(Disenchantment.plugin)
|
|
||||||
|
// unregister only the feature click event and not all
|
||||||
|
// This is to avoid the disenchantment gui breaking
|
||||||
|
try {
|
||||||
|
unregisterStaticDisenchantmentListener(ShatterClickListener::class)
|
||||||
|
unregisterStaticDisenchantmentListener(InventoryClickEvent::class)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
CustomAnvil.instance.logger.log(
|
||||||
|
Level.SEVERE, "Could not initialize disenchantment support" +
|
||||||
|
"please report this bug to the developer", e
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unregisterStaticDisenchantmentListener(clazz: KClass<*>) {
|
||||||
|
val field = clazz.java.getDeclaredField("listener")
|
||||||
|
field.isAccessible = true
|
||||||
|
val listener: Listener = field.get(null) as Listener
|
||||||
|
InventoryClickEvent.getHandlerList().unregister(listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testPrepareAnvil(event: PrepareAnvilEvent, player: HumanEntity): Boolean {
|
fun testPrepareAnvil(event: PrepareAnvilEvent, player: HumanEntity): Boolean {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ prefix: "Custom Anvil"
|
||||||
version: ${version}
|
version: ${version}
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
description: Allow to customise anvil mechanics
|
description: Allow to customise anvil mechanics
|
||||||
api-version: 1.16
|
api-version: 1.21.8
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
authors: [ DelilahEve, alexcrea ]
|
authors: [ DelilahEve, alexcrea ]
|
||||||
libraries: [${libraries}]
|
libraries: [${libraries}]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue