From 20addceac1662ce922566e61ec4e538fdf56b2ca Mon Sep 17 00:00:00 2001 From: Krakenied Date: Wed, 11 Sep 2024 10:19:03 +0200 Subject: Remove thrower from the map if it's null --- .../quests/bukkit/tasktype/type/BarteringTaskType.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bukkit/src') diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BarteringTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BarteringTaskType.java index b2d4c88c..8186f90a 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BarteringTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/BarteringTaskType.java @@ -28,6 +28,9 @@ import java.util.Map; import java.util.UUID; import java.util.WeakHashMap; +/** + * TODO: There is Paper PR to make obtaining the thrower UUID easier: Paper#5736 + */ public final class BarteringTaskType extends BukkitTaskType { private final BukkitQuestsPlugin plugin; @@ -60,7 +63,12 @@ public final class BarteringTaskType extends BukkitTaskType { if (entity instanceof final Piglin piglin) { final UUID throwerId = event.getItem().getOwner(); - this.piglin2ThrowerIdMap.put(piglin, throwerId); + + if (throwerId != null) { + this.piglin2ThrowerIdMap.put(piglin, throwerId); + } else { + this.piglin2ThrowerIdMap.remove(piglin); + } } } -- cgit v1.2.3-70-g09d2