mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-06 15:51:52 +00:00
Farming skill will now properly support bamboo and sugar cane
This commit is contained in:
@@ -4,6 +4,7 @@ import com.willfp.eco.util.BlockUtils
|
||||
import com.willfp.ecoskills.giveSkillExperience
|
||||
import com.willfp.ecoskills.skills.Skill
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.BlockFace
|
||||
import org.bukkit.block.data.Ageable
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
@@ -14,6 +15,10 @@ class SkillFarming : Skill(
|
||||
"farming"
|
||||
) {
|
||||
private val rewards: MutableMap<Material, Double>
|
||||
private val stackedCrops = listOf(
|
||||
Material.SUGAR_CANE,
|
||||
Material.BAMBOO
|
||||
)
|
||||
|
||||
init {
|
||||
rewards = EnumMap(org.bukkit.Material::class.java)
|
||||
@@ -60,6 +65,16 @@ class SkillFarming : Skill(
|
||||
|
||||
val toGive = rewards[type] ?: return
|
||||
|
||||
player.giveSkillExperience(this, toGive)
|
||||
var amount = 1
|
||||
|
||||
if (type in stackedCrops) {
|
||||
var current = event.block.getRelative(BlockFace.UP)
|
||||
while (current.type == type) {
|
||||
amount++
|
||||
current = current.getRelative(BlockFace.UP)
|
||||
}
|
||||
}
|
||||
|
||||
player.giveSkillExperience(this, toGive*amount)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user