PlayerPickupExperienceEvent

Allows plugins to cancel a player picking up an experience orb
This commit is contained in:
Aikar 2017-12-19 22:02:53 -05:00
parent ed76af5637
commit 533b86c3fc

View file

@ -177,8 +177,9 @@
@Override
public void playerTouch(Player player) {
if (player instanceof ServerPlayer entityplayer) {
if (player.takeXpDelay == 0) {
- if (player.takeXpDelay == 0) {
- player.takeXpDelay = 2;
+ if (player.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(entityplayer.getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper - PlayerPickupExperienceEvent
+ player.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(player, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2;
player.take(this, 1);
int i = this.repairPlayerItems(entityplayer, this.value);