Use Item from PlayerPickupItemEvent when fired (fixes #1717)

This commit is contained in:
Shane Freeder 2018-11-30 15:11:33 +00:00
parent bb7d367269
commit 9a85c96402
2 changed files with 19 additions and 16 deletions

View File

@ -7,28 +7,28 @@ Mojang was sleeping even if we had no more requests to go after
the current one finished, resulting in 100ms lost per profile lookup the current one finished, resulting in 100ms lost per profile lookup
diff --git a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java diff --git a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
index 26a743722..6ed3199c3 100644 index 71e48e87b..23f1447cf 100644
--- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java --- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
+++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java
@@ -0,0 +0,0 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository { @@ -0,0 +0,0 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository {
} }
final int page = 0; final int page = 0;
+ boolean hasRequested = false; // Paper + boolean hasRequested = false; // Paper
for (final List<String> request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) { for (final List<String> request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) {
int failCount = 0; int failCount = 0;
@@ -0,0 +0,0 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository { @@ -0,0 +0,0 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository {
LOGGER.debug("Couldn't find profile {}", name); LOGGER.debug("Couldn't find profile {}", name);
callback.onProfileLookupFailed(new GameProfile(null, name), new ProfileNotFoundException("Server did not find the requested profile")); callback.onProfileLookupFailed(new GameProfile(null, name), new ProfileNotFoundException("Server did not find the requested profile"));
} }
+ // Paper start + // Paper start
+ if (!hasRequested) { + if (!hasRequested) {
+ hasRequested = true; + hasRequested = true;
+ continue; + continue;
+ } + }
+ // Paper end + // Paper end
try { try {
Thread.sleep(DELAY_BETWEEN_PAGES); Thread.sleep(DELAY_BETWEEN_PAGES);
-- --

View File

@ -5,17 +5,20 @@ Subject: [PATCH] Fix #1420
diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java
index 7ac07ac07ac0..7ac07ac07ac0 100644 index 66e574bd3..a72d3dcc6 100644
--- a/src/main/java/net/minecraft/server/EntityArrow.java --- a/src/main/java/net/minecraft/server/EntityArrow.java
+++ b/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile { @@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) { if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) {
// CraftBukkit start // CraftBukkit start
ItemStack itemstack = this.getItemStack(); ItemStack itemstack = this.getItemStack();
- EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
+ EntityItem item = null; // Paper - GH-1420 - allow using event item
+ if (!itemstack.isEmpty()) { // Paper - GH-1420 (skip pick up event for fully damaged (or air) itemstack) + if (!itemstack.isEmpty()) { // Paper - GH-1420 (skip pick up event for fully damaged (or air) itemstack)
EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); + item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack); // Paper - GH-1420 - allow using event item
if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) { if (this.fromPlayer == PickupStatus.ALLOWED && entityhuman.inventory.canHold(itemstack) > 0) {
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()); 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
@@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile { @@ -0,0 +0,0 @@ public abstract class EntityArrow extends Entity implements IProjectile {
return; return;
} }
@ -24,7 +27,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID(); boolean flag = this.fromPlayer == EntityArrow.PickupStatus.ALLOWED || this.fromPlayer == EntityArrow.PickupStatus.CREATIVE_ONLY && entityhuman.abilities.canInstantlyBuild || this.q() && this.getShooter().getUniqueID() == entityhuman.getUniqueID();
- if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) { - if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item.getItemStack())) {
+ if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(itemstack)) { // Paper - GH-1420 + if (this.fromPlayer == EntityArrow.PickupStatus.ALLOWED && !entityhuman.inventory.pickup(item != null ? item.getItemStack() : itemstack)) { // Paper - GH-1420
// CraftBukkit end // CraftBukkit end
flag = false; flag = false;
} }