mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-08 22:37:38 +01:00
Added Replenish
This commit is contained in:
parent
335dc1814c
commit
78748b9b7e
@ -15,6 +15,7 @@ import com.willfp.ecoenchants.enchants.LoreConversion
|
||||
import com.willfp.ecoenchants.enchants.impl.EnchantmentPermanenceCurse
|
||||
import com.willfp.ecoenchants.enchants.impl.EnchantmentRapid
|
||||
import com.willfp.ecoenchants.enchants.impl.EnchantmentRepairing
|
||||
import com.willfp.ecoenchants.enchants.impl.EnchantmentReplenish
|
||||
import com.willfp.ecoenchants.enchants.impl.EnchantmentTelekinesis
|
||||
import com.willfp.ecoenchants.enchants.registerVanillaEnchants
|
||||
import com.willfp.ecoenchants.integrations.EnchantRegistrations
|
||||
@ -52,6 +53,7 @@ class EcoEnchantsPlugin : LibReforgePlugin() {
|
||||
EnchantmentPermanenceCurse(this)
|
||||
EnchantmentRepairing(this)
|
||||
EnchantmentRapid(this)
|
||||
EnchantmentReplenish(this)
|
||||
|
||||
registerVanillaEnchants(this)
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
package com.willfp.ecoenchants.enchants.impl
|
||||
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin
|
||||
import com.willfp.ecoenchants.enchants.EcoEnchant
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.data.Ageable
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.block.BlockBreakEvent
|
||||
|
||||
class EnchantmentReplenish(
|
||||
plugin: EcoEnchantsPlugin
|
||||
) : EcoEnchant(
|
||||
"replenish",
|
||||
plugin,
|
||||
force = false
|
||||
) {
|
||||
init {
|
||||
this.registerListener(ReplenishHandler(plugin))
|
||||
}
|
||||
|
||||
private class ReplenishHandler(
|
||||
private val plugin: EcoEnchantsPlugin
|
||||
) : Listener {
|
||||
@EventHandler(
|
||||
ignoreCancelled = true
|
||||
)
|
||||
fun handle(event: BlockBreakEvent) {
|
||||
val player = event.player
|
||||
val block = event.block
|
||||
val type = block.type
|
||||
|
||||
if (type in arrayOf(
|
||||
Material.GLOW_BERRIES,
|
||||
Material.SWEET_BERRY_BUSH,
|
||||
Material.CACTUS,
|
||||
Material.BAMBOO,
|
||||
Material.CHORUS_FLOWER,
|
||||
Material.SUGAR_CANE
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
val data = block.blockData
|
||||
|
||||
if (data !is Ageable) {
|
||||
return
|
||||
}
|
||||
|
||||
if (data.age != data.maximumAge) {
|
||||
event.isDropItems = false
|
||||
event.expToDrop = 0
|
||||
}
|
||||
|
||||
data.age = 0
|
||||
|
||||
plugin.scheduler.run {
|
||||
block.type = type
|
||||
block.blockData = data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
display-name: "Replenish"
|
||||
description: "Crops are replanted automatically"
|
||||
type: normal
|
||||
|
||||
targets:
|
||||
- hoe
|
||||
conflicts: [ ]
|
||||
rarity: legendary
|
||||
max-level: 1
|
||||
|
||||
tradeable: true
|
||||
discoverable: true
|
||||
enchantable: true
|
||||
|
||||
conditions: [ ]
|
||||
|
Loading…
Reference in New Issue
Block a user