mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Merge pull request #418 from emortaldev/master
Add getPlayer() to PickupExperienceEvent
This commit is contained in:
commit
7d752cc323
@ -318,7 +318,7 @@ 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(this, experienceOrb);
|
||||
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
||||
short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player
|
||||
entity.remove();
|
||||
|
@ -1,21 +1,30 @@
|
||||
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 Player player;
|
||||
private final ExperienceOrb experienceOrb;
|
||||
private short experienceCount;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PickupExperienceEvent(@NotNull 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;
|
||||
|
Loading…
Reference in New Issue
Block a user