aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0162-PlayerPickupExperienceEvent.patch
blob: c4ef53a2055cf8dd99cdabce9b9c340c4d5191c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 19 Dec 2017 22:02:53 -0500
Subject: [PATCH] PlayerPickupExperienceEvent

Allows plugins to cancel a player picking up an experience orb

diff --git a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
index ae70ad9d6c02fcb5631a3c45db283b29844bbb0d..0f55715f2d97ab09746a51f9d39134b513778fdd 100644
--- a/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
+++ b/src/main/java/net/minecraft/world/entity/ExperienceOrb.java
@@ -312,7 +312,7 @@ public class ExperienceOrb extends Entity {
     @Override
     public void playerTouch(Player player) {
         if (!this.level().isClientSide) {
-            if (player.takeXpDelay == 0) {
+            if (player.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(((net.minecraft.server.level.ServerPlayer) player).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(player, this.value);