diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index d74c6eedf..21e533eb3 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -318,10 +318,9 @@ public class Player extends LivingEntity implements CommandSender, Localizable, if (expandedBoundingBox.intersect(itemBoundingBox)) { if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled()) continue; - PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb, this); + PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(this, experienceOrb); EventDispatcher.callCancellable(pickupExperienceEvent, () -> { - short experienceCount = pickupExperienceEvent.getExperienceCount(); - this.setExp(this.getExp() + experienceCount); + short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player entity.remove(); }); } diff --git a/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java b/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java index e85e053c1..f6f391729 100644 --- a/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java +++ b/src/main/java/net/minestom/server/event/item/PickupExperienceEvent.java @@ -3,32 +3,33 @@ package net.minestom.server.event.item; import net.minestom.server.entity.ExperienceOrb; import net.minestom.server.entity.Player; import net.minestom.server.event.trait.CancellableEvent; +import net.minestom.server.event.trait.PlayerEvent; import org.jetbrains.annotations.NotNull; -public class PickupExperienceEvent implements CancellableEvent { +public class PickupExperienceEvent implements CancellableEvent, PlayerEvent { - private final ExperienceOrb experienceOrb; private final Player player; + private final ExperienceOrb experienceOrb; private short experienceCount; private boolean cancelled; - public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb, @NotNull Player player) { - this.experienceOrb = experienceOrb; + public PickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) { this.player = player; + this.experienceOrb = experienceOrb; this.experienceCount = experienceOrb.getExperienceCount(); } + @Override + public @NotNull Player getPlayer() { + return player; + } + @NotNull public ExperienceOrb getExperienceOrb() { return experienceOrb; } - @NotNull - public Player getPlayer() { - return player; - } - public short getExperienceCount() { return experienceCount; }