Add source to PlayerExpChangeEvent

This commit is contained in:
AlphaBlend 2016-09-08 08:48:33 -07:00
parent 76de1e898e
commit 087a701e69
2 changed files with 12 additions and 1 deletions

View File

@ -84,7 +84,7 @@
if (i > 0) {
- player.giveExperiencePoints(i);
+ player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, i).getAmount()); // CraftBukkit - this.value -> event.getAmount()
+ player.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(player, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object
}
--this.count;

View File

@ -1168,6 +1168,17 @@ public class CraftEventFactory {
return event;
}
// Paper start - Add orb
public static PlayerExpChangeEvent callPlayerExpChangeEvent(net.minecraft.world.entity.player.Player entity, net.minecraft.world.entity.ExperienceOrb 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(Level world, BlockPos pos, net.minecraft.world.level.block.state.BlockState block) {
return CraftEventFactory.handleBlockGrowEvent(world, pos, block, 3);
}