From 7d25c57f43182a73959074e5b8eb61481b41dcdb Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Fri, 30 Nov 2018 15:11:33 +0000 Subject: [PATCH] Use Item from PlayerPickupItemEvent when fired (fixes #1717) --- Spigot-Server-Patches/0353-Fix-1420.patch | 17 ++++++----- ...-after-profile-lookups-if-not-needed.patch | 28 +++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Spigot-Server-Patches/0353-Fix-1420.patch b/Spigot-Server-Patches/0353-Fix-1420.patch index 235c276183..f2bd377aee 100644 --- a/Spigot-Server-Patches/0353-Fix-1420.patch +++ b/Spigot-Server-Patches/0353-Fix-1420.patch @@ -1,22 +1,25 @@ -From 7ac07ac07ac07ac07ac07ac07ac07ac07ac07ac0 Mon Sep 17 00:00:00 2001 +From 5f33e6c078a1af6a8a61615eda853205adf22009 Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Fri, 7 Sep 2018 18:28:24 -0500 Subject: [PATCH] Fix #1420 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 +++ b/src/main/java/net/minecraft/server/EntityArrow.java -@@ -492,6 +492,7 @@ public abstract class EntityArrow extends Entity implements IProjectile { +@@ -492,7 +492,9 @@ public abstract class EntityArrow extends Entity implements IProjectile { if (!this.world.isClientSide && (this.inGround || this.q()) && this.shake <= 0) { // CraftBukkit start 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) - 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) { 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()); -@@ -502,9 +503,10 @@ public abstract class EntityArrow extends Entity implements IProjectile { + // event.setCancelled(!entityhuman.canPickUpLoot); TODO +@@ -502,9 +504,10 @@ public abstract class EntityArrow extends Entity implements IProjectile { return; } } @@ -24,10 +27,10 @@ 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(); - 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 flag = false; } -- -2.19.1 +2.19.2 diff --git a/Spigot-Server-Patches/0399-Don-t-sleep-after-profile-lookups-if-not-needed.patch b/Spigot-Server-Patches/0399-Don-t-sleep-after-profile-lookups-if-not-needed.patch index f532c1e4fe..4ddaa229b6 100644 --- a/Spigot-Server-Patches/0399-Don-t-sleep-after-profile-lookups-if-not-needed.patch +++ b/Spigot-Server-Patches/0399-Don-t-sleep-after-profile-lookups-if-not-needed.patch @@ -1,4 +1,4 @@ -From d0a3de41338e9f77091303e911211ba09411900d Mon Sep 17 00:00:00 2001 +From 202d3b30d84fa38f2d97a0f8854ebd947826baad Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 23 Oct 2018 20:25:05 -0400 Subject: [PATCH] Don't sleep after profile lookups if not needed @@ -7,30 +7,30 @@ Mojang was sleeping even if we had no more requests to go after 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 -index 26a743722..6ed3199c3 100644 +index 71e48e87b..23f1447cf 100644 --- a/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/src/main/java/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java @@ -42,6 +42,7 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository { - } - - final int page = 0; + } + + final int page = 0; + boolean hasRequested = false; // Paper - - for (final List request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) { - int failCount = 0; + + for (final List request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) { + int failCount = 0; @@ -67,6 +68,12 @@ public class YggdrasilGameProfileRepository implements GameProfileRepository { - LOGGER.debug("Couldn't find profile {}", name); - callback.onProfileLookupFailed(new GameProfile(null, name), new ProfileNotFoundException("Server did not find the requested profile")); - } + LOGGER.debug("Couldn't find profile {}", name); + callback.onProfileLookupFailed(new GameProfile(null, name), new ProfileNotFoundException("Server did not find the requested profile")); + } + // Paper start + if (!hasRequested) { + hasRequested = true; + continue; + } + // Paper end - - try { - Thread.sleep(DELAY_BETWEEN_PAGES); + + try { + Thread.sleep(DELAY_BETWEEN_PAGES); -- 2.19.2