Skip to content

Commit

Permalink
Remove thrower from the map if it's null
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed Sep 11, 2024
1 parent b204931 commit 20addce
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import java.util.UUID;
import java.util.WeakHashMap;

/**
* TODO: There is Paper PR to make obtaining the thrower UUID easier: <a href="https://github.com/PaperMC/Paper/pull/5736">Paper#5736</a>
*/
public final class BarteringTaskType extends BukkitTaskType {

private final BukkitQuestsPlugin plugin;
Expand Down Expand Up @@ -60,7 +63,12 @@ public void onEntityPickupItem(final @NotNull EntityPickupItemEvent event) {

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);
}
}
}

Expand Down

0 comments on commit 20addce

Please sign in to comment.