Added permanence_curse

This commit is contained in:
Auxilor
2022-08-31 13:07:50 +01:00
parent f8a692ca6e
commit 41b2502275
8 changed files with 55 additions and 6 deletions

View File

@@ -37,6 +37,19 @@ object EcoEnchants {
return ImmutableSet.copyOf(BY_KEY.keys)
}
/**
* Get [EcoEnchant] matching id.
*
* @param id The id to search for.
* @return The matching [EcoEnchant], or null if not found.
*/
@JvmStatic
fun getByID(id: String?): EcoEnchant? {
return if (id == null) {
null
} else BY_KEY[id]
}
/**
* Get [EcoEnchant] matching key.
*
@@ -44,10 +57,10 @@ object EcoEnchants {
* @return The matching [EcoEnchant], or null if not found.
*/
@JvmStatic
fun getByKey(key: String?): EcoEnchant? {
fun getByKey(key: NamespacedKey?): EcoEnchant? {
return if (key == null) {
null
} else BY_KEY[key]
} else getByID(key.key)
}
/**

View File

@@ -0,0 +1,12 @@
package com.willfp.ecoenchants.enchants.impl
import com.willfp.ecoenchants.EcoEnchantsPlugin
import com.willfp.ecoenchants.enchants.EcoEnchant
class EnchantmentPermanenceCurse(
plugin: EcoEnchantsPlugin
) : EcoEnchant(
"permanence_curse",
plugin,
force = false
)

View File

@@ -4,6 +4,7 @@ import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.fast.fast
import com.willfp.eco.core.proxy.ProxyConstants
import com.willfp.eco.util.StringUtils
import com.willfp.ecoenchants.enchants.EcoEnchants
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy
import org.bukkit.ChatColor
import org.bukkit.Material
@@ -142,6 +143,14 @@ class AnvilSupport(
ChatColor.stripColor(itemName)
}.let { if (it.isNullOrEmpty()) left.fast().displayName else it }
val permanenceCurse = EcoEnchants.getByID("permanence_curse")
if (permanenceCurse != null) {
if (left.fast().getEnchants(true).containsKey(permanenceCurse)) {
return FAIL
}
}
if (right == null || right.type == Material.AIR) {
if (left.fast().displayName == formattedItemName) {
return FAIL

View File

@@ -14,7 +14,7 @@ max-level: 1
tradeable: true
discoverable: true
enchantable: true
enchantable: false
effects:
- id: cancel_event

View File

@@ -12,7 +12,7 @@ max-level: 1
tradeable: true
discoverable: true
enchantable: true
enchantable: false
effects:
- id: cancel_event

View File

@@ -11,7 +11,7 @@ max-level: 1
tradeable: true
discoverable: true
enchantable: true
enchantable: false
effects:
- id: hunger_multiplier

View File

@@ -14,7 +14,7 @@ max-level: 1
tradeable: true
discoverable: true
enchantable: true
enchantable: false
effects:
- id: cancel_event

View File

@@ -0,0 +1,15 @@
display-name: "Curse of Permanence"
description: "Prevents modifying this item in an anvil"
type: curse
targets:
- all
conflicts: [ ]
rarity: legendary
max-level: 1
tradeable: true
discoverable: true
enchantable: false
conditions: [ ]