Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Dec 27, 2023
2 parents 01486f5 + 58cfa31 commit 263cfc3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val Location.namedBiome: NamedBiome?
val world = this.world ?: return null
val vanilla = world.getBiome(this)

return if (vanilla.name.lowercase() == "biome") {
return if (vanilla.name.lowercase() == "custom") {
customBiomesIntegrations
.firstOrNull { it.getBiome(this) != null }
?.getBiome(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.willfp.libreforge.triggers.event

import com.willfp.eco.util.toSingletonList
import org.bukkit.Location
import org.bukkit.event.Cancellable
import org.bukkit.event.Event
import org.bukkit.event.HandlerList
import org.bukkit.event.block.BlockDropItemEvent
import org.bukkit.event.entity.EntityDeathEvent
import org.bukkit.event.player.PlayerDropItemEvent
import org.bukkit.inventory.ItemStack


Expand Down Expand Up @@ -137,3 +139,36 @@ class EditableBlockDropEvent(
event.isCancelled = p0
}
}

class EditablePlayerDropEvent(
private val event: PlayerDropItemEvent
): EditableDropEvent() {
private val modifiers = mutableListOf<DropModifier>()

override fun addModifier(modifier: DropModifier) {
modifiers += modifier
}

override val originalItems: List<ItemStack>
get() = event.itemDrop.itemStack.toSingletonList()

override val items: List<DropResult>
get() = originalItems.map { modifiers.modify(it) }

override val dropLocation: Location
get() = event.itemDrop.location

override fun removeItem(item: ItemStack) {
if (event.itemDrop.itemStack == item) {
event.itemDrop.remove()
}
}

override fun isCancelled(): Boolean {
return event.isCancelled
}

override fun setCancelled(p0: Boolean) {
event.isCancelled = p0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.willfp.libreforge.toDispatcher
import com.willfp.libreforge.triggers.Trigger
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.libreforge.triggers.TriggerParameter
import com.willfp.libreforge.triggers.event.EditablePlayerDropEvent
import org.bukkit.event.EventHandler
import org.bukkit.event.player.PlayerDropItemEvent

Expand All @@ -25,7 +26,7 @@ object TriggerDropItem : Trigger("drop_item") {
player = player,
item = event.itemDrop.itemStack,
value = event.itemDrop.itemStack.amount.toDouble(),
event = event,
event = EditablePlayerDropEvent(event),
location = event.itemDrop.location
)
)
Expand Down

0 comments on commit 263cfc3

Please sign in to comment.