Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to modify items on DropQueuePushEvent #348

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading