Added ability to modify items on DropQueuePushEvent
This commit is contained in:
@@ -27,7 +27,7 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
/**
|
||||
* The items.
|
||||
*/
|
||||
private final Collection<? extends ItemStack> items;
|
||||
private Collection<? extends ItemStack> items;
|
||||
|
||||
/**
|
||||
* The xp.
|
||||
@@ -114,6 +114,15 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the items to be dropped.
|
||||
*
|
||||
* @param items The items.
|
||||
*/
|
||||
public void setItems(Collection<? extends ItemStack> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the xp to be dropped.
|
||||
*
|
||||
|
||||
@@ -54,13 +54,16 @@ open class EcoDropQueue(val player: Player) : DropQueue() {
|
||||
hasTelekinesis = false
|
||||
}
|
||||
|
||||
val pushEvent = DropQueuePushEvent(player, items, location, xp, hasTelekinesis)
|
||||
val pushEvent = DropQueuePushEvent(player, items.toMutableList(), location, xp, hasTelekinesis)
|
||||
Bukkit.getServer().pluginManager.callEvent(pushEvent)
|
||||
|
||||
if (pushEvent.isCancelled) {
|
||||
return
|
||||
}
|
||||
|
||||
items.clear()
|
||||
items.addAll(pushEvent.items)
|
||||
|
||||
val world = location.world!!
|
||||
location = location.add(0.5, 0.5, 0.5)
|
||||
items.removeIf { itemStack: ItemStack -> itemStack.type == Material.AIR }
|
||||
|
||||
Reference in New Issue
Block a user