Paper/Spigot-Server-Patches/0121-Add-source-to-PlayerExpChangeEvent.patch
Aikar ce2eae5ce3
[Auto] Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b56e8160 #519: Add ArrowBodyCountChangeEvent

CraftBukkit Changes:
39806409e #697: Add ArrowBodyCountChangeEvent
2020-09-02 05:12:25 -04:00

50 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: AlphaBlend <whizkid3000@hotmail.com>
Date: Thu, 8 Sep 2016 08:48:33 -0700
Subject: [PATCH] Add source to PlayerExpChangeEvent
diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
index 23d5b7cb1a5cbe3409a0741af08b2fac8d1a58c1..604bdc5ab98071db88ac3e93ebf11869cc60a308 100644
--- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java
+++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
@@ -188,7 +188,7 @@ public class EntityExperienceOrb extends Entity {
}
if (this.value > 0) {
- entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object
}
this.die();
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index e6420b1d59c8db78e3ad313c6709f64664e5aced..d423313fd949ff1adf3f6d9c5f339a465e0f0b9e 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -123,6 +123,7 @@ import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Vehicle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession;
+import org.bukkit.entity.ExperienceOrb; // Paper
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Result;
@@ -1043,6 +1044,17 @@ public class CraftEventFactory {
return event;
}
+ // Paper start - Add orb
+ public static PlayerExpChangeEvent callPlayerExpChangeEvent(EntityHuman entity, EntityExperienceOrb entityOrb) {
+ Player player = (Player) entity.getBukkitEntity();
+ ExperienceOrb source = (ExperienceOrb) entityOrb.getBukkitEntity();
+ int expAmount = source.getExperience();
+ PlayerExpChangeEvent event = new PlayerExpChangeEvent(player, source, expAmount);
+ Bukkit.getPluginManager().callEvent(event);
+ return event;
+ }
+ // Paper end
+
public static boolean handleBlockGrowEvent(World world, BlockPosition pos, IBlockData block) {
return handleBlockGrowEvent(world, pos, block, 3);
}