Skip to content

Commit

Permalink
Merge pull request #348 from Auxilor/develop
Browse files Browse the repository at this point in the history
Added ability to modify items on DropQueuePushEvent
  • Loading branch information
WillFP authored Apr 8, 2024
2 parents ab73c22 + 7ef928c commit 4209161
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -114,6 +114,15 @@ public Collection<? extends ItemStack> getItems() {
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PlaceholderParser {
val prefix = "%${additionalPlayer.identifier}_"
processed = found.fold(processed) { acc, placeholder ->
if (placeholder.startsWith(prefix)) {
val newPlaceholder = "%${StringUtils.removePrefix(prefix, placeholder)}"
val newPlaceholder = "%${StringUtils.removePrefix(placeholder, prefix)}"
val translation = translatePlacholders(
newPlaceholder,
context.copyWithPlayer(additionalPlayer.player),
Expand Down

0 comments on commit 4209161

Please sign in to comment.