From dbbab8518e41e5529f0070db3257a0c0de72dc7c Mon Sep 17 00:00:00 2001 From: often Date: Sat, 24 Feb 2024 21:13:01 +0300 Subject: [PATCH 1/2] Added ability to modify items on DropQueuePushEvent --- .../willfp/eco/core/events/DropQueuePushEvent.java | 11 ++++++++++- .../com/willfp/eco/internal/drops/EcoDropQueue.kt | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/eco-api/src/main/java/com/willfp/eco/core/events/DropQueuePushEvent.java b/eco-api/src/main/java/com/willfp/eco/core/events/DropQueuePushEvent.java index 11148fa2a..b113684fd 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/events/DropQueuePushEvent.java +++ b/eco-api/src/main/java/com/willfp/eco/core/events/DropQueuePushEvent.java @@ -27,7 +27,7 @@ public class DropQueuePushEvent extends PlayerEvent implements Cancellable { /** * The items. */ - private final Collection items; + private Collection items; /** * The xp. @@ -114,6 +114,15 @@ public Collection getItems() { return items; } + /** + * Set the items to be dropped. + * + * @param items The items. + */ + public void setItems(Collection items) { + this.items = items; + } + /** * Get the xp to be dropped. * diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/drops/EcoDropQueue.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/drops/EcoDropQueue.kt index 5d68219a9..d9e26d475 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/drops/EcoDropQueue.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/drops/EcoDropQueue.kt @@ -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 } From 7ef928c3600e512ecd64527e8490e3aa0c00fce2 Mon Sep 17 00:00:00 2001 From: often Date: Sat, 16 Mar 2024 20:21:14 +0300 Subject: [PATCH 2/2] Fixed additional player placeholders --- .../com/willfp/eco/internal/placeholder/PlaceholderParser.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/placeholder/PlaceholderParser.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/placeholder/PlaceholderParser.kt index 72b173684..66dd0f745 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/placeholder/PlaceholderParser.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/placeholder/PlaceholderParser.kt @@ -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),