mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Add getPlayer() to PickupExperienceEvent
This commit is contained in:
parent
9750e1fe8b
commit
a0696bc20b
@ -318,9 +318,10 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
if (expandedBoundingBox.intersect(itemBoundingBox)) {
|
||||
if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled())
|
||||
continue;
|
||||
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb);
|
||||
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb, this);
|
||||
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
||||
short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player
|
||||
short experienceCount = pickupExperienceEvent.getExperienceCount();
|
||||
this.setExp(this.getExp() + experienceCount);
|
||||
entity.remove();
|
||||
});
|
||||
}
|
||||
|
@ -1,18 +1,21 @@
|
||||
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 org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PickupExperienceEvent implements CancellableEvent {
|
||||
|
||||
private final ExperienceOrb experienceOrb;
|
||||
private final Player player;
|
||||
private short experienceCount;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb) {
|
||||
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb, @NotNull Player player) {
|
||||
this.experienceOrb = experienceOrb;
|
||||
this.player = player;
|
||||
this.experienceCount = experienceOrb.getExperienceCount();
|
||||
}
|
||||
|
||||
@ -21,6 +24,11 @@ public class PickupExperienceEvent implements CancellableEvent {
|
||||
return experienceOrb;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public short getExperienceCount() {
|
||||
return experienceCount;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user