mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-07 00:48:28 +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 (expandedBoundingBox.intersect(itemBoundingBox)) {
|
||||||
if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled())
|
if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled())
|
||||||
continue;
|
continue;
|
||||||
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb);
|
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb, this);
|
||||||
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
||||||
short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player
|
short experienceCount = pickupExperienceEvent.getExperienceCount();
|
||||||
|
this.setExp(this.getExp() + experienceCount);
|
||||||
entity.remove();
|
entity.remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package net.minestom.server.event.item;
|
package net.minestom.server.event.item;
|
||||||
|
|
||||||
import net.minestom.server.entity.ExperienceOrb;
|
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.CancellableEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PickupExperienceEvent implements CancellableEvent {
|
public class PickupExperienceEvent implements CancellableEvent {
|
||||||
|
|
||||||
private final ExperienceOrb experienceOrb;
|
private final ExperienceOrb experienceOrb;
|
||||||
|
private final Player player;
|
||||||
private short experienceCount;
|
private short experienceCount;
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb) {
|
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb, @NotNull Player player) {
|
||||||
this.experienceOrb = experienceOrb;
|
this.experienceOrb = experienceOrb;
|
||||||
|
this.player = player;
|
||||||
this.experienceCount = experienceOrb.getExperienceCount();
|
this.experienceCount = experienceOrb.getExperienceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,6 +24,11 @@ public class PickupExperienceEvent implements CancellableEvent {
|
|||||||
return experienceOrb;
|
return experienceOrb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
public short getExperienceCount() {
|
public short getExperienceCount() {
|
||||||
return experienceCount;
|
return experienceCount;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user