13
0
geforkt von Mirrors/Paper

PlayerPickupItemEvent#setFlyAtPlayer

Dieser Commit ist enthalten in:
BillyGalbreath 2017-05-07 06:26:09 -05:00
Ursprung b41abcdb68
Commit eb52c5e2f2

Datei anzeigen

@ -198,7 +198,7 @@
} }
return true; return true;
@@ -382,22 +437,62 @@ @@ -382,22 +437,70 @@
} }
if (this.getItem().isEmpty()) { if (this.getItem().isEmpty()) {
@ -219,6 +219,7 @@
+ // CraftBukkit start - fire PlayerPickupItemEvent + // CraftBukkit start - fire PlayerPickupItemEvent
+ int canHold = player.getInventory().canHold(itemstack); + int canHold = player.getInventory().canHold(itemstack);
+ int remaining = i - canHold; + int remaining = i - canHold;
+ boolean flyAtPlayer = false; // Paper
+ +
+ if (this.pickupDelay <= 0 && canHold > 0) { + if (this.pickupDelay <= 0 && canHold > 0) {
+ itemstack.setCount(canHold); + itemstack.setCount(canHold);
@ -226,8 +227,14 @@
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining); + PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems()); + playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
+ this.level().getCraftServer().getPluginManager().callEvent(playerEvent); + this.level().getCraftServer().getPluginManager().callEvent(playerEvent);
+ flyAtPlayer = playerEvent.getFlyAtPlayer(); // Paper
+ if (playerEvent.isCancelled()) { + if (playerEvent.isCancelled()) {
+ itemstack.setCount(i); // SPIGOT-5294 - restore count + itemstack.setCount(i); // SPIGOT-5294 - restore count
+ // Paper start
+ if (flyAtPlayer) {
+ player.take(this, i);
+ }
+ // Paper end
+ return; + return;
+ } + }
@ -257,6 +264,7 @@
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(player.getUUID())) && player.getInventory().add(itemstack)) { if (this.pickupDelay == 0 && (this.target == null || this.target.equals(player.getUUID())) && player.getInventory().add(itemstack)) {
+ if (flyAtPlayer) // Paper - PlayerPickupItemEvent
player.take(this, i); player.take(this, i);
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
- this.discard(); - this.discard();
@ -264,7 +272,7 @@
itemstack.setCount(i); itemstack.setCount(i);
} }
@@ -492,7 +587,7 @@ @@ -492,7 +595,7 @@
public void makeFakeItem() { public void makeFakeItem() {
this.setNeverPickUp(); this.setNeverPickUp();