From b14d34fea2ee4a99c34d46812db5e5a8098dc482 Mon Sep 17 00:00:00 2001 From: Pablete1234 Date: Tue, 19 Jul 2022 03:57:22 +0200 Subject: [PATCH] Expose displaced items in kit event Signed-off-by: Pablete1234 --- core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java | 9 ++++++++- core/src/main/java/tc/oc/pgm/kits/ItemKit.java | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java b/core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java index 9799a11f1d..515a2643a5 100644 --- a/core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java +++ b/core/src/main/java/tc/oc/pgm/kits/ApplyItemKitEvent.java @@ -13,8 +13,10 @@ public class ApplyItemKitEvent extends ApplyKitEvent { private final Map slotItems; private final List freeItems; + private final List displacedItems; - public ApplyItemKitEvent(MatchPlayer player, ItemKit kit, boolean force) { + public ApplyItemKitEvent( + MatchPlayer player, ItemKit kit, boolean force, List displacedItems) { super(player, kit, force); this.slotItems = new HashMap<>(kit.getSlotItems().size()); @@ -26,6 +28,7 @@ public ApplyItemKitEvent(MatchPlayer player, ItemKit kit, boolean force) { for (ItemStack stack : kit.getFreeItems()) { this.freeItems.add(stack.clone()); } + this.displacedItems = displacedItems; } /** @@ -40,6 +43,10 @@ public List getFreeItems() { return freeItems; } + public List getDisplacedItems() { + return displacedItems; + } + /** * Return all items that will be applied by the kit. Iterators from the returned iterable support * {@link Iterator#remove} to prevent the item from being applied, without modifying the original diff --git a/core/src/main/java/tc/oc/pgm/kits/ItemKit.java b/core/src/main/java/tc/oc/pgm/kits/ItemKit.java index b6ec15acd0..957e0dad69 100644 --- a/core/src/main/java/tc/oc/pgm/kits/ItemKit.java +++ b/core/src/main/java/tc/oc/pgm/kits/ItemKit.java @@ -43,7 +43,7 @@ public Iterable getItems() { */ @Override public void apply(MatchPlayer player, boolean force, List displacedItems) { - ApplyItemKitEvent event = new ApplyItemKitEvent(player, this, force); + ApplyItemKitEvent event = new ApplyItemKitEvent(player, this, force, displacedItems); player.getMatch().callEvent(event); if (event.isCancelled()) { return;