SPIGOT-2242: Handle changed item in PlayerPickupArrowEvent

This commit is contained in:
md_5 2016-12-10 12:48:56 +11:00
parent aa257534dc
commit 7e02867f09

View File

@ -46,15 +46,14 @@
}
if (entity.damageEntity(damagesource, (float) i)) {
@@ -422,6 +436,20 @@
@@ -422,9 +436,22 @@
public void d(EntityHuman entityhuman) {
if (!this.world.isClientSide && this.inGround && this.shake <= 0) {
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(Items.ARROW);
+ ItemStack itemstack = this.j(); // PAIL: rename
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), (org.bukkit.entity.Arrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.world.getServer().getPluginManager().callEvent(event);
@ -63,11 +62,15 @@
+ return;
+ }
+ }
+ // CraftBukkit end
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild;
if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
@@ -493,7 +521,14 @@
- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(this.j())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) {
+ // CraftBukkit end
flag = false;
}
@@ -493,7 +520,14 @@
}
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, entityliving) > 0) {