Remove unrelated changes, make PickupExperienceEvent implement PlayerEvent

This commit is contained in:
emortal 2021-08-19 05:22:57 +01:00
parent a0696bc20b
commit 2e548e6582
2 changed files with 12 additions and 12 deletions

View File

@ -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();
});
}

View File

@ -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;
}