mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +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 (expandedBoundingBox.intersect(itemBoundingBox)) {
|
||||||
if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled())
|
if (experienceOrb.shouldRemove() || experienceOrb.isRemoveScheduled())
|
||||||
continue;
|
continue;
|
||||||
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(experienceOrb);
|
PickupExperienceEvent pickupExperienceEvent = new PickupExperienceEvent(this, experienceOrb);
|
||||||
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
EventDispatcher.callCancellable(pickupExperienceEvent, () -> {
|
||||||
short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player
|
short experienceCount = pickupExperienceEvent.getExperienceCount(); // TODO give to player
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
@ -1,21 +1,30 @@
|
|||||||
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 net.minestom.server.event.trait.PlayerEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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 final ExperienceOrb experienceOrb;
|
||||||
private short experienceCount;
|
private short experienceCount;
|
||||||
|
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public PickupExperienceEvent(@NotNull ExperienceOrb experienceOrb) {
|
public PickupExperienceEvent(@NotNull Player player, @NotNull ExperienceOrb experienceOrb) {
|
||||||
|
this.player = player;
|
||||||
this.experienceOrb = experienceOrb;
|
this.experienceOrb = experienceOrb;
|
||||||
this.experienceCount = experienceOrb.getExperienceCount();
|
this.experienceCount = experienceOrb.getExperienceCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExperienceOrb getExperienceOrb() {
|
public ExperienceOrb getExperienceOrb() {
|
||||||
return experienceOrb;
|
return experienceOrb;
|
||||||
|
Loading…
Reference in New Issue
Block a user