Recoded entire plugin
This commit is contained in:
@@ -8,7 +8,7 @@ import com.willfp.ecoitems.items.EcoItems
|
||||
import com.willfp.ecoitems.items.EcoItemsRecipes
|
||||
import com.willfp.ecoitems.items.ItemAttributeListener
|
||||
import com.willfp.ecoitems.items.ItemListener
|
||||
import com.willfp.ecoitems.items.ItemUtils
|
||||
import com.willfp.ecoitems.items.ecoItems
|
||||
import com.willfp.ecoitems.libreforge.ConditionHasEcoItem
|
||||
import com.willfp.ecoitems.util.DiscoverRecipeListener
|
||||
import com.willfp.libreforge.conditions.Conditions
|
||||
@@ -17,18 +17,21 @@ import com.willfp.libreforge.loader.configs.ConfigCategory
|
||||
import com.willfp.libreforge.registerHolderProvider
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
internal lateinit var plugin: EcoItemsPlugin
|
||||
private set
|
||||
|
||||
class EcoItemsPlugin : LibreforgePlugin() {
|
||||
/**
|
||||
* Internal constructor called by bukkit on plugin load.
|
||||
*/
|
||||
init {
|
||||
instance = this
|
||||
plugin = this
|
||||
}
|
||||
|
||||
override fun handleEnable() {
|
||||
Conditions.register(ConditionHasEcoItem)
|
||||
|
||||
registerHolderProvider { ItemUtils.getEcoItemsOnPlayer(it) }
|
||||
registerHolderProvider { it.ecoItems }
|
||||
}
|
||||
|
||||
override fun loadConfigCategories(): List<ConfigCategory> {
|
||||
@@ -55,12 +58,4 @@ class EcoItemsPlugin : LibreforgePlugin() {
|
||||
override fun createDisplayModule(): DisplayModule {
|
||||
return ItemsDisplay(this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Instance of EcoItems.
|
||||
*/
|
||||
@JvmStatic
|
||||
lateinit var instance: EcoItemsPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@ import org.bukkit.command.CommandSender
|
||||
class CommandEcoItems(
|
||||
plugin: EcoPlugin
|
||||
) : PluginCommand(
|
||||
plugin,
|
||||
"ecoitems",
|
||||
"ecoitems.command.ecoitems",
|
||||
false) {
|
||||
plugin,
|
||||
"ecoitems",
|
||||
"ecoitems.command.ecoitems",
|
||||
false
|
||||
) {
|
||||
init {
|
||||
addSubcommand(CommandReload(plugin))
|
||||
this.addSubcommand(CommandReload(plugin))
|
||||
.addSubcommand(CommandGive(plugin))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,43 +21,23 @@ class CommandGive(plugin: EcoPlugin) : Subcommand(plugin, "give", "ecoitems.comm
|
||||
)
|
||||
|
||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("needs-player"))
|
||||
return
|
||||
}
|
||||
if (args.size == 1) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("needs-item"))
|
||||
return
|
||||
}
|
||||
val receiverName = args[0]
|
||||
val receiver = Bukkit.getPlayer(receiverName)
|
||||
if (receiver == null) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
||||
return
|
||||
}
|
||||
val itemID = args[1]
|
||||
var amount = 1
|
||||
val player = notifyPlayerRequired(args.getOrNull(0), "invalid-player")
|
||||
|
||||
val ecoItem = EcoItems.getByID(itemID.lowercase())
|
||||
if (ecoItem == null) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("invalid-item"))
|
||||
return
|
||||
}
|
||||
val ecoItem = notifyNull(EcoItems.getByID(args.getOrNull(1)), "invalid-item")
|
||||
|
||||
var message = plugin.langYml.getMessage("give-success")
|
||||
message = message.replace("%item%", itemID).replace("%recipient%", receiver.name)
|
||||
val amount = args.getOrNull(2)?.toIntOrNull() ?: 1
|
||||
|
||||
val message = plugin.langYml.getMessage("give-success")
|
||||
.replace("%item%", ecoItem.id.key)
|
||||
.replace("%recipient%", player.name)
|
||||
|
||||
sender.sendMessage(message)
|
||||
|
||||
if (args.size == 3) {
|
||||
amount = args[2].toIntOrNull() ?: 1
|
||||
}
|
||||
|
||||
val item = ecoItem.itemStack
|
||||
|
||||
item.amount = amount
|
||||
|
||||
DropQueue(receiver)
|
||||
DropQueue(player)
|
||||
.addItem(item)
|
||||
.forceTelekinesis()
|
||||
.push()
|
||||
|
||||
@@ -5,10 +5,11 @@ import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.core.display.DisplayModule
|
||||
import com.willfp.eco.core.display.DisplayPriority
|
||||
import com.willfp.eco.core.fast.FastItemStack
|
||||
import com.willfp.eco.core.fast.fast
|
||||
import com.willfp.eco.core.placeholder.context.placeholderContext
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.eco.util.formatEco
|
||||
import com.willfp.ecoitems.items.ItemUtils
|
||||
import com.willfp.ecoitems.items.ecoItem
|
||||
import com.willfp.libreforge.ItemProvidedHolder
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
@@ -19,35 +20,33 @@ class ItemsDisplay(plugin: EcoPlugin) : DisplayModule(plugin, DisplayPriority.LO
|
||||
player: Player?,
|
||||
vararg args: Any
|
||||
) {
|
||||
val fis = FastItemStack.wrap(itemStack)
|
||||
val ecoItem = ItemUtils.getEcoItem(itemStack)
|
||||
val fis = itemStack.fast()
|
||||
val ecoItem = fis.ecoItem ?: return
|
||||
|
||||
if (ecoItem != null) {
|
||||
val provided = ItemProvidedHolder(ecoItem, itemStack)
|
||||
val provided = ItemProvidedHolder(ecoItem, itemStack)
|
||||
|
||||
val itemFast = FastItemStack.wrap(ecoItem.itemStack)
|
||||
val itemFast = FastItemStack.wrap(ecoItem.itemStack)
|
||||
|
||||
val context = placeholderContext(
|
||||
player = player,
|
||||
item = itemStack
|
||||
)
|
||||
val context = placeholderContext(
|
||||
player = player,
|
||||
item = itemStack
|
||||
)
|
||||
|
||||
val lore = ecoItem.lore.map { "${Display.PREFIX}${StringUtils.format(it, context)}" }.toMutableList()
|
||||
val lore = ecoItem.lore.map { "${Display.PREFIX}${StringUtils.format(it, context)}" }.toMutableList()
|
||||
|
||||
if (player != null) {
|
||||
val lines = ecoItem.conditions.getNotMetLines(player, provided).map { Display.PREFIX + it }
|
||||
if (player != null) {
|
||||
val lines = ecoItem.conditions.getNotMetLines(player, provided).map { Display.PREFIX + it }
|
||||
|
||||
if (lines.isNotEmpty()) {
|
||||
lore.add(Display.PREFIX)
|
||||
lore.addAll(lines)
|
||||
}
|
||||
if (lines.isNotEmpty()) {
|
||||
lore.add(Display.PREFIX)
|
||||
lore.addAll(lines)
|
||||
}
|
||||
|
||||
lore.addAll(fis.lore)
|
||||
|
||||
fis.displayName = ecoItem.displayName.formatEco(context)
|
||||
fis.addItemFlags(*itemFast.itemFlags.toTypedArray())
|
||||
fis.lore = lore
|
||||
}
|
||||
|
||||
lore.addAll(fis.lore)
|
||||
|
||||
fis.displayName = ecoItem.displayName.formatEco(context)
|
||||
fis.addItemFlags(*itemFast.itemFlags.toTypedArray())
|
||||
fis.lore = lore
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.builder.ItemStackBuilder
|
||||
import com.willfp.eco.core.recipe.Recipes
|
||||
import com.willfp.eco.core.registry.Registrable
|
||||
import com.willfp.ecoitems.slot.ItemSlots
|
||||
import com.willfp.libreforge.Holder
|
||||
import com.willfp.libreforge.ViolationContext
|
||||
import com.willfp.libreforge.conditions.Conditions
|
||||
@@ -33,14 +34,13 @@ class EcoItem(
|
||||
|
||||
override val id = plugin.createNamespacedKey(id)
|
||||
|
||||
override fun getID(): String {
|
||||
return this.id.key
|
||||
}
|
||||
|
||||
val lore: List<String> = config.getStrings("item.lore")
|
||||
|
||||
val displayName: String = config.getString("item.display-name")
|
||||
|
||||
val slot = ItemSlots.getByID(config.getString("slot"))
|
||||
|
||||
// Defensive copy
|
||||
private val _itemStack: ItemStack = run {
|
||||
val itemConfig = config.getSubsection("item")
|
||||
ItemStackBuilder(Items.lookup(itemConfig.getString("item")).item).apply {
|
||||
@@ -62,7 +62,7 @@ class EcoItem(
|
||||
|
||||
val customItem = CustomItem(
|
||||
plugin.namespacedKeyFactory.create(id),
|
||||
{ test -> ItemUtils.getEcoItem(test) == this },
|
||||
{ test -> test.ecoItem == this },
|
||||
itemStack
|
||||
).apply { register() }
|
||||
|
||||
@@ -76,9 +76,13 @@ class EcoItem(
|
||||
)
|
||||
} else null
|
||||
|
||||
val baseDamage = config.getDouble("base-damage")
|
||||
val baseDamage = config.getDoubleOrNull("base-damage")
|
||||
|
||||
val baseAttackSpeed = config.getDouble("base-attack-speed")
|
||||
val baseAttackSpeed = config.getDoubleOrNull("base-attack-speed")
|
||||
|
||||
override fun getID(): String {
|
||||
return this.id.key
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is EcoItem) {
|
||||
|
||||
@@ -18,25 +18,16 @@ object EcoItems : ConfigCategory("item", "items") {
|
||||
"items"
|
||||
)
|
||||
|
||||
/**
|
||||
* Get all registered [EcoItem]s.
|
||||
*
|
||||
* @return A list of all [EcoItem]s.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun values(): List<EcoItem> {
|
||||
return ImmutableList.copyOf(registry.values())
|
||||
fun getByID(ida: String?): EcoItem? {
|
||||
if (id == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return registry[id]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get [EcoItem] matching id.
|
||||
*
|
||||
* @param name The id to search for.
|
||||
* @return The matching [EcoItem], or null if not found.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByID(name: String): EcoItem? {
|
||||
return registry[name]
|
||||
fun values(): List<EcoItem> {
|
||||
return ImmutableList.copyOf(registry.values())
|
||||
}
|
||||
|
||||
override fun clear(plugin: LibreforgePlugin) {
|
||||
|
||||
@@ -19,10 +19,12 @@ object EcoItemsRecipes : ConfigCategory("recipe", "recipes") {
|
||||
|
||||
override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) {
|
||||
val result = Items.lookup(config.getString("result"))
|
||||
val item = result.item
|
||||
val item = result.item.clone()
|
||||
|
||||
if (config.has("recipe-give-amount")) {
|
||||
item.amount = config.getInt("recipe-give-amount") // Legacy
|
||||
}
|
||||
|
||||
plugin.scheduler.run {
|
||||
Recipes.createAndRegisterRecipe(
|
||||
plugin, id, item, config.getStrings("recipe"), config.getStringOrNull("permission")
|
||||
|
||||
@@ -21,8 +21,7 @@ class ItemAttributeListener(private val plugin: EcoPlugin) : Listener {
|
||||
}
|
||||
|
||||
private fun apply(player: Player) {
|
||||
val items = ItemUtils.getEcoItemsOnPlayer(player)
|
||||
.map { it.holder as EcoItem }
|
||||
val items = player.ecoItems.map { it.holder as EcoItem }
|
||||
|
||||
val damageInst = player.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE) ?: return
|
||||
val speedInst = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED) ?: return
|
||||
@@ -65,23 +64,27 @@ class ItemAttributeListener(private val plugin: EcoPlugin) : Listener {
|
||||
}
|
||||
|
||||
for ((offset, item) in items.withIndex()) {
|
||||
damageInst.addModifier(
|
||||
AttributeModifier(
|
||||
UUID.nameUUIDFromBytes("ecoitems_ad_$offset".toByteArray()),
|
||||
"EcoItems Damage $offset",
|
||||
item.baseDamage - player.inventory.itemInMainHand.type.baseDamage,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
if (item.baseDamage != null) {
|
||||
damageInst.addModifier(
|
||||
AttributeModifier(
|
||||
UUID.nameUUIDFromBytes("ecoitems_ad_$offset".toByteArray()),
|
||||
"EcoItems Damage $offset",
|
||||
item.baseDamage - player.inventory.itemInMainHand.type.baseDamage,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
speedInst.addModifier(
|
||||
AttributeModifier(
|
||||
UUID.nameUUIDFromBytes("ecoitems_as_$offset".toByteArray()),
|
||||
"EcoItems Speed $offset",
|
||||
item.baseAttackSpeed - player.inventory.itemInMainHand.type.baseAttackSpeed,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
if (item.baseAttackSpeed != null) {
|
||||
speedInst.addModifier(
|
||||
AttributeModifier(
|
||||
UUID.nameUUIDFromBytes("ecoitems_as_$offset".toByteArray()),
|
||||
"EcoItems Speed $offset",
|
||||
item.baseAttackSpeed - player.inventory.itemInMainHand.type.baseAttackSpeed,
|
||||
AttributeModifier.Operation.ADD_NUMBER
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,8 @@ import kotlin.math.roundToInt
|
||||
object ItemListener : Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
fun onPlaceItem(event: BlockPlaceEvent) {
|
||||
ItemUtils.getEcoItem(event.itemInHand) ?: return
|
||||
event.itemInHand.ecoItem ?: return
|
||||
|
||||
if (event.itemInHand.type.isBlock) {
|
||||
event.isCancelled = true
|
||||
}
|
||||
@@ -21,7 +22,7 @@ object ItemListener : Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
fun onPlaceItem2(event: PlayerInteractEvent) {
|
||||
ItemUtils.getEcoItem(event.item) ?: return
|
||||
event.item.ecoItem ?: return
|
||||
|
||||
if (event.item?.type?.isBlock != true) {
|
||||
return
|
||||
@@ -34,9 +35,12 @@ object ItemListener : Listener {
|
||||
|
||||
@EventHandler
|
||||
fun effectiveDurabilityListener(event: PlayerItemDamageEvent) {
|
||||
val ecoItem = ItemUtils.getEcoItem(event.item) ?: return
|
||||
val ecoItem = event.item.ecoItem ?: return
|
||||
|
||||
val maxDurability = event.item.type.maxDurability.toInt()
|
||||
|
||||
val ratio = maxDurability.toDouble() / ecoItem.effectiveDurability
|
||||
|
||||
if (ratio < 1) {
|
||||
if (NumberUtils.randFloat(0.0, 1.0) > ratio) {
|
||||
event.isCancelled = true
|
||||
|
||||
@@ -1,98 +1,59 @@
|
||||
package com.willfp.ecoitems.items
|
||||
|
||||
import com.willfp.eco.core.fast.FastItemStack
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import com.willfp.ecoitems.EcoItemsPlugin.Companion.instance
|
||||
import com.willfp.eco.core.fast.fast
|
||||
import com.willfp.eco.util.namespacedKeyOf
|
||||
import com.willfp.ecoitems.slot.ItemSlots
|
||||
import com.willfp.libreforge.ItemProvidedHolder
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.meta.ItemMeta
|
||||
import org.bukkit.persistence.PersistentDataContainer
|
||||
import org.bukkit.persistence.PersistentDataType
|
||||
|
||||
object ItemUtils {
|
||||
/**
|
||||
* Instance of EcoItems.
|
||||
*/
|
||||
private val PLUGIN = instance
|
||||
private val legacyKey = namespacedKeyOf("ecoweapons", "weapon")
|
||||
private val key = namespacedKeyOf("ecoitems", "item")
|
||||
|
||||
private val legacyKey = NamespacedKeyUtils.create("ecoweapons", "weapon")
|
||||
|
||||
/**
|
||||
* Get EcoItem from an item.
|
||||
*
|
||||
* @param itemStack The itemStack to check.
|
||||
* @return The EcoItem, or null if no EcoItem is found.
|
||||
*/
|
||||
fun getEcoItem(itemStack: ItemStack?): EcoItem? {
|
||||
itemStack ?: return null
|
||||
val container = FastItemStack.wrap(itemStack).persistentDataContainer
|
||||
return getEcoItem(container)
|
||||
val ItemStack?.ecoItem: EcoItem?
|
||||
get() {
|
||||
this ?: return null
|
||||
val fis = this.fast()
|
||||
return fis.ecoItem
|
||||
}
|
||||
|
||||
/**
|
||||
* Get EcoItem from an item.
|
||||
*
|
||||
* @param meta The itemStack to check.
|
||||
* @return The EcoItem, or null if no EcoItem is found.
|
||||
*/
|
||||
fun getEcoItem(meta: ItemMeta): EcoItem? {
|
||||
val container = meta.persistentDataContainer
|
||||
return getEcoItem(container)
|
||||
}
|
||||
|
||||
private fun getEcoItem(container: PersistentDataContainer): EcoItem? {
|
||||
val legacy = container.get(
|
||||
legacyKey, PersistentDataType.STRING
|
||||
)
|
||||
|
||||
if (legacy != null) {
|
||||
container.set(
|
||||
PLUGIN.namespacedKeyFactory.create("item"), PersistentDataType.STRING, legacy
|
||||
)
|
||||
container.remove(legacyKey)
|
||||
val FastItemStack.ecoItem: EcoItem?
|
||||
get() {
|
||||
val pdc = this.persistentDataContainer
|
||||
if (pdc.has(legacyKey)) {
|
||||
pdc.remove(legacyKey)
|
||||
pdc.set(key, PersistentDataType.STRING, pdc.get(legacyKey, PersistentDataType.STRING)!!)
|
||||
}
|
||||
|
||||
val id = container.get(
|
||||
PLUGIN.namespacedKeyFactory.create("item"), PersistentDataType.STRING
|
||||
) ?: return null
|
||||
|
||||
return EcoItems.getByID(id)
|
||||
return EcoItems.getByID(pdc.get(key, PersistentDataType.STRING))
|
||||
}
|
||||
|
||||
/**
|
||||
* Get EcoItem on a player.
|
||||
*
|
||||
* @param player The player to check.
|
||||
* @return The EcoItem, or null if no EcoItem is found.
|
||||
*/
|
||||
fun getEcoItemsOnPlayer(player: Player): List<ItemProvidedHolder> {
|
||||
val list = mutableListOf<ItemProvidedHolder>()
|
||||
val Player.ecoItems: Collection<ItemProvidedHolder>
|
||||
get() {
|
||||
val ecoItems = mutableMapOf<EcoItem, ItemStack>()
|
||||
|
||||
val mainhand = getEcoItem(player.inventory.itemInMainHand)
|
||||
if (mainhand != null) {
|
||||
list.add(
|
||||
ItemProvidedHolder(
|
||||
mainhand, player.inventory.itemInMainHand
|
||||
)
|
||||
)
|
||||
}
|
||||
for (slot in ItemSlots) {
|
||||
val items = slot.getItems(this).filterNotNull()
|
||||
|
||||
if (PLUGIN.configYml.getBool("check-offhand")) {
|
||||
val offhand = getEcoItem(player.inventory.itemInOffHand)
|
||||
if (offhand != null) {
|
||||
list.add(
|
||||
ItemProvidedHolder(
|
||||
offhand, player.inventory.itemInOffHand
|
||||
)
|
||||
)
|
||||
for (item in items) {
|
||||
val ecoItem = item.ecoItem ?: continue
|
||||
if (ecoItem.slot == slot) {
|
||||
ecoItems[ecoItem] = item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list
|
||||
val provided = mutableListOf<ItemProvidedHolder>()
|
||||
|
||||
for ((ecoItem, item) in ecoItems) {
|
||||
provided.add(ItemProvidedHolder(ecoItem, item))
|
||||
}
|
||||
|
||||
return provided
|
||||
}
|
||||
}
|
||||
|
||||
val Material.baseDamage: Double
|
||||
get() {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.willfp.ecoitems.libreforge
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.util.containsIgnoreCase
|
||||
import com.willfp.ecoitems.items.EcoItem
|
||||
import com.willfp.ecoitems.items.ItemUtils
|
||||
import com.willfp.ecoitems.items.ecoItems
|
||||
import com.willfp.libreforge.NoCompileData
|
||||
import com.willfp.libreforge.arguments
|
||||
import com.willfp.libreforge.conditions.Condition
|
||||
@@ -15,7 +15,7 @@ object ConditionHasEcoItem : Condition<NoCompileData>("has_ecoitem") {
|
||||
}
|
||||
|
||||
override fun isMet(player: Player, config: Config, compileData: NoCompileData): Boolean {
|
||||
return ItemUtils.getEcoItemsOnPlayer(player)
|
||||
return player.ecoItems
|
||||
.map { it.holder }
|
||||
.filterIsInstance<EcoItem>()
|
||||
.map { it.id.key }
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.willfp.ecoitems.slot
|
||||
|
||||
import com.willfp.eco.core.registry.KRegistrable
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
abstract class ItemSlot(
|
||||
override val id: String
|
||||
) : KRegistrable {
|
||||
abstract fun getItems(player: Player): List<ItemStack?>
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is ItemSlot && this.id == other.id
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return id.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.willfp.ecoitems.slot
|
||||
|
||||
import com.willfp.eco.core.registry.Registry
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotAny
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotBoots
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotChestplate
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotHands
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotHelmet
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotLeggings
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotMainhand
|
||||
import com.willfp.ecoitems.slot.impl.ItemSlotOffhand
|
||||
|
||||
object ItemSlots : Registry<ItemSlot>() {
|
||||
fun getByID(id: String?): ItemSlot {
|
||||
if (id == null) {
|
||||
return ItemSlotHands // Legacy
|
||||
}
|
||||
|
||||
return get(id) ?: ItemSlotMainhand
|
||||
}
|
||||
|
||||
init {
|
||||
register(ItemSlotAny)
|
||||
register(ItemSlotBoots)
|
||||
register(ItemSlotChestplate)
|
||||
register(ItemSlotHands)
|
||||
register(ItemSlotHelmet)
|
||||
register(ItemSlotLeggings)
|
||||
register(ItemSlotMainhand)
|
||||
register(ItemSlotOffhand)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotAny : ItemSlot("any") {
|
||||
override fun getItems(player: Player): List<ItemStack?> {
|
||||
return player.inventory.contents.toList()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotBoots : ItemSlot("boots") {
|
||||
override fun getItems(player: Player): List<ItemStack?> {
|
||||
return listOf(
|
||||
player.inventory.boots,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotChestplate : ItemSlot("chestplate") {
|
||||
override fun getItems(player: Player): List<ItemStack?> {
|
||||
return listOf(
|
||||
player.inventory.chestplate,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotHands : ItemSlot("hands") {
|
||||
override fun getItems(player: Player): List<ItemStack> {
|
||||
return listOf(
|
||||
player.inventory.itemInMainHand,
|
||||
player.inventory.itemInOffHand
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotHelmet : ItemSlot("helmet") {
|
||||
override fun getItems(player: Player): List<ItemStack?> {
|
||||
return listOf(
|
||||
player.inventory.helmet,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotLeggings : ItemSlot("leggings") {
|
||||
override fun getItems(player: Player): List<ItemStack?> {
|
||||
return listOf(
|
||||
player.inventory.leggings,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotMainhand : ItemSlot("mainhand") {
|
||||
override fun getItems(player: Player): List<ItemStack> {
|
||||
return listOf(player.inventory.itemInMainHand)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.willfp.ecoitems.slot.impl
|
||||
|
||||
import com.willfp.ecoitems.slot.ItemSlot
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
object ItemSlotOffhand : ItemSlot("offhand") {
|
||||
override fun getItems(player: Player): List<ItemStack> {
|
||||
return listOf(player.inventory.itemInOffHand)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,4 @@
|
||||
# by Auxilor
|
||||
#
|
||||
|
||||
check-offhand: false # If items should work in offhands
|
||||
|
||||
discover-recipes: true # If all recipes should be automatically discovered.
|
||||
|
||||
@@ -33,8 +33,12 @@ item:
|
||||
|
||||
effective-durability: 1024 # Optional, set the durability
|
||||
|
||||
base-damage: 12 # The item base damage
|
||||
base-attack-speed: 1.5 # The item base attack speed
|
||||
# The slot the item has to be in to activate its effects.
|
||||
# Can be mainhand, offhand, hands, helmet, chestplate, leggings, boots, or any.
|
||||
slot: mainhand
|
||||
|
||||
base-damage: 12 # (Optional) The item base damage
|
||||
base-attack-speed: 1.5 # (Optional) The item base attack speed
|
||||
|
||||
# The effects of the item (i.e. the functionality)
|
||||
# See here: https://plugins.auxilor.io/effects/configuring-an-effect
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
item:
|
||||
item: sea_lantern unbreaking:1 hide_enchants hide_attributes
|
||||
display-name: "<gradient:11998e>Armor Core</gradient:38ef7d>"
|
||||
lore:
|
||||
- "&8Required to craft"
|
||||
- "&8Armor Sets"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ecoitems:enchanted_emerald
|
||||
- copper_block
|
||||
- amethyst_shard
|
||||
- copper_block
|
||||
- prismarine_crystals
|
||||
- copper_block
|
||||
- amethyst_shard
|
||||
- copper_block
|
||||
- ecoitems:enchanted_emerald
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
@@ -1,25 +0,0 @@
|
||||
item:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWQ3ZTc3MmM5Mjk1NDUzYzZhYTYyNDVmZmI0MDJmZGY2NzExMWI5NjE3OTE4OWJkMzBlMzY2NmY5NThiOTkifX19
|
||||
display-name: "&fBlank Reforge Stone"
|
||||
lore:
|
||||
- "&8Required to craft reforge"
|
||||
- "&8stones to give rare and powerful"
|
||||
- "&8reforges on your items"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ecoitems:enchanted_iron_ingot
|
||||
- ""
|
||||
- ecoitems:enchanted_iron_ingot
|
||||
- ""
|
||||
- ecoitems:enchanted_cobblestone
|
||||
- ""
|
||||
- ecoitems:enchanted_iron_ingot
|
||||
- ""
|
||||
- ecoitems:enchanted_iron_ingot
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
item:
|
||||
item: egg unbreaking:1 hide_enchants hide_attributes
|
||||
display-name: "<gradient:#1cefff>Boss Core</gradient:#c0c0aa>"
|
||||
lore:
|
||||
- "&8Required to craft boss"
|
||||
- "&8spawn eggs"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_pearl
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_pearl
|
||||
- ecoitems:enchanted_diamond
|
||||
- ecoitems:enchanted_ender_pearl
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_pearl
|
||||
- ""
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
item:
|
||||
item: bow hide_attributes
|
||||
effective-durability: 1920
|
||||
display-name: "<gradient:#67B26F>Bow of Thirds</gradient:#4ca2cd>"
|
||||
lore:
|
||||
- "<gradient:#67B26F>&lBOW OF THIRDS BONUS</gradient:#4ca2cd>"
|
||||
- "&8» ca2cdEvery third shot will shoot three arrows"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- stick
|
||||
- string
|
||||
- stick
|
||||
- ecoitems:enchanted_ender_eye 16
|
||||
- string
|
||||
- ""
|
||||
- stick
|
||||
- string
|
||||
|
||||
base-damage: 1
|
||||
base-attack-speed: 4
|
||||
|
||||
effects:
|
||||
- id: shoot_arrow
|
||||
args:
|
||||
every: 3
|
||||
repeat:
|
||||
times: 2
|
||||
start: -11
|
||||
increment: 22
|
||||
inherit_velocity: true
|
||||
mutators:
|
||||
- id: spin_velocity
|
||||
args:
|
||||
angle: '%repeat_count%'
|
||||
triggers:
|
||||
- shoot_bow
|
||||
conditions: [ ]
|
||||
@@ -0,0 +1,31 @@
|
||||
item:
|
||||
item: fishing_rod hide_attributes hide_enchants unbreaking:1
|
||||
display-name: "&9Grappling Hook"
|
||||
lore:
|
||||
- "&7Travel in style using"
|
||||
- "&7this Grappling Hook!"
|
||||
- "&82.5 Second Cooldown"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- ""
|
||||
- ecoitem:enchanted_diamond
|
||||
- ""
|
||||
- stick
|
||||
- ecoitem:enchanted_diamond
|
||||
- stick
|
||||
- ""
|
||||
- ""
|
||||
|
||||
slot: mainhand
|
||||
|
||||
effects:
|
||||
- id: pull_to_location
|
||||
args:
|
||||
send_cooldown_message: true
|
||||
cooldown: 2.5
|
||||
velocity: 1.5
|
||||
triggers:
|
||||
- hook_in_ground
|
||||
|
||||
conditions: [ ]
|
||||
@@ -1,26 +0,0 @@
|
||||
item:
|
||||
item: netherite_pickaxe hide_attributes
|
||||
display-name: "&bHardened Netherite Pickaxe"
|
||||
effective-durability: 4096
|
||||
lore:
|
||||
- "&7Damage: &c6❤"
|
||||
- "&7Attack Speed: &c1.3"
|
||||
craftable: true
|
||||
craftingPermission:
|
||||
recipe:
|
||||
- netherite_ingot
|
||||
- netherite_ingot
|
||||
- netherite_ingot
|
||||
- ""
|
||||
- stick
|
||||
- ""
|
||||
- ""
|
||||
- stick
|
||||
- ""
|
||||
|
||||
base-damage: 6
|
||||
base-attack-speed: 1.3
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
item:
|
||||
item: netherite_sword hide_attributes
|
||||
effective-durability: 4096
|
||||
display-name: "&bHardened Netherite Sword"
|
||||
lore:
|
||||
- "&7Damage: &c9❤"
|
||||
- "&7Attack Speed: &c1.6"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- netherite_ingot
|
||||
- ""
|
||||
- ""
|
||||
- netherite_ingot
|
||||
- ""
|
||||
- ""
|
||||
- stick
|
||||
- ""
|
||||
|
||||
base-damage: 9
|
||||
base-attack-speed: 1.6
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
item:
|
||||
item: blaze_rod hide_attributes
|
||||
display-name: "<g:#FF512F>Infernal Spear</g:#F09819>"
|
||||
lore:
|
||||
- "&7Damage: &c10❤"
|
||||
- "&7Attack Speed: &c1.5"
|
||||
- ""
|
||||
- "<g:#FF512F>&lINFERNAL SPEAR BONUS</g:#F09819>"
|
||||
- "&8» &#FF512FDeal 50% more damage in the nether"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- wither_skeleton_skull 16
|
||||
- ""
|
||||
- ""
|
||||
- iron_ingot 16
|
||||
- ""
|
||||
- ""
|
||||
- blaze_rod 16
|
||||
- ""
|
||||
|
||||
base-damage: 10
|
||||
base-attack-speed: 1.5
|
||||
|
||||
effects:
|
||||
- id: damage_multiplier
|
||||
args:
|
||||
multiplier: 1.5
|
||||
triggers:
|
||||
- melee_attack
|
||||
conditions:
|
||||
- id: in_world
|
||||
args:
|
||||
world: world_the_nether
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
item:
|
||||
item: netherite_sword hide_attributes
|
||||
display-name: "<g:#870000>Reaper Scythe</g:#7a2828>"
|
||||
lore:
|
||||
- "&7Damage: &c12❤"
|
||||
- "&7Attack Speed: &c2.0"
|
||||
- ""
|
||||
- "<g:#870000>&lREAPER SCYTHE BONUS</g:#7a2828>"
|
||||
- "&8» �% chance to bleed enemies"
|
||||
- ""
|
||||
- "&4❣ &cMust be on full health for bonus"
|
||||
- "&4❣ &cConsumes <g:#870000>Reaper Souls</g:#7a2828>"
|
||||
craftable: true
|
||||
recipe:
|
||||
- nether_star
|
||||
- netherite_sword
|
||||
- nether_star
|
||||
- netherite_sword
|
||||
- golden_hoe
|
||||
- netherite_sword
|
||||
- nether_star
|
||||
- netherite_sword
|
||||
- nether_star
|
||||
|
||||
base-damage: 12
|
||||
base-attack-speed: 2.0
|
||||
|
||||
effects:
|
||||
- effects:
|
||||
- id: bleed
|
||||
args:
|
||||
damage: 2
|
||||
amount: 5
|
||||
interval: 10
|
||||
chance: 25
|
||||
- id: remove_item
|
||||
args:
|
||||
item: ecoitems:reaper_soul
|
||||
triggers:
|
||||
- melee_attack
|
||||
|
||||
conditions:
|
||||
- id: above_health_percent
|
||||
args:
|
||||
percent: 98
|
||||
- id: has_item
|
||||
args:
|
||||
item: ecoitems:reaper_soul
|
||||
@@ -1,24 +0,0 @@
|
||||
item:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDc3NGU1ZWYzZDhiY2RlOWVhMjFjMzRiODQ4MjdkMzQ1MzFlNjhmMTExNTEwZjMzODMwNTVlY2FhNzRiZWJjYyJ9fX0=
|
||||
display-name: "<g:#870000>Reaper Soul</g:#7a2828>"
|
||||
lore:
|
||||
- "&7Fuel for the <g:#870000>Reaper Scythe</g:#7a2828>"
|
||||
- "&7Consumed while using the weapon"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- gold_ingot
|
||||
- ""
|
||||
- ""
|
||||
- iron_ingot
|
||||
- ""
|
||||
- soul_soil
|
||||
- soul_sand
|
||||
- soul_soil
|
||||
recipe-give-amount: 4
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
@@ -1,37 +0,0 @@
|
||||
item:
|
||||
item: iron_sword hide_attributes
|
||||
display-name: "<g:#FDC830>Rogue Zweihänder</g:#F37335>"
|
||||
lore:
|
||||
- "&7Damage: &c7❤"
|
||||
- "&7Attack Speed: &c1.5"
|
||||
- ""
|
||||
- "<g:#FDC830>&lROGUE ZWEIHÄNDER BONUS</g:#F37335>"
|
||||
- "&8» &#FDC830Deal 50% more damage against"
|
||||
- "&#FDC830zombies"
|
||||
craftable: true
|
||||
recipe:
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
- iron_sword
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
- rotten_flesh 64
|
||||
|
||||
base-damage: 7
|
||||
base-attack-speed: 1.2
|
||||
|
||||
effects:
|
||||
- id: damage_multiplier
|
||||
args:
|
||||
multiplier: 1.5
|
||||
filters:
|
||||
entities:
|
||||
- zombie
|
||||
- husk
|
||||
- drowned
|
||||
triggers:
|
||||
- melee_attack
|
||||
conditions: [ ]
|
||||
@@ -1,23 +0,0 @@
|
||||
item:
|
||||
item: lime_glazed_terracotta unbreaking:1 hide_enchants hide_attributes
|
||||
display-name: "<gradient:12c2e9>Talisman Core</gradient:c471ed> &aI"
|
||||
lore:
|
||||
- "&8Required to craft"
|
||||
- "&aTier I&8 Talismans"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_eye
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_eye
|
||||
- obsidian
|
||||
- ecoitems:enchanted_ender_eye
|
||||
- ""
|
||||
- ecoitems:enchanted_ender_eye
|
||||
- ""
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
@@ -1,23 +0,0 @@
|
||||
item:
|
||||
item: light_blue_glazed_terracotta unbreaking:1 hide_enchants hide_attributes
|
||||
display-name: "<gradient:12c2e9>Talisman Core</gradient:c471ed> &eII"
|
||||
lore:
|
||||
- "&8Required to craft"
|
||||
- "&eTier II&8 Talismans"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ecoitems:talisman_core_1
|
||||
- ""
|
||||
- ecoitems:talisman_core_1
|
||||
- ""
|
||||
- ""
|
||||
- ""
|
||||
- ecoitems:talisman_core_1
|
||||
- ""
|
||||
- ecoitems:talisman_core_1
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
@@ -1,23 +0,0 @@
|
||||
item:
|
||||
item: pink_glazed_terracotta unbreaking:1 hide_enchants hide_attributes
|
||||
display-name: "<gradient:12c2e9>Talisman Core</gradient:c471ed> &cIII"
|
||||
lore:
|
||||
- "&8Required to craft"
|
||||
- "&cTier III&8 Talismans"
|
||||
craftable: true
|
||||
recipe:
|
||||
- ecoitems:talisman_core_2
|
||||
- ""
|
||||
- ecoitems:talisman_core_2
|
||||
- ""
|
||||
- ""
|
||||
- ""
|
||||
- ecoitems:talisman_core_2
|
||||
- ""
|
||||
- ecoitems:talisman_core_2
|
||||
|
||||
base-damage: 0
|
||||
base-attack-speed: 1
|
||||
|
||||
effects: [ ]
|
||||
conditions: [ ]
|
||||
@@ -5,8 +5,6 @@ messages:
|
||||
invalid-command: "&cUnknown subcommand!"
|
||||
reloaded: "Reloaded!"
|
||||
|
||||
needs-player: "&cYou must specify a player"
|
||||
invalid-player: "&cInvalid player!"
|
||||
needs-item: "&cYou must specify an item!"
|
||||
invalid-item: "&cInvalid item!"
|
||||
give-success: "Gave &a%item%&r to &a%recipient%"
|
||||
give-success: "Gave &a%item%&r to &a%recipient%&f!"
|
||||
|
||||
@@ -10,3 +10,5 @@ recipe: # The recipe, read here for more: https://plugins.auxilor.io/all-plugins
|
||||
- ""
|
||||
- emerald_block 32
|
||||
- ""
|
||||
|
||||
permission: "ecoitems.craft.enchanted_emerald_block_craft" # (Optional) The permission required to craft this recipe.
|
||||
|
||||
Reference in New Issue
Block a user