From 799f6af3570033e478698596c938389f20cb416e Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Sat, 27 Apr 2019 19:23:53 -0400
Subject: [PATCH] More patches for 1.14

Chunk related stuff will need to be revisted later
---
 .../0144-Fix-block-break-desync.patch         |   6 +-
 ... 0161-Shoulder-Entities-Release-API.patch} |  53 ++++-----
 ...patch => 0162-Profile-Lookup-Events.patch} |   4 +-
 ...layer-logins-during-server-shutdown.patch} |   8 +-
 ...patch => 0164-Entity-fromMobSpawner.patch} |  22 ++--
 ...5-Improve-the-Saddle-API-for-Horses.patch} |   8 +-
 ...plement-ensureServerConversions-API.patch} |   6 +-
 ...> 0167-Implement-getI18NDisplayName.patch} |   8 +-
 ...=> 0168-ProfileWhitelistVerifyEvent.patch} |  14 +--
 ...ch => 0169-Fix-this-stupid-bullshit.patch} |   8 +-
 ...awns-should-honor-nametags-and-leash.patch |  22 ++++
 ...mer-when-spawner-event-is-cancelled.patch} |  10 +-
 ...2-Fix-MC-117075-TE-Unload-Lag-Spike.patch} |   8 +-
 ...a-custom-authentication-servers-dow.patch} |  12 +-
 ...atch => 0174-LivingEntity-setKiller.patch} |   6 +-
 ...ms-to-redirect-System.out-err-to-lo.patch} |   8 +-
 ...-prefixes-using-Log4J-configuration.patch} |   8 +-
 ...Include-Log4J2-SLF4J-implementation.patch} |   4 +-
 ...efix-for-various-plugins-bypassing-.patch} |   4 +-
 ...t.patch => 0179-Add-PlayerJumpEvent.patch} |  24 +---
 ...-handle-PacketPlayInKeepAlive-async.patch} |  12 +-
 ...t-protocol-version-and-virtual-host.patch} |  20 ++--
 ...t-serverside-behavior-of-keepalives.patch} |  33 +++---
 ...ith-fastutil-s-ObjectOpenHashSet-in.patch} |   4 +-
 ...Effects-only-to-players-who-can-see.patch} |  56 +++++----
 ...maximum-exp-value-when-merging-orbs.patch} |  10 +-
 ... => 0186-Add-PlayerArmorChangeEvent.patch} |  12 +-
 .../0187-Fix-Anvil-Level-sync-to-client.patch |  46 --------
 ...om-being-processed-when-the-player-.patch} |  10 +-
 ...rages-for-getTileEntity-in-order-to-.patch |  28 -----
 ...-implementations-for-captured-block.patch} |   6 +-
 ...get-a-BlockState-without-a-snapshot.patch} |  16 +--
 ...patch => 0190-AsyncTabCompleteEvent.patch} |  20 ++--
 ...91-Avoid-NPE-in-PathfinderGoalTempt.patch} |   6 +-
 ...aving-disabled-before-unloading-all-.patch |  26 ----
 ...=> 0192-PlayerPickupExperienceEvent.patch} |  18 +--
 ...tch => 0193-ExperienceOrbMergeEvent.patch} |   6 +-
 ...-Ability-to-apply-mending-to-XP-API.patch} |  26 ++--
 ...max-squid-spawn-height-configurable.patch} |  24 ++--
 ...awns-should-honor-nametags-and-leash.patch |  22 ----
 ...urable-Chunks-Sends-per-Tick-setting.patch |  43 -------
 ...Configurable-Max-Chunk-Gens-per-Tick.patch | 111 ------------------
 42 files changed, 264 insertions(+), 534 deletions(-)
 rename Spigot-Server-Patches/{0183-Shoulder-Entities-Release-API.patch => 0161-Shoulder-Entities-Release-API.patch} (66%)
 rename Spigot-Server-Patches/{0184-Profile-Lookup-Events.patch => 0162-Profile-Lookup-Events.patch} (97%)
 rename Spigot-Server-Patches/{0185-Block-player-logins-during-server-shutdown.patch => 0163-Block-player-logins-during-server-shutdown.patch} (86%)
 rename Spigot-Server-Patches/{0186-Entity-fromMobSpawner.patch => 0164-Entity-fromMobSpawner.patch} (77%)
 rename Spigot-Server-Patches/{0189-Improve-the-Saddle-API-for-Horses.patch => 0165-Improve-the-Saddle-API-for-Horses.patch} (94%)
 rename Spigot-Server-Patches/{0190-Implement-ensureServerConversions-API.patch => 0166-Implement-ensureServerConversions-API.patch} (85%)
 rename Spigot-Server-Patches/{0191-Implement-getI18NDisplayName.patch => 0167-Implement-getI18NDisplayName.patch} (90%)
 rename Spigot-Server-Patches/{0193-ProfileWhitelistVerifyEvent.patch => 0168-ProfileWhitelistVerifyEvent.patch} (85%)
 rename Spigot-Server-Patches/{0194-Fix-this-stupid-bullshit.patch => 0169-Fix-this-stupid-bullshit.patch} (88%)
 create mode 100644 Spigot-Server-Patches/0170-Ocelot-despawns-should-honor-nametags-and-leash.patch
 rename Spigot-Server-Patches/{0196-Reset-spawner-timer-when-spawner-event-is-cancelled.patch => 0171-Reset-spawner-timer-when-spawner-event-is-cancelled.patch} (78%)
 rename Spigot-Server-Patches/{0197-Fix-MC-117075-TE-Unload-Lag-Spike.patch => 0172-Fix-MC-117075-TE-Unload-Lag-Spike.patch} (79%)
 rename Spigot-Server-Patches/{0198-Allow-specifying-a-custom-authentication-servers-dow.patch => 0173-Allow-specifying-a-custom-authentication-servers-dow.patch} (84%)
 rename Spigot-Server-Patches/{0199-LivingEntity-setKiller.patch => 0174-LivingEntity-setKiller.patch} (87%)
 rename Spigot-Server-Patches/{0200-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch => 0175-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch} (90%)
 rename Spigot-Server-Patches/{0201-Handle-plugin-prefixes-using-Log4J-configuration.patch => 0176-Handle-plugin-prefixes-using-Log4J-configuration.patch} (95%)
 rename Spigot-Server-Patches/{0202-Include-Log4J2-SLF4J-implementation.patch => 0177-Include-Log4J2-SLF4J-implementation.patch} (87%)
 rename Spigot-Server-Patches/{0203-Disable-logger-prefix-for-various-plugins-bypassing-.patch => 0178-Disable-logger-prefix-for-various-plugins-bypassing-.patch} (95%)
 rename Spigot-Server-Patches/{0204-Add-PlayerJumpEvent.patch => 0179-Add-PlayerJumpEvent.patch} (77%)
 rename Spigot-Server-Patches/{0205-handle-PacketPlayInKeepAlive-async.patch => 0180-handle-PacketPlayInKeepAlive-async.patch} (85%)
 rename Spigot-Server-Patches/{0206-Expose-client-protocol-version-and-virtual-host.patch => 0181-Expose-client-protocol-version-and-virtual-host.patch} (91%)
 rename Spigot-Server-Patches/{0207-revert-serverside-behavior-of-keepalives.patch => 0182-revert-serverside-behavior-of-keepalives.patch} (87%)
 rename Spigot-Server-Patches/{0208-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch => 0183-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch} (92%)
 rename Spigot-Server-Patches/{0209-Send-attack-SoundEffects-only-to-players-who-can-see.patch => 0184-Send-attack-SoundEffects-only-to-players-who-can-see.patch} (71%)
 rename Spigot-Server-Patches/{0210-Option-for-maximum-exp-value-when-merging-orbs.patch => 0185-Option-for-maximum-exp-value-when-merging-orbs.patch} (92%)
 rename Spigot-Server-Patches/{0211-Add-PlayerArmorChangeEvent.patch => 0186-Add-PlayerArmorChangeEvent.patch} (82%)
 delete mode 100644 Spigot-Server-Patches/0187-Fix-Anvil-Level-sync-to-client.patch
 rename Spigot-Server-Patches/{0212-Prevent-logins-from-being-processed-when-the-player-.patch => 0187-Prevent-logins-from-being-processed-when-the-player-.patch} (84%)
 delete mode 100644 Spigot-Server-Patches/0188-Add-missing-coverages-for-getTileEntity-in-order-to-.patch
 rename Spigot-Server-Patches/{0213-use-CB-BlockState-implementations-for-captured-block.patch => 0188-use-CB-BlockState-implementations-for-captured-block.patch} (89%)
 rename Spigot-Server-Patches/{0214-API-to-get-a-BlockState-without-a-snapshot.patch => 0189-API-to-get-a-BlockState-without-a-snapshot.patch} (92%)
 rename Spigot-Server-Patches/{0215-AsyncTabCompleteEvent.patch => 0190-AsyncTabCompleteEvent.patch} (92%)
 rename Spigot-Server-Patches/{0216-Avoid-NPE-in-PathfinderGoalTempt.patch => 0191-Avoid-NPE-in-PathfinderGoalTempt.patch} (82%)
 delete mode 100644 Spigot-Server-Patches/0192-GH-806-Respect-saving-disabled-before-unloading-all-.patch
 rename Spigot-Server-Patches/{0217-PlayerPickupExperienceEvent.patch => 0192-PlayerPickupExperienceEvent.patch} (59%)
 rename Spigot-Server-Patches/{0218-ExperienceOrbMergeEvent.patch => 0193-ExperienceOrbMergeEvent.patch} (90%)
 rename Spigot-Server-Patches/{0219-Ability-to-apply-mending-to-XP-API.patch => 0194-Ability-to-apply-mending-to-XP-API.patch} (79%)
 rename Spigot-Server-Patches/{0222-Make-max-squid-spawn-height-configurable.patch => 0195-Make-max-squid-spawn-height-configurable.patch} (68%)
 delete mode 100644 Spigot-Server-Patches/0195-Ocelot-despawns-should-honor-nametags-and-leash.patch
 delete mode 100644 Spigot-Server-Patches/0220-Configurable-Chunks-Sends-per-Tick-setting.patch
 delete mode 100644 Spigot-Server-Patches/0221-Configurable-Max-Chunk-Gens-per-Tick.patch

diff --git a/Spigot-Server-Patches/0144-Fix-block-break-desync.patch b/Spigot-Server-Patches/0144-Fix-block-break-desync.patch
index bbd50e2c11..7ad09bd3e3 100644
--- a/Spigot-Server-Patches/0144-Fix-block-break-desync.patch
+++ b/Spigot-Server-Patches/0144-Fix-block-break-desync.patch
@@ -1,18 +1,18 @@
-From ac742bd2ace2f239eefa33afb4f7cced59f3680e Mon Sep 17 00:00:00 2001
+From d4cdb325da7cbe6154860e78f0bbec61ecea6c14 Mon Sep 17 00:00:00 2001
 From: Michael Himing <mhiming@gmail.com>
 Date: Sun, 8 Jan 2017 18:50:35 +1100
 Subject: [PATCH] Fix block break desync
 
 
 diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index 6874563e4..37caa2a70 100644
+index 6874563e4..868d0e98b 100644
 --- a/src/main/java/net/minecraft/server/PlayerConnection.java
 +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
 @@ -1176,6 +1176,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
              double d3 = d0 * d0 + d1 * d1 + d2 * d2;
  
              if (d3 > 36.0D) {
-+                if (worldserver.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4, true)) // Paper - Fix block break desync - Don't send for unloaded chunks
++                if (worldserver.isChunkLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4)) // Paper - Fix block break desync - Don't send for unloaded chunks
 +                    this.sendPacket(new PacketPlayOutBlockChange(worldserver, blockposition)); // Paper - Fix block break desync
                  return;
              } else if (blockposition.getY() >= this.minecraftServer.getMaxBuildHeight()) {
diff --git a/Spigot-Server-Patches/0183-Shoulder-Entities-Release-API.patch b/Spigot-Server-Patches/0161-Shoulder-Entities-Release-API.patch
similarity index 66%
rename from Spigot-Server-Patches/0183-Shoulder-Entities-Release-API.patch
rename to Spigot-Server-Patches/0161-Shoulder-Entities-Release-API.patch
index 6eb22a93be..2bdca09b27 100644
--- a/Spigot-Server-Patches/0183-Shoulder-Entities-Release-API.patch
+++ b/Spigot-Server-Patches/0161-Shoulder-Entities-Release-API.patch
@@ -1,17 +1,17 @@
-From 8b06af0c55201686c142c01024a4fa994b130307 Mon Sep 17 00:00:00 2001
+From 7b2008881f05671eedc216afd33c945de5eb313b Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Sat, 17 Jun 2017 15:18:30 -0400
 Subject: [PATCH] Shoulder Entities Release API
 
 
 diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
-index 23e7cdfe88..298012f37c 100644
+index 5df763d92..0f8100a05 100644
 --- a/src/main/java/net/minecraft/server/EntityHuman.java
 +++ b/src/main/java/net/minecraft/server/EntityHuman.java
-@@ -1831,21 +1831,48 @@ public abstract class EntityHuman extends EntityLiving {
-         }
+@@ -1781,20 +1781,45 @@ public abstract class EntityHuman extends EntityLiving {
          // CraftBukkit end
      }
+ 
 +    // Paper start
 +    public Entity releaseLeftShoulderEntity() {
 +        Entity entity = this.spawnEntityFromShoulder0(this.getShoulderEntityLeft());
@@ -20,9 +20,7 @@ index 23e7cdfe88..298012f37c 100644
 +        }
 +        return entity;
 +    }
- 
--    private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
--        if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
++
 +    public Entity releaseRightShoulderEntity() {
 +        Entity entity = this.spawnEntityFromShoulder0(this.getShoulderEntityRight());
 +        if (entity != null) {
@@ -31,41 +29,40 @@ index 23e7cdfe88..298012f37c 100644
 +        return entity;
 +    }
 +
-+    // Paper - incase any plugins used NMS to call this... old method signature to avoid other diff
-+    private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) {
++    // Paper - maintain old signature
+     private boolean spawnEntityFromShoulder(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
+-        if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
 +        return spawnEntityFromShoulder0(nbttagcompound) != null;
 +    }
-+    // Paper - Moved to new method that now returns entity, and properly null checks
-+    private Entity spawnEntityFromShoulder0(@Nullable NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean - Paper - return Entity
-+        if (!this.world.isClientSide && nbttagcompound != null && !nbttagcompound.isEmpty()) { // Paper - null check
-             Entity entity = EntityTypes.a(nbttagcompound, this.world);
-+            if (entity == null) { // Paper - null check
-+                return null;
-+            }
++
++    // Paper - return entity
++    private Entity spawnEntityFromShoulder0(@Nullable NBTTagCompound nbttagcompound) {
++        if (!this.world.isClientSide && nbttagcompound != null && !nbttagcompound.isEmpty()) {
+             return EntityTypes.a(nbttagcompound, this.world).map((entity) -> { // CraftBukkit
+                 if (entity instanceof EntityTameableAnimal) {
+                     ((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID);
+                 }
  
-             if (entity instanceof EntityTameableAnimal) {
-                 ((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID);
-             }
- 
-             entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
--            return this.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
-+            if (this.world.addEntity(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY)) { // CraftBukkit
-+                return entity;
-+            }
+                 entity.setPosition(this.locX, this.locY + 0.699999988079071D, this.locZ);
+-                return ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+-            }).orElse(true); // CraftBukkit
++                boolean addedToWorld = ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
++                return addedToWorld ? entity : null;
++            }).orElse(null); // CraftBukkit // Paper - false -> null
          }
  
 -        return true; // CraftBukkit
-+        return null;
++        return null; // Paper - return null
      }
 +    // Paper end
  
      public abstract boolean isSpectator();
  
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-index 79d1255676..d5dbc4ca81 100644
+index a7b495c7a..c2b6e792a 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
-@@ -556,6 +556,32 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+@@ -610,6 +610,32 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
          getHandle().getCooldownTracker().a(CraftMagicNumbers.getItem(material), ticks);
      }
  
diff --git a/Spigot-Server-Patches/0184-Profile-Lookup-Events.patch b/Spigot-Server-Patches/0162-Profile-Lookup-Events.patch
similarity index 97%
rename from Spigot-Server-Patches/0184-Profile-Lookup-Events.patch
rename to Spigot-Server-Patches/0162-Profile-Lookup-Events.patch
index 25655ace8e..b4bd7f85d2 100644
--- a/Spigot-Server-Patches/0184-Profile-Lookup-Events.patch
+++ b/Spigot-Server-Patches/0162-Profile-Lookup-Events.patch
@@ -1,4 +1,4 @@
-From 62fe5662571b58921aed09ccdc85810a5e2061b6 Mon Sep 17 00:00:00 2001
+From bc9cdd4a213d9542dd238b6a697aa19183b607b5 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Sat, 17 Jun 2017 17:00:32 -0400
 Subject: [PATCH] Profile Lookup Events
@@ -7,7 +7,7 @@ Adds a Pre Lookup Event and a Post Lookup Event so that plugins may prefill in p
 profiles that had to be looked up.
 
 diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java
-index 3bcdb8f93f..bb9894318e 100644
+index 3bcdb8f93..bb9894318 100644
 --- a/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java
 +++ b/src/main/java/com/destroystokyo/paper/profile/PaperGameProfileRepository.java
 @@ -1,17 +1,68 @@
diff --git a/Spigot-Server-Patches/0185-Block-player-logins-during-server-shutdown.patch b/Spigot-Server-Patches/0163-Block-player-logins-during-server-shutdown.patch
similarity index 86%
rename from Spigot-Server-Patches/0185-Block-player-logins-during-server-shutdown.patch
rename to Spigot-Server-Patches/0163-Block-player-logins-during-server-shutdown.patch
index f91308ab9e..6eeefdd34f 100644
--- a/Spigot-Server-Patches/0185-Block-player-logins-during-server-shutdown.patch
+++ b/Spigot-Server-Patches/0163-Block-player-logins-during-server-shutdown.patch
@@ -1,14 +1,14 @@
-From ed322683af055029de337dbc60c07d8cf30e86b1 Mon Sep 17 00:00:00 2001
+From 1c3408f1b9315a7932749a79efb2890814994c4e Mon Sep 17 00:00:00 2001
 From: Zach Brown <zach.brown@destroystokyo.com>
 Date: Sun, 2 Jul 2017 21:35:56 -0500
 Subject: [PATCH] Block player logins during server shutdown
 
 
 diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
-index e901c066ac..852dc7162a 100644
+index 22d5c7d20..91b6f1de8 100644
 --- a/src/main/java/net/minecraft/server/LoginListener.java
 +++ b/src/main/java/net/minecraft/server/LoginListener.java
-@@ -49,6 +49,12 @@ public class LoginListener implements PacketLoginInListener, ITickable {
+@@ -49,6 +49,12 @@ public class LoginListener implements PacketLoginInListener {
      }
  
      public void tick() {
@@ -19,7 +19,7 @@ index e901c066ac..852dc7162a 100644
 +        }
 +        // Paper end
          if (this.g == LoginListener.EnumProtocolState.READY_TO_ACCEPT) {
-             this.b();
+             this.c();
          } else if (this.g == LoginListener.EnumProtocolState.DELAY_ACCEPT) {
 -- 
 2.21.0
diff --git a/Spigot-Server-Patches/0186-Entity-fromMobSpawner.patch b/Spigot-Server-Patches/0164-Entity-fromMobSpawner.patch
similarity index 77%
rename from Spigot-Server-Patches/0186-Entity-fromMobSpawner.patch
rename to Spigot-Server-Patches/0164-Entity-fromMobSpawner.patch
index 65ec23e08e..e1b790b755 100644
--- a/Spigot-Server-Patches/0186-Entity-fromMobSpawner.patch
+++ b/Spigot-Server-Patches/0164-Entity-fromMobSpawner.patch
@@ -1,14 +1,14 @@
-From 8ca9f8cb42942c15263e253d5c42e16b379285f3 Mon Sep 17 00:00:00 2001
+From f58c0fe41a80304f921ac5c534d2227aba155c0b Mon Sep 17 00:00:00 2001
 From: BillyGalbreath <Blake.Galbreath@GMail.com>
 Date: Sun, 18 Jun 2017 18:17:05 -0500
 Subject: [PATCH] Entity#fromMobSpawner()
 
 
 diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
-index 291a304172..92a15ba947 100644
+index ee7fe30c7..c28b498a2 100644
 --- a/src/main/java/net/minecraft/server/Entity.java
 +++ b/src/main/java/net/minecraft/server/Entity.java
-@@ -182,6 +182,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -181,6 +181,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
      public final boolean defaultActivationState;
      public long activatedTick = Integer.MIN_VALUE;
      public boolean fromMobSpawner;
@@ -16,7 +16,7 @@ index 291a304172..92a15ba947 100644
      protected int numCollisions = 0; // Paper
      public void inactiveTick() { }
      // Spigot end
-@@ -1667,6 +1668,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1573,6 +1574,10 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
              if (origin != null) {
                  nbttagcompound.set("Paper.Origin", this.createList(origin.getX(), origin.getY(), origin.getZ()));
              }
@@ -27,7 +27,7 @@ index 291a304172..92a15ba947 100644
              // Paper end
              return nbttagcompound;
          } catch (Throwable throwable) {
-@@ -1814,6 +1819,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
+@@ -1700,6 +1705,8 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
              if (!originTag.isEmpty()) {
                  origin = new Location(world.getWorld(), originTag.getDoubleAt(0), originTag.getDoubleAt(1), originTag.getDoubleAt(2));
              }
@@ -37,22 +37,22 @@ index 291a304172..92a15ba947 100644
  
          } catch (Throwable throwable) {
 diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
-index ce43b4bc52..98065d6b02 100644
+index 6499d27e6..2b2af2daa 100644
 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
 +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
-@@ -115,6 +115,7 @@ public abstract class MobSpawnerAbstract {
-                         if (this.spawnData.b().d() == 1 && this.spawnData.b().hasKeyOfType("id", 8) && entity instanceof EntityInsentient) {
-                             ((EntityInsentient) entity).prepare(world.getDamageScaler(new BlockPosition(entity)), (GroupDataEntity) null, (NBTTagCompound) null);
+@@ -133,6 +133,7 @@ public abstract class MobSpawnerAbstract {
+                                 ((EntityInsentient) entity).prepare(world, world.getDamageScaler(new BlockPosition(entity)), EnumMobSpawn.SPAWNER, (GroupDataEntity) null, (NBTTagCompound) null);
+                             }
                          }
 +                        entity.spawnedViaMobSpawner = true; // Paper
                          // Spigot Start
                          if ( entity.world.spigotConfig.nerfSpawnerMobs )
                          {
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
-index 466750f779..84a58c7dcd 100644
+index 5d9b4a58e..e0ae72bbc 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
-@@ -855,5 +855,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
+@@ -983,5 +983,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
          Location origin = getHandle().origin;
          return origin == null ? null : origin.clone();
      }
diff --git a/Spigot-Server-Patches/0189-Improve-the-Saddle-API-for-Horses.patch b/Spigot-Server-Patches/0165-Improve-the-Saddle-API-for-Horses.patch
similarity index 94%
rename from Spigot-Server-Patches/0189-Improve-the-Saddle-API-for-Horses.patch
rename to Spigot-Server-Patches/0165-Improve-the-Saddle-API-for-Horses.patch
index 3e55e08cc2..e407325dec 100644
--- a/Spigot-Server-Patches/0189-Improve-the-Saddle-API-for-Horses.patch
+++ b/Spigot-Server-Patches/0165-Improve-the-Saddle-API-for-Horses.patch
@@ -1,4 +1,4 @@
-From 7b02067570d465d1f87f32920b8f36099008c710 Mon Sep 17 00:00:00 2001
+From 415781dddbe5dae2d4483881168112c89c3fa53e Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Sat, 10 Dec 2016 16:24:06 -0500
 Subject: [PATCH] Improve the Saddle API for Horses
@@ -7,7 +7,7 @@ Not all horses with Saddles have armor. This lets us break up the horses with sa
 and access their saddle state separately from an interface shared with Armor.
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
-index 14d0416802..e56bef3340 100644
+index 14d041680..e56bef334 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
 @@ -6,6 +6,7 @@ import net.minecraft.server.EntityHorseAbstract;
@@ -27,7 +27,7 @@ index 14d0416802..e56bef3340 100644
      }
  }
 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
-index 173818e682..2f68524049 100644
+index 173818e68..2f6852404 100644
 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventoryHorse.java
 @@ -4,7 +4,7 @@ import net.minecraft.server.IInventory;
@@ -41,7 +41,7 @@ index 173818e682..2f68524049 100644
          super(inventory);
 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java
 new file mode 100644
-index 0000000000..99cfbaf90b
+index 000000000..99cfbaf90
 --- /dev/null
 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSaddledInventory.java
 @@ -0,0 +1,15 @@
diff --git a/Spigot-Server-Patches/0190-Implement-ensureServerConversions-API.patch b/Spigot-Server-Patches/0166-Implement-ensureServerConversions-API.patch
similarity index 85%
rename from Spigot-Server-Patches/0190-Implement-ensureServerConversions-API.patch
rename to Spigot-Server-Patches/0166-Implement-ensureServerConversions-API.patch
index ddd53838b2..d70882681c 100644
--- a/Spigot-Server-Patches/0190-Implement-ensureServerConversions-API.patch
+++ b/Spigot-Server-Patches/0166-Implement-ensureServerConversions-API.patch
@@ -1,4 +1,4 @@
-From 70223002377dc229edfeaf45d328d3f17ee4fbf1 Mon Sep 17 00:00:00 2001
+From f11ee1d20bd3ca71dee58b437a3dc79141d421a1 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Wed, 4 May 2016 22:43:12 -0400
 Subject: [PATCH] Implement ensureServerConversions API
@@ -7,10 +7,10 @@ This will take a Bukkit ItemStack and run it through any conversions a server pr
 to ensure it meets latest minecraft expectations.
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
-index 52041caedc..f5fa58d6cc 100644
+index f529367c8..2a51fa41a 100644
 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
-@@ -294,4 +294,10 @@ public final class CraftItemFactory implements ItemFactory {
+@@ -312,4 +312,10 @@ public final class CraftItemFactory implements ItemFactory {
      public Material updateMaterial(ItemMeta meta, Material material) throws IllegalArgumentException {
          return ((CraftMetaItem) meta).updateMaterial(material);
      }
diff --git a/Spigot-Server-Patches/0191-Implement-getI18NDisplayName.patch b/Spigot-Server-Patches/0167-Implement-getI18NDisplayName.patch
similarity index 90%
rename from Spigot-Server-Patches/0191-Implement-getI18NDisplayName.patch
rename to Spigot-Server-Patches/0167-Implement-getI18NDisplayName.patch
index c04d505a6c..394a6063d3 100644
--- a/Spigot-Server-Patches/0191-Implement-getI18NDisplayName.patch
+++ b/Spigot-Server-Patches/0167-Implement-getI18NDisplayName.patch
@@ -1,4 +1,4 @@
-From d7ec5666d9d230e0ce0dec15ff7e7d659c75f5dc Mon Sep 17 00:00:00 2001
+From c4add1f5b9e89c011b0efe544cccca56c0ff7bc6 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Wed, 4 May 2016 23:59:38 -0400
 Subject: [PATCH] Implement getI18NDisplayName
@@ -8,7 +8,7 @@ Currently the server only supports the English language. To override this,
 You must replace the language file embedded in the server jar.
 
 diff --git a/src/main/java/net/minecraft/server/LocaleLanguage.java b/src/main/java/net/minecraft/server/LocaleLanguage.java
-index 747b8ad4de..4c5556a096 100644
+index 8fe8e28aa..295c01b28 100644
 --- a/src/main/java/net/minecraft/server/LocaleLanguage.java
 +++ b/src/main/java/net/minecraft/server/LocaleLanguage.java
 @@ -44,10 +44,12 @@ public class LocaleLanguage {
@@ -25,10 +25,10 @@ index 747b8ad4de..4c5556a096 100644
          return this.c(s);
      }
 diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
-index f5fa58d6cc..3a6e6f687d 100644
+index 2a51fa41a..dd02fb95a 100644
 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
-@@ -299,5 +299,18 @@ public final class CraftItemFactory implements ItemFactory {
+@@ -317,5 +317,18 @@ public final class CraftItemFactory implements ItemFactory {
      public ItemStack ensureServerConversions(ItemStack item) {
          return CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(item));
      }
diff --git a/Spigot-Server-Patches/0193-ProfileWhitelistVerifyEvent.patch b/Spigot-Server-Patches/0168-ProfileWhitelistVerifyEvent.patch
similarity index 85%
rename from Spigot-Server-Patches/0193-ProfileWhitelistVerifyEvent.patch
rename to Spigot-Server-Patches/0168-ProfileWhitelistVerifyEvent.patch
index befac7675a..618996a0ad 100644
--- a/Spigot-Server-Patches/0193-ProfileWhitelistVerifyEvent.patch
+++ b/Spigot-Server-Patches/0168-ProfileWhitelistVerifyEvent.patch
@@ -1,14 +1,14 @@
-From 6b5a66b6dc3f5c6a722153e708ef3884d5e8066c Mon Sep 17 00:00:00 2001
+From b35a0e4863b159d80828469756202fc68e18e00f Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Mon, 3 Jul 2017 18:11:10 -0500
 Subject: [PATCH] ProfileWhitelistVerifyEvent
 
 
 diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
-index 8bb3fef21e..96eff10ffa 100644
+index 52b2f4874..b855e7968 100644
 --- a/src/main/java/net/minecraft/server/PlayerList.java
 +++ b/src/main/java/net/minecraft/server/PlayerList.java
-@@ -543,9 +543,9 @@ public abstract class PlayerList {
+@@ -519,9 +519,9 @@ public abstract class PlayerList {
  
              // return chatmessage;
              if (!gameprofilebanentry.hasExpired()) event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage)); // Spigot
@@ -20,7 +20,7 @@ index 8bb3fef21e..96eff10ffa 100644
          } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
              IpBanEntry ipbanentry = this.l.get(socketaddress);
  
-@@ -1171,9 +1171,25 @@ public abstract class PlayerList {
+@@ -889,9 +889,25 @@ public abstract class PlayerList {
          this.server.getCommandDispatcher().a(entityplayer);
      }
  
@@ -28,7 +28,7 @@ index 8bb3fef21e..96eff10ffa 100644
      public boolean isWhitelisted(GameProfile gameprofile) {
 -        return !this.hasWhitelist || this.operators.d(gameprofile) || this.whitelist.d(gameprofile);
 +        return isWhitelisted(gameprofile, null);
-+    }
+     }
 +    public boolean isWhitelisted(GameProfile gameprofile, org.bukkit.event.player.PlayerLoginEvent loginEvent) {
 +        boolean isOp = this.operators.d(gameprofile);
 +        boolean isWhitelisted = !this.hasWhitelist || isOp || this.whitelist.d(gameprofile);
@@ -42,11 +42,11 @@ index 8bb3fef21e..96eff10ffa 100644
 +            return false;
 +        }
 +        return true;
-     }
++    }
 +    // Paper end
  
      public boolean isOp(GameProfile gameprofile) {
-         return this.operators.d(gameprofile) || this.server.H() && this.server.getWorldServer(DimensionManager.OVERWORLD).getWorldData().u() && this.server.G().equalsIgnoreCase(gameprofile.getName()) || this.u;
+         return this.operators.d(gameprofile) || this.server.b(gameprofile) && this.server.getWorldServer(DimensionManager.OVERWORLD).getWorldData().u() || this.u;
 -- 
 2.21.0
 
diff --git a/Spigot-Server-Patches/0194-Fix-this-stupid-bullshit.patch b/Spigot-Server-Patches/0169-Fix-this-stupid-bullshit.patch
similarity index 88%
rename from Spigot-Server-Patches/0194-Fix-this-stupid-bullshit.patch
rename to Spigot-Server-Patches/0169-Fix-this-stupid-bullshit.patch
index a338c9b494..f941a64d57 100644
--- a/Spigot-Server-Patches/0194-Fix-this-stupid-bullshit.patch
+++ b/Spigot-Server-Patches/0169-Fix-this-stupid-bullshit.patch
@@ -1,4 +1,4 @@
-From 55397606a09c8ea5deecea742516e8badfdad445 Mon Sep 17 00:00:00 2001
+From 4b74b8f599e4aab980e2e02073bdb3653cfb5ead Mon Sep 17 00:00:00 2001
 From: DemonWav <demonwav@gmail.com>
 Date: Sun, 6 Aug 2017 17:17:53 -0500
 Subject: [PATCH] Fix this stupid bullshit
@@ -9,12 +9,12 @@ modified in order to prevent merge conflicts when Spigot changes/disables the wa
 and to provide some level of hint without being disruptive.
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
-index 4102e19700..b145b55bc7 100644
+index e3d163ac4..a991cda1f 100644
 --- a/src/main/java/org/bukkit/craftbukkit/Main.java
 +++ b/src/main/java/org/bukkit/craftbukkit/Main.java
-@@ -217,10 +217,12 @@ public class Main {
+@@ -216,10 +216,12 @@ public class Main {
                      Calendar deadline = Calendar.getInstance();
-                     deadline.add(Calendar.DAY_OF_YEAR, -21);
+                     deadline.add(Calendar.DAY_OF_YEAR, -3);
                      if (buildDate.before(deadline.getTime())) {
 -                        System.err.println("*** Error, this build is outdated ***");
 +                        // Paper start - This is some stupid bullshit
diff --git a/Spigot-Server-Patches/0170-Ocelot-despawns-should-honor-nametags-and-leash.patch b/Spigot-Server-Patches/0170-Ocelot-despawns-should-honor-nametags-and-leash.patch
new file mode 100644
index 0000000000..69216b549a
--- /dev/null
+++ b/Spigot-Server-Patches/0170-Ocelot-despawns-should-honor-nametags-and-leash.patch
@@ -0,0 +1,22 @@
+From 3fa0d4dcc51608fefd241573f1184466504f9194 Mon Sep 17 00:00:00 2001
+From: BillyGalbreath <Blake.Galbreath@GMail.com>
+Date: Mon, 31 Jul 2017 01:54:40 -0500
+Subject: [PATCH] Ocelot despawns should honor nametags and leash
+
+
+diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java
+index af1ff9518..1713bead2 100644
+--- a/src/main/java/net/minecraft/server/EntityOcelot.java
++++ b/src/main/java/net/minecraft/server/EntityOcelot.java
+@@ -81,7 +81,7 @@ public class EntityOcelot extends EntityAnimal {
+ 
+     @Override
+     public boolean isTypeNotPersistent(double d0) {
+-        return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit
++        return !this.isTrusting() && !this.hasCustomName() && !this.isLeashed() /*&& this.ticksLived > 2400*/; // CraftBukkit // Paper - honor name and leash
+     }
+ 
+     @Override
+-- 
+2.21.0
+
diff --git a/Spigot-Server-Patches/0196-Reset-spawner-timer-when-spawner-event-is-cancelled.patch b/Spigot-Server-Patches/0171-Reset-spawner-timer-when-spawner-event-is-cancelled.patch
similarity index 78%
rename from Spigot-Server-Patches/0196-Reset-spawner-timer-when-spawner-event-is-cancelled.patch
rename to Spigot-Server-Patches/0171-Reset-spawner-timer-when-spawner-event-is-cancelled.patch
index 11b746d3ad..dafd6bcbc2 100644
--- a/Spigot-Server-Patches/0196-Reset-spawner-timer-when-spawner-event-is-cancelled.patch
+++ b/Spigot-Server-Patches/0171-Reset-spawner-timer-when-spawner-event-is-cancelled.patch
@@ -1,14 +1,14 @@
-From 559b3a1c59758c2ab0ff16debdd5529623c02956 Mon Sep 17 00:00:00 2001
+From 3c650d7970db805f3d67068ad9d1c189c9d6ec42 Mon Sep 17 00:00:00 2001
 From: BillyGalbreath <Blake.Galbreath@GMail.com>
 Date: Mon, 31 Jul 2017 01:45:19 -0500
 Subject: [PATCH] Reset spawner timer when spawner event is cancelled
 
 
 diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
-index 98065d6b02..027ba71918 100644
+index 2b2af2daa..d8ae336e9 100644
 --- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
 +++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
-@@ -121,6 +121,9 @@ public abstract class MobSpawnerAbstract {
+@@ -139,6 +139,9 @@ public abstract class MobSpawnerAbstract {
                          {
                              entity.fromMobSpawner = true;
                          }
@@ -18,8 +18,8 @@ index 98065d6b02..027ba71918 100644
                          if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, blockposition).isCancelled()) {
                              Entity vehicle = entity.getVehicle();
                              if (vehicle != null) {
-@@ -138,7 +141,7 @@ public abstract class MobSpawnerAbstract {
-                             entityinsentient.doSpawnEffect();
+@@ -156,7 +159,7 @@ public abstract class MobSpawnerAbstract {
+                             ((EntityInsentient) entity).doSpawnEffect();
                          }
  
 -                        flag = true;
diff --git a/Spigot-Server-Patches/0197-Fix-MC-117075-TE-Unload-Lag-Spike.patch b/Spigot-Server-Patches/0172-Fix-MC-117075-TE-Unload-Lag-Spike.patch
similarity index 79%
rename from Spigot-Server-Patches/0197-Fix-MC-117075-TE-Unload-Lag-Spike.patch
rename to Spigot-Server-Patches/0172-Fix-MC-117075-TE-Unload-Lag-Spike.patch
index 71453083cd..60c38ca2ca 100644
--- a/Spigot-Server-Patches/0197-Fix-MC-117075-TE-Unload-Lag-Spike.patch
+++ b/Spigot-Server-Patches/0172-Fix-MC-117075-TE-Unload-Lag-Spike.patch
@@ -1,15 +1,15 @@
-From 15cd669dcb33567293742d5942ca735b544822d1 Mon Sep 17 00:00:00 2001
+From b34797104929ce0cfd6143ec47b33616aeafb133 Mon Sep 17 00:00:00 2001
 From: mezz <tehgeek@gmail.com>
 Date: Wed, 9 Aug 2017 17:51:22 -0500
 Subject: [PATCH] Fix MC-117075: TE Unload Lag Spike
 
 
 diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
-index 5e1ab431dc..cdb430ef4f 100644
+index 1286703bf..c9fc001f2 100644
 --- a/src/main/java/net/minecraft/server/World.java
 +++ b/src/main/java/net/minecraft/server/World.java
-@@ -1274,7 +1274,11 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
-         this.methodProfiler.exitEnter("blockEntities");
+@@ -727,7 +727,11 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
+         gameprofilerfiller.enter("blockEntities");
          timings.tileEntityTick.startTiming(); // Spigot
          if (!this.tileEntityListUnload.isEmpty()) {
 -            this.tileEntityListTick.removeAll(this.tileEntityListUnload);
diff --git a/Spigot-Server-Patches/0198-Allow-specifying-a-custom-authentication-servers-dow.patch b/Spigot-Server-Patches/0173-Allow-specifying-a-custom-authentication-servers-dow.patch
similarity index 84%
rename from Spigot-Server-Patches/0198-Allow-specifying-a-custom-authentication-servers-dow.patch
rename to Spigot-Server-Patches/0173-Allow-specifying-a-custom-authentication-servers-dow.patch
index 04850d36ca..2ec2642056 100644
--- a/Spigot-Server-Patches/0198-Allow-specifying-a-custom-authentication-servers-dow.patch
+++ b/Spigot-Server-Patches/0173-Allow-specifying-a-custom-authentication-servers-dow.patch
@@ -1,4 +1,4 @@
-From fee8c1007a09297383dd293f9003f41e347c37c7 Mon Sep 17 00:00:00 2001
+From a862ab264571177d979c514e21eafdb472f1b94b Mon Sep 17 00:00:00 2001
 From: kashike <kashike@vq.lc>
 Date: Thu, 17 Aug 2017 16:08:20 -0700
 Subject: [PATCH] Allow specifying a custom "authentication servers down" kick
@@ -6,7 +6,7 @@ Subject: [PATCH] Allow specifying a custom "authentication servers down" kick
 
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
-index d10d60921b..2b5dde6d99 100644
+index 1adbb2480..a9cf1b8e8 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
 @@ -1,5 +1,6 @@
@@ -16,7 +16,7 @@ index d10d60921b..2b5dde6d99 100644
  import com.google.common.base.Throwables;
  
  import java.io.File;
-@@ -285,4 +286,9 @@ public class PaperConfig {
+@@ -261,4 +262,9 @@ public class PaperConfig {
      private static void suggestPlayersWhenNull() {
          suggestPlayersWhenNullTabCompletions = getBoolean("settings.suggest-player-names-when-null-tab-completions", suggestPlayersWhenNullTabCompletions);
      }
@@ -27,10 +27,10 @@ index d10d60921b..2b5dde6d99 100644
 +    }
  }
 diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
-index 852dc7162a..74bc08f85c 100644
+index 91b6f1de8..398f67f4b 100644
 --- a/src/main/java/net/minecraft/server/LoginListener.java
 +++ b/src/main/java/net/minecraft/server/LoginListener.java
-@@ -239,6 +239,10 @@ public class LoginListener implements PacketLoginInListener, ITickable {
+@@ -242,6 +242,10 @@ public class LoginListener implements PacketLoginInListener {
                              LoginListener.this.i = LoginListener.this.a(gameprofile);
                              LoginListener.this.g = LoginListener.EnumProtocolState.READY_TO_ACCEPT;
                          } else {
@@ -39,7 +39,7 @@ index 852dc7162a..74bc08f85c 100644
 +                                LoginListener.this.disconnect(new ChatComponentText(com.destroystokyo.paper.PaperConfig.authenticationServersDownKickMessage));
 +                            } else // Paper end
                              LoginListener.this.disconnect(new ChatMessage("multiplayer.disconnect.authservers_down", new Object[0]));
-                             LoginListener.c.error("Couldn't verify username because servers are unavailable");
+                             LoginListener.LOGGER.error("Couldn't verify username because servers are unavailable");
                          }
 -- 
 2.21.0
diff --git a/Spigot-Server-Patches/0199-LivingEntity-setKiller.patch b/Spigot-Server-Patches/0174-LivingEntity-setKiller.patch
similarity index 87%
rename from Spigot-Server-Patches/0199-LivingEntity-setKiller.patch
rename to Spigot-Server-Patches/0174-LivingEntity-setKiller.patch
index 394192e7b0..4d28e9887e 100644
--- a/Spigot-Server-Patches/0199-LivingEntity-setKiller.patch
+++ b/Spigot-Server-Patches/0174-LivingEntity-setKiller.patch
@@ -1,14 +1,14 @@
-From 7329a5ba4aec7f44664e5d1580eb7982602dc0ff Mon Sep 17 00:00:00 2001
+From de17608d7017d74e39664f79b7243c5840d6b415 Mon Sep 17 00:00:00 2001
 From: BillyGalbreath <Blake.Galbreath@GMail.com>
 Date: Mon, 31 Jul 2017 01:49:48 -0500
 Subject: [PATCH] LivingEntity#setKiller
 
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-index 716eda9902..2f96842bb9 100644
+index 424b2b708..f95347df0 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
-@@ -278,6 +278,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
+@@ -277,6 +277,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
          return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity();
      }
  
diff --git a/Spigot-Server-Patches/0200-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch b/Spigot-Server-Patches/0175-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch
similarity index 90%
rename from Spigot-Server-Patches/0200-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch
rename to Spigot-Server-Patches/0175-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch
index b28a0a32e0..57e4c14dbe 100644
--- a/Spigot-Server-Patches/0200-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch
+++ b/Spigot-Server-Patches/0175-Use-Log4j-IOStreams-to-redirect-System.out-err-to-lo.patch
@@ -1,4 +1,4 @@
-From 24b3889d4c1ca6119886c22819850d47bf9ce2bd Mon Sep 17 00:00:00 2001
+From 3e140363bc07b0523ddad00c7c75be134d659023 Mon Sep 17 00:00:00 2001
 From: Minecrell <minecrell@minecrell.net>
 Date: Mon, 18 Sep 2017 12:00:03 +0200
 Subject: [PATCH] Use Log4j IOStreams to redirect System.out/err to logger
@@ -12,7 +12,7 @@ results in a separate line, even though it should not result in
 a line break. Log4j's implementation handles it correctly.
 
 diff --git a/pom.xml b/pom.xml
-index 2b73ec28a1..0a6e81b680 100644
+index 108c8c05e..183c3c4c8 100644
 --- a/pom.xml
 +++ b/pom.xml
 @@ -63,6 +63,11 @@
@@ -28,10 +28,10 @@ index 2b73ec28a1..0a6e81b680 100644
              <groupId>org.ow2.asm</groupId>
              <artifactId>asm</artifactId>
 diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
-index 5bb1ea880a..0d2c7a6dc4 100644
+index 3d0cb874d..d9f1c2205 100644
 --- a/src/main/java/net/minecraft/server/DedicatedServer.java
 +++ b/src/main/java/net/minecraft/server/DedicatedServer.java
-@@ -131,8 +131,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
+@@ -135,8 +135,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
          */
          // Paper end
  
diff --git a/Spigot-Server-Patches/0201-Handle-plugin-prefixes-using-Log4J-configuration.patch b/Spigot-Server-Patches/0176-Handle-plugin-prefixes-using-Log4J-configuration.patch
similarity index 95%
rename from Spigot-Server-Patches/0201-Handle-plugin-prefixes-using-Log4J-configuration.patch
rename to Spigot-Server-Patches/0176-Handle-plugin-prefixes-using-Log4J-configuration.patch
index ac578e6cd5..6f4b01f353 100644
--- a/Spigot-Server-Patches/0201-Handle-plugin-prefixes-using-Log4J-configuration.patch
+++ b/Spigot-Server-Patches/0176-Handle-plugin-prefixes-using-Log4J-configuration.patch
@@ -1,4 +1,4 @@
-From fbb71c462a42540cf6eadfe9769bf6b92cba0c94 Mon Sep 17 00:00:00 2001
+From 87bb6601d0339ee3dab7789689dd29d3351710d0 Mon Sep 17 00:00:00 2001
 From: Minecrell <minecrell@minecrell.net>
 Date: Thu, 21 Sep 2017 16:14:55 +0200
 Subject: [PATCH] Handle plugin prefixes using Log4J configuration
@@ -15,7 +15,7 @@ This may cause additional prefixes to be disabled for plugins bypassing
 the plugin logger.
 
 diff --git a/pom.xml b/pom.xml
-index 0a6e81b680..82b9cae166 100644
+index 183c3c4c8..c18a7f5ca 100644
 --- a/pom.xml
 +++ b/pom.xml
 @@ -61,7 +61,7 @@
@@ -28,7 +28,7 @@ index 0a6e81b680..82b9cae166 100644
          <dependency>
              <groupId>org.apache.logging.log4j</groupId>
 diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
-index fe3bad5830..56f135f244 100644
+index b171bdfaa..0d827815c 100644
 --- a/src/main/java/org/spigotmc/SpigotConfig.java
 +++ b/src/main/java/org/spigotmc/SpigotConfig.java
 @@ -291,7 +291,7 @@ public class SpigotConfig
@@ -41,7 +41,7 @@ index fe3bad5830..56f135f244 100644
  
      public static int playerShuffle;
 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
-index 08b6bb7f97..9f8334376f 100644
+index 08b6bb7f9..9f8334376 100644
 --- a/src/main/resources/log4j2.xml
 +++ b/src/main/resources/log4j2.xml
 @@ -2,10 +2,22 @@
diff --git a/Spigot-Server-Patches/0202-Include-Log4J2-SLF4J-implementation.patch b/Spigot-Server-Patches/0177-Include-Log4J2-SLF4J-implementation.patch
similarity index 87%
rename from Spigot-Server-Patches/0202-Include-Log4J2-SLF4J-implementation.patch
rename to Spigot-Server-Patches/0177-Include-Log4J2-SLF4J-implementation.patch
index 3c3cfa5a8b..46d2f5e489 100644
--- a/Spigot-Server-Patches/0202-Include-Log4J2-SLF4J-implementation.patch
+++ b/Spigot-Server-Patches/0177-Include-Log4J2-SLF4J-implementation.patch
@@ -1,11 +1,11 @@
-From e12eabca265e425f44c2bcae003dc7d3f7716da5 Mon Sep 17 00:00:00 2001
+From e010dba56ef78266584c5dd25d612b51c1ed7ab1 Mon Sep 17 00:00:00 2001
 From: Minecrell <minecrell@minecrell.net>
 Date: Thu, 21 Sep 2017 16:33:35 +0200
 Subject: [PATCH] Include Log4J2 SLF4J implementation
 
 
 diff --git a/pom.xml b/pom.xml
-index 82b9cae166..3ad5af3463 100644
+index c18a7f5ca..16799b4cd 100644
 --- a/pom.xml
 +++ b/pom.xml
 @@ -63,6 +63,12 @@
diff --git a/Spigot-Server-Patches/0203-Disable-logger-prefix-for-various-plugins-bypassing-.patch b/Spigot-Server-Patches/0178-Disable-logger-prefix-for-various-plugins-bypassing-.patch
similarity index 95%
rename from Spigot-Server-Patches/0203-Disable-logger-prefix-for-various-plugins-bypassing-.patch
rename to Spigot-Server-Patches/0178-Disable-logger-prefix-for-various-plugins-bypassing-.patch
index bb8bfc8e7e..4ba478f333 100644
--- a/Spigot-Server-Patches/0203-Disable-logger-prefix-for-various-plugins-bypassing-.patch
+++ b/Spigot-Server-Patches/0178-Disable-logger-prefix-for-various-plugins-bypassing-.patch
@@ -1,4 +1,4 @@
-From bf7855cdd2469f6ee51b72d01e98685fe6951675 Mon Sep 17 00:00:00 2001
+From 0fecfb589e5732e28c516ad6d7f8f25534eaedb7 Mon Sep 17 00:00:00 2001
 From: Minecrell <minecrell@minecrell.net>
 Date: Sat, 23 Sep 2017 21:07:20 +0200
 Subject: [PATCH] Disable logger prefix for various plugins bypassing the
@@ -11,7 +11,7 @@ log. Disable the logger prefix for these plugins so the messages
 show up correctly.
 
 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
-index 9f8334376f..6711e6dff9 100644
+index 9f8334376..6711e6dff 100644
 --- a/src/main/resources/log4j2.xml
 +++ b/src/main/resources/log4j2.xml
 @@ -5,7 +5,8 @@
diff --git a/Spigot-Server-Patches/0204-Add-PlayerJumpEvent.patch b/Spigot-Server-Patches/0179-Add-PlayerJumpEvent.patch
similarity index 77%
rename from Spigot-Server-Patches/0204-Add-PlayerJumpEvent.patch
rename to Spigot-Server-Patches/0179-Add-PlayerJumpEvent.patch
index 954f8007f8..40acad802f 100644
--- a/Spigot-Server-Patches/0204-Add-PlayerJumpEvent.patch
+++ b/Spigot-Server-Patches/0179-Add-PlayerJumpEvent.patch
@@ -1,26 +1,14 @@
-From 089a524589f6065314534ab6607df461a97426e0 Mon Sep 17 00:00:00 2001
+From 720eb49fed3242715f0bceec19e5ef72af4d8e74 Mon Sep 17 00:00:00 2001
 From: Zach Brown <zach.brown@destroystokyo.com>
 Date: Thu, 28 Sep 2017 17:21:44 -0400
 Subject: [PATCH] Add PlayerJumpEvent
 
 
-diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
-index 298012f37c..bfae875ebb 100644
---- a/src/main/java/net/minecraft/server/EntityHuman.java
-+++ b/src/main/java/net/minecraft/server/EntityHuman.java
-@@ -1483,6 +1483,7 @@ public abstract class EntityHuman extends EntityLiving {
-         return 0;
-     }
- 
-+    public void jump() { this.cH(); } // Paper - OBFHELPER
-     public void cH() {
-         super.cH();
-         this.a(StatisticList.JUMP);
 diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index ac64fcfb31..5fa3268b59 100644
+index c07bb9b74..82dad99ef 100644
 --- a/src/main/java/net/minecraft/server/PlayerConnection.java
 +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -58,6 +58,8 @@ import org.bukkit.inventory.CraftingInventory;
+@@ -60,6 +60,8 @@ import org.bukkit.inventory.CraftingInventory;
  import org.bukkit.inventory.EquipmentSlot;
  import org.bukkit.inventory.InventoryView;
  import org.bukkit.util.NumberConversions;
@@ -29,11 +17,11 @@ index ac64fcfb31..5fa3268b59 100644
  import co.aikar.timings.MinecraftTimings; // Paper
  // CraftBukkit end
  
-@@ -872,7 +874,34 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -913,7 +915,34 @@ public class PlayerConnection implements PacketListenerPlayIn {
                              d8 = d5 - this.p;
                              d9 = d6 - this.q;
                              if (this.player.onGround && !packetplayinflying.b() && d8 > 0.0D) {
--                                this.player.cH();
+-                                this.player.jump();
 +                                // Paper start - Add player jump event
 +                                Player player = this.getPlayer();
 +                                Location from = new Location(player.getWorld(), lastPosX, lastPosY, lastPosZ, lastYaw, lastPitch); // Get the Players previous Event location.
@@ -64,7 +52,7 @@ index ac64fcfb31..5fa3268b59 100644
 +                                // Paper end
                              }
  
-                             this.player.move(EnumMoveType.PLAYER, d7, d8, d9);
+                             this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
 -- 
 2.21.0
 
diff --git a/Spigot-Server-Patches/0205-handle-PacketPlayInKeepAlive-async.patch b/Spigot-Server-Patches/0180-handle-PacketPlayInKeepAlive-async.patch
similarity index 85%
rename from Spigot-Server-Patches/0205-handle-PacketPlayInKeepAlive-async.patch
rename to Spigot-Server-Patches/0180-handle-PacketPlayInKeepAlive-async.patch
index 8cae7e3a2b..024457ae5b 100644
--- a/Spigot-Server-Patches/0205-handle-PacketPlayInKeepAlive-async.patch
+++ b/Spigot-Server-Patches/0180-handle-PacketPlayInKeepAlive-async.patch
@@ -1,4 +1,4 @@
-From 5b9b0efc388810e9be0e7b7ccc532a7e8cbcc10b Mon Sep 17 00:00:00 2001
+From 662f1be875e018ce68fcc261c909bf9a339cf19d Mon Sep 17 00:00:00 2001
 From: Shane Freeder <theboyetronic@gmail.com>
 Date: Thu, 5 Oct 2017 01:54:07 +0100
 Subject: [PATCH] handle PacketPlayInKeepAlive async
@@ -15,12 +15,12 @@ also adding some additional logging in order to help work out what is causing
 random disconnections for clients.
 
 diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index 5fa3268b59..0d87ddc0f5 100644
+index 82dad99ef..62c0137a7 100644
 --- a/src/main/java/net/minecraft/server/PlayerConnection.java
 +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -2451,14 +2451,18 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
-     }
+@@ -2504,14 +2504,18 @@ public class PlayerConnection implements PacketListenerPlayIn {
  
+     @Override
      public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
 -        PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit
 +        //PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit // Paper - This shouldn't be on the main thread
@@ -29,11 +29,11 @@ index 5fa3268b59..0d87ddc0f5 100644
  
              this.player.ping = (this.player.ping * 3 + i) / 4;
              this.awaitingKeepAlive = false;
-         } else if (!this.player.getDisplayName().getString().equals(this.minecraftServer.G())) {
+         } else if (!this.isExemptPlayer()) {
 -            this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
 +            // Paper start - This needs to be handled on the main thread for plugins
 +            minecraftServer.postToMainThread(() -> {
-+                this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
++                this.disconnect(new ChatMessage("disconnect.timeout"));
 +            });
 +            // Paper end
          }
diff --git a/Spigot-Server-Patches/0206-Expose-client-protocol-version-and-virtual-host.patch b/Spigot-Server-Patches/0181-Expose-client-protocol-version-and-virtual-host.patch
similarity index 91%
rename from Spigot-Server-Patches/0206-Expose-client-protocol-version-and-virtual-host.patch
rename to Spigot-Server-Patches/0181-Expose-client-protocol-version-and-virtual-host.patch
index 2760ee13ac..4aa0e8a3fd 100644
--- a/Spigot-Server-Patches/0206-Expose-client-protocol-version-and-virtual-host.patch
+++ b/Spigot-Server-Patches/0181-Expose-client-protocol-version-and-virtual-host.patch
@@ -1,4 +1,4 @@
-From 6c0a39d7388e9bfbe78da5bf42868cb6bab7c588 Mon Sep 17 00:00:00 2001
+From 14c5f2f61a0c28123ccb3504d313683bceec5807 Mon Sep 17 00:00:00 2001
 From: Minecrell <minecrell@minecrell.net>
 Date: Tue, 10 Oct 2017 18:45:20 +0200
 Subject: [PATCH] Expose client protocol version and virtual host
@@ -6,7 +6,7 @@ Subject: [PATCH] Expose client protocol version and virtual host
 
 diff --git a/src/main/java/com/destroystokyo/paper/network/PaperNetworkClient.java b/src/main/java/com/destroystokyo/paper/network/PaperNetworkClient.java
 new file mode 100644
-index 0000000000..5caca6439d
+index 000000000..5caca6439
 --- /dev/null
 +++ b/src/main/java/com/destroystokyo/paper/network/PaperNetworkClient.java
 @@ -0,0 +1,50 @@
@@ -61,7 +61,7 @@ index 0000000000..5caca6439d
 +
 +}
 diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
-index 93ca93b640..e732d55f9f 100644
+index 60be2fa99..da88978db 100644
 --- a/src/main/java/net/minecraft/server/HandshakeListener.java
 +++ b/src/main/java/net/minecraft/server/HandshakeListener.java
 @@ -15,6 +15,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
@@ -72,7 +72,7 @@ index 93ca93b640..e732d55f9f 100644
  
      public HandshakeListener(MinecraftServer minecraftserver, NetworkManager networkmanager) {
          this.a = minecraftserver;
-@@ -128,6 +129,10 @@ public class HandshakeListener implements PacketHandshakingInListener {
+@@ -129,6 +130,10 @@ public class HandshakeListener implements PacketHandshakingInListener {
              throw new UnsupportedOperationException("Invalid intention " + packethandshakinginsetprotocol.b());
          }
  
@@ -82,9 +82,9 @@ index 93ca93b640..e732d55f9f 100644
 +        // Paper end
      }
  
-     public void a(IChatBaseComponent ichatbasecomponent) {}
+     @Override
 diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
-index e2fc41d6d1..2ff2549d0e 100644
+index 2db7229e9..5d5e23c18 100644
 --- a/src/main/java/net/minecraft/server/NetworkManager.java
 +++ b/src/main/java/net/minecraft/server/NetworkManager.java
 @@ -62,6 +62,10 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
@@ -99,10 +99,10 @@ index e2fc41d6d1..2ff2549d0e 100644
      public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
          this.h = enumprotocoldirection;
 diff --git a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
-index 7acdac55e5..f1a3be69d0 100644
+index 4f008e472..8545146fb 100644
 --- a/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
 +++ b/src/main/java/net/minecraft/server/PacketHandshakingInSetProtocol.java
-@@ -33,6 +33,7 @@ public class PacketHandshakingInSetProtocol implements Packet<PacketHandshakingI
+@@ -35,6 +35,7 @@ public class PacketHandshakingInSetProtocol implements Packet<PacketHandshakingI
          return this.d;
      }
  
@@ -111,10 +111,10 @@ index 7acdac55e5..f1a3be69d0 100644
          return this.a;
      }
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index d85e622525..dafc2948c0 100644
+index 0b0053207..bb50ae1ac 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-@@ -174,6 +174,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+@@ -179,6 +179,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
          }
      }
  
diff --git a/Spigot-Server-Patches/0207-revert-serverside-behavior-of-keepalives.patch b/Spigot-Server-Patches/0182-revert-serverside-behavior-of-keepalives.patch
similarity index 87%
rename from Spigot-Server-Patches/0207-revert-serverside-behavior-of-keepalives.patch
rename to Spigot-Server-Patches/0182-revert-serverside-behavior-of-keepalives.patch
index 27691fa873..e0d15e32e3 100644
--- a/Spigot-Server-Patches/0207-revert-serverside-behavior-of-keepalives.patch
+++ b/Spigot-Server-Patches/0182-revert-serverside-behavior-of-keepalives.patch
@@ -1,4 +1,4 @@
-From f675c65d7d47b07c993b7d741418f9b6f15ec079 Mon Sep 17 00:00:00 2001
+From 6a33d0f087cf96e9f875fe67da1cdfd73aa8d382 Mon Sep 17 00:00:00 2001
 From: Shane Freeder <theboyetronic@gmail.com>
 Date: Sun, 15 Oct 2017 00:29:07 +0100
 Subject: [PATCH] revert serverside behavior of keepalives
@@ -17,10 +17,10 @@ from networking or during connections flood of chunk packets on slower clients,
  at the cost of dead connections being kept open for longer.
 
 diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index 0d87ddc0f5..551740ec6c 100644
+index 62c0137a7..9a981a608 100644
 --- a/src/main/java/net/minecraft/server/PlayerConnection.java
 +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -70,7 +70,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -72,7 +72,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
      private final MinecraftServer minecraftServer;
      public EntityPlayer player;
      private int e;
@@ -29,7 +29,7 @@ index 0d87ddc0f5..551740ec6c 100644
      private boolean awaitingKeepAlive; private void setPendingPing(boolean isPending) { this.awaitingKeepAlive = isPending;}; private boolean isPendingPing() { return this.awaitingKeepAlive;}; // Paper - OBFHELPER
      private long h; private void setKeepAliveID(long keepAliveID) { this.h = keepAliveID;}; private long getKeepAliveID() {return this.h; };  // Paper - OBFHELPER
      // CraftBukkit start - multithreaded fields
-@@ -101,6 +101,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -103,6 +103,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
      private int E;
      private int receivedMovePackets;
      private int processedMovePackets;
@@ -37,14 +37,11 @@ index 0d87ddc0f5..551740ec6c 100644
  
      public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
          this.minecraftServer = minecraftserver;
-@@ -179,18 +180,26 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -181,18 +182,25 @@ public class PlayerConnection implements PacketListenerPlayIn {
          }
  
-         this.minecraftServer.methodProfiler.enter("keepAlive");
+         this.minecraftServer.getMethodProfiler().enter("keepAlive");
 -        long i = SystemUtils.getMonotonicMillis();
--
--        if (i - this.lastKeepAlive >= 25000L) { // CraftBukkit
--            if (this.awaitingKeepAlive) {
 +        // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings
 +        // This should effectively place the keepalive handling back to "as it was" before 1.12.2
 +        long currentTime = SystemUtils.getMonotonicMillis();
@@ -53,12 +50,6 @@ index 0d87ddc0f5..551740ec6c 100644
 +        if (this.isPendingPing()) {
 +            if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
 +                PlayerConnection.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getName()); // more info
-                 this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
--            } else {
--                this.awaitingKeepAlive = true;
--                this.lastKeepAlive = i;
--                this.h = i;
--                this.sendPacket(new PacketPlayOutKeepAlive(this.h));
 +            }
 +        } else {
 +            if (elapsedTime >= 15000L) { // 15 seconds
@@ -66,12 +57,20 @@ index 0d87ddc0f5..551740ec6c 100644
 +                this.setLastPing(currentTime);
 +                this.setKeepAliveID(currentTime);
 +                this.sendPacket(new PacketPlayOutKeepAlive(this.getKeepAliveID()));
-+
+ 
+-        if (i - this.lastKeepAlive >= 25000L) { // CraftBukkit
+-            if (this.awaitingKeepAlive) {
+-                this.disconnect(new ChatMessage("disconnect.timeout", new Object[0]));
+-            } else {
+-                this.awaitingKeepAlive = true;
+-                this.lastKeepAlive = i;
+-                this.h = i;
+-                this.sendPacket(new PacketPlayOutKeepAlive(this.h));
              }
          }
 +        // Paper end
  
-         this.minecraftServer.methodProfiler.exit();
+         this.minecraftServer.getMethodProfiler().exit();
          // CraftBukkit start
 -- 
 2.21.0
diff --git a/Spigot-Server-Patches/0208-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch b/Spigot-Server-Patches/0183-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch
similarity index 92%
rename from Spigot-Server-Patches/0208-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch
rename to Spigot-Server-Patches/0183-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch
index ad3efa1f54..63516b8439 100644
--- a/Spigot-Server-Patches/0208-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch
+++ b/Spigot-Server-Patches/0183-Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch
@@ -1,4 +1,4 @@
-From 5e1b6f44000755e1b473737e27c13fdc6a2a46a6 Mon Sep 17 00:00:00 2001
+From fd2bd4f9885b94441cf42515e5c37a7d59e8c267 Mon Sep 17 00:00:00 2001
 From: Brokkonaut <hannos17@gmx.de>
 Date: Fri, 20 Oct 2017 04:33:45 +0200
 Subject: [PATCH] Replace HashSet with fastutil's ObjectOpenHashSet in
@@ -13,7 +13,7 @@ ObjectOpenHashSet never uses compareTo(), so the inconsistencies of NextTickList
 Fixes https://github.com/PaperMC/Paper/issues/588
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java b/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java
-index 80a5c29f3b..cd864c4047 100644
+index 80a5c29f3..cd864c404 100644
 --- a/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java
 +++ b/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java
 @@ -8,7 +8,7 @@ import java.util.TreeSet;
diff --git a/Spigot-Server-Patches/0209-Send-attack-SoundEffects-only-to-players-who-can-see.patch b/Spigot-Server-Patches/0184-Send-attack-SoundEffects-only-to-players-who-can-see.patch
similarity index 71%
rename from Spigot-Server-Patches/0209-Send-attack-SoundEffects-only-to-players-who-can-see.patch
rename to Spigot-Server-Patches/0184-Send-attack-SoundEffects-only-to-players-who-can-see.patch
index f44c873755..0e36633aa1 100644
--- a/Spigot-Server-Patches/0209-Send-attack-SoundEffects-only-to-players-who-can-see.patch
+++ b/Spigot-Server-Patches/0184-Send-attack-SoundEffects-only-to-players-who-can-see.patch
@@ -1,4 +1,4 @@
-From f94e3680ce72b843b725ae03807974c2816d210f Mon Sep 17 00:00:00 2001
+From ee17efd1d77554be35135b8e259d2ebd09d6488d Mon Sep 17 00:00:00 2001
 From: Brokkonaut <hannos17@gmx.de>
 Date: Tue, 31 Oct 2017 03:26:18 +0100
 Subject: [PATCH] Send attack SoundEffects only to players who can see the
@@ -6,11 +6,11 @@ Subject: [PATCH] Send attack SoundEffects only to players who can see the
 
 
 diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
-index bfae875ebb..259f73f66e 100644
+index 0f8100a05..a30d88af8 100644
 --- a/src/main/java/net/minecraft/server/EntityHuman.java
 +++ b/src/main/java/net/minecraft/server/EntityHuman.java
-@@ -989,6 +989,15 @@ public abstract class EntityHuman extends EntityLiving {
-         this.k = 0;
+@@ -941,6 +941,15 @@ public abstract class EntityHuman extends EntityLiving {
+         return super.isFrozen() || this.isSleeping();
      }
  
 +    // Paper start - send SoundEffect to everyone who can see fromEntity
@@ -23,59 +23,59 @@ index bfae875ebb..259f73f66e 100644
 +    // Paper end
 +
      public void attack(Entity entity) {
-         if (entity.bk()) {
+         if (entity.br()) {
              if (!entity.t(this)) {
-@@ -1013,7 +1022,7 @@ public abstract class EntityHuman extends EntityLiving {
+@@ -965,7 +974,7 @@ public abstract class EntityHuman extends EntityLiving {
                      int i = b0 + EnchantmentManager.b((EntityLiving) this);
  
                      if (this.isSprinting() && flag) {
--                        this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.bV(), 1.0F, 1.0F);
-+                        sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
+-                        this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F);
++                        sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F);  // Paper - send while respecting visibility
                          ++i;
                          flag1 = true;
                      }
-@@ -1091,7 +1100,7 @@ public abstract class EntityHuman extends EntityLiving {
+@@ -1040,7 +1049,7 @@ public abstract class EntityHuman extends EntityLiving {
                                  }
                              }
  
--                            this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.bV(), 1.0F, 1.0F);
-+                            sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
-                             this.dl();
+-                            this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0F, 1.0F);
++                            sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0F, 1.0F);  // Paper - send while respecting visibility
+                             this.dE();
                          }
  
-@@ -1121,15 +1130,15 @@ public abstract class EntityHuman extends EntityLiving {
+@@ -1068,15 +1077,15 @@ public abstract class EntityHuman extends EntityLiving {
                          }
  
                          if (flag2) {
--                            this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.bV(), 1.0F, 1.0F);
-+                            sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
+-                            this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0F, 1.0F);
++                            sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0F, 1.0F);  // Paper - send while respecting visibility
                              this.a(entity);
                          }
  
                          if (!flag2 && !flag3) {
                              if (flag) {
--                                this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.bV(), 1.0F, 1.0F);
-+                                sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
+-                                this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0F, 1.0F);
++                                sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0F, 1.0F);  // Paper - send while respecting visibility
                              } else {
--                                this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.bV(), 1.0F, 1.0F);
-+                                sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
+-                                this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0F, 1.0F);
++                                sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0F, 1.0F);  // Paper - send while respecting visibility
                              }
                          }
  
-@@ -1185,7 +1194,7 @@ public abstract class EntityHuman extends EntityLiving {
+@@ -1128,7 +1137,7 @@ public abstract class EntityHuman extends EntityLiving {
  
                          this.applyExhaustion(world.spigotConfig.combatExhaustion); // Spigot - Change to use configurable value
                      } else {
--                        this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.bV(), 1.0F, 1.0F);
-+                        sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.bV(), 1.0F, 1.0F); // Paper - send while respecting visibility
+-                        this.world.a((EntityHuman) null, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
++                        sendSoundEffect(this, this.locX, this.locY, this.locZ, SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
                          if (flag4) {
                              entity.extinguish();
                          }
 diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
-index cdb430ef4f..cdef374c61 100644
+index c9fc001f2..4d86e7849 100644
 --- a/src/main/java/net/minecraft/server/World.java
 +++ b/src/main/java/net/minecraft/server/World.java
-@@ -954,6 +954,12 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
+@@ -664,6 +664,10 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
          this.a(entityhuman, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, soundeffect, soundcategory, f, f1);
      }
  
@@ -83,11 +83,9 @@ index cdb430ef4f..cdef374c61 100644
 +    public final void sendSoundEffect(@Nullable EntityHuman fromEntity, double x, double y, double z, SoundEffect soundeffect, SoundCategory soundcategory, float volume, float pitch) {
 +        this.a(fromEntity, x, y, z, soundeffect, soundcategory, volume, pitch);
 +    }
-+    // Paper end
-+
-     public void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
-         for (int i = 0; i < this.v.size(); ++i) {
-             ((IWorldAccess) this.v.get(i)).a(entityhuman, soundeffect, soundcategory, d0, d1, d2, f, f1);
+     public abstract void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1);
+ 
+     public abstract void a(@Nullable EntityHuman entityhuman, Entity entity, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1);
 -- 
 2.21.0
 
diff --git a/Spigot-Server-Patches/0210-Option-for-maximum-exp-value-when-merging-orbs.patch b/Spigot-Server-Patches/0185-Option-for-maximum-exp-value-when-merging-orbs.patch
similarity index 92%
rename from Spigot-Server-Patches/0210-Option-for-maximum-exp-value-when-merging-orbs.patch
rename to Spigot-Server-Patches/0185-Option-for-maximum-exp-value-when-merging-orbs.patch
index 571ab3a1f0..d48313f55c 100644
--- a/Spigot-Server-Patches/0210-Option-for-maximum-exp-value-when-merging-orbs.patch
+++ b/Spigot-Server-Patches/0185-Option-for-maximum-exp-value-when-merging-orbs.patch
@@ -1,14 +1,14 @@
-From 9fe4a6075e6fa09371163a89977cededa88ae9c3 Mon Sep 17 00:00:00 2001
+From 8b33d0de3f3ad917a98f1a15c009286a04c612ae Mon Sep 17 00:00:00 2001
 From: BillyGalbreath <Blake.Galbreath@GMail.com>
 Date: Fri, 10 Nov 2017 23:03:12 -0500
 Subject: [PATCH] Option for maximum exp value when merging orbs
 
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 3baf0380c0..c9422d545a 100644
+index abc967d3f..2a50d6bab 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -387,4 +387,10 @@ public class PaperWorldConfig {
+@@ -338,4 +338,10 @@ public class PaperWorldConfig {
          disableCreeperLingeringEffect = getBoolean("disable-creeper-lingering-effect", false);
          log("Creeper lingering effect: " + disableCreeperLingeringEffect);
      }
@@ -20,10 +20,10 @@ index 3baf0380c0..c9422d545a 100644
 +    }
  }
 diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index 9cbbfed4fe..2985c76f37 100644
+index b75369275..8fca14243 100644
 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
 +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -394,16 +394,32 @@ public class CraftEventFactory {
+@@ -499,16 +499,32 @@ public class CraftEventFactory {
              EntityExperienceOrb xp = (EntityExperienceOrb) entity;
              double radius = world.spigotConfig.expMerge;
              if (radius > 0) {
diff --git a/Spigot-Server-Patches/0211-Add-PlayerArmorChangeEvent.patch b/Spigot-Server-Patches/0186-Add-PlayerArmorChangeEvent.patch
similarity index 82%
rename from Spigot-Server-Patches/0211-Add-PlayerArmorChangeEvent.patch
rename to Spigot-Server-Patches/0186-Add-PlayerArmorChangeEvent.patch
index 193d0f44d8..d3161c6a6f 100644
--- a/Spigot-Server-Patches/0211-Add-PlayerArmorChangeEvent.patch
+++ b/Spigot-Server-Patches/0186-Add-PlayerArmorChangeEvent.patch
@@ -1,11 +1,11 @@
-From 6983ce9beb5d9de6bbc77810cee8af4b4cc3bb6b Mon Sep 17 00:00:00 2001
+From 017175990b58dac008de3399fe82a3d8d41aebb4 Mon Sep 17 00:00:00 2001
 From: pkt77 <parkerkt77@gmail.com>
 Date: Fri, 10 Nov 2017 23:46:34 -0500
 Subject: [PATCH] Add PlayerArmorChangeEvent
 
 
 diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
-index 138a224e04..02fcfc449c 100644
+index 121925046..9ef605ba3 100644
 --- a/src/main/java/net/minecraft/server/EntityLiving.java
 +++ b/src/main/java/net/minecraft/server/EntityLiving.java
 @@ -1,5 +1,6 @@
@@ -13,9 +13,9 @@ index 138a224e04..02fcfc449c 100644
  
 +import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
  import com.google.common.base.Objects;
+ import com.google.common.collect.ImmutableList;
  import com.google.common.collect.Maps;
- import java.util.Collection;
-@@ -2085,6 +2086,13 @@ public abstract class EntityLiving extends Entity {
+@@ -2269,6 +2270,13 @@ public abstract class EntityLiving extends Entity {
                  ItemStack itemstack1 = this.getEquipment(enumitemslot);
  
                  if (!ItemStack.matches(itemstack1, itemstack)) {
@@ -26,11 +26,11 @@ index 138a224e04..02fcfc449c 100644
 +                        new PlayerArmorChangeEvent((Player) this.getBukkitEntity(), PlayerArmorChangeEvent.SlotType.valueOf(enumitemslot.name()), oldItem, newItem).callEvent();
 +                    }
 +                    // Paper end
-                     ((WorldServer) this.world).getTracker().a((Entity) this, (Packet) (new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1)));
+                     ((WorldServer) this.world).getChunkProvider().broadcast(this, new PacketPlayOutEntityEquipment(this.getId(), enumitemslot, itemstack1));
                      if (!itemstack.isEmpty()) {
                          this.getAttributeMap().a(itemstack.a(enumitemslot));
 diff --git a/src/main/java/net/minecraft/server/EnumItemSlot.java b/src/main/java/net/minecraft/server/EnumItemSlot.java
-index a9a1339933..8f4b5dca94 100644
+index 02a7ae678..60b235f16 100644
 --- a/src/main/java/net/minecraft/server/EnumItemSlot.java
 +++ b/src/main/java/net/minecraft/server/EnumItemSlot.java
 @@ -16,6 +16,7 @@ public enum EnumItemSlot {
diff --git a/Spigot-Server-Patches/0187-Fix-Anvil-Level-sync-to-client.patch b/Spigot-Server-Patches/0187-Fix-Anvil-Level-sync-to-client.patch
deleted file mode 100644
index 16ad8709f9..0000000000
--- a/Spigot-Server-Patches/0187-Fix-Anvil-Level-sync-to-client.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-From 701f704672d685a7c1683c9a4f7c4055e3c4fcdc Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Tue, 11 Jul 2017 23:17:57 -0400
-Subject: [PATCH] Fix Anvil Level sync to client
-
-https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/763827668e6e5cddc111f3c93a0d718fec21ff51
-
-Was done incorrectly and is now causing level desyncs to client.
-
-Always send current level to the client, and instead make setWindowProperty set the level.
-
-diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
-index a6ac516147..1560dd382a 100644
---- a/src/main/java/net/minecraft/server/ContainerAnvil.java
-+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
-@@ -375,9 +375,9 @@ public class ContainerAnvil extends Container {
-         for (int i = 0; i < this.listeners.size(); ++i) {
-             ICrafting icrafting = (ICrafting) this.listeners.get(i);
- 
--            if (this.lastLevelCost != this.levelCost) {
-+            //if (this.lastLevelCost != this.levelCost) { // Paper - this was the wrong solution to this, fixing it correctly in CraftPlayer
-                 icrafting.setContainerData(this, 0, this.levelCost);
--            }
-+            //} // Paper
-         }
- 
-         this.lastLevelCost = this.levelCost;
-diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index c5f2284553..d85e622525 100644
---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-@@ -1405,6 +1405,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
-         if (container.getBukkitView().getType() != prop.getType()) {
-             return false;
-         }
-+        // Paper start
-+        if (prop == Property.REPAIR_COST && container instanceof net.minecraft.server.ContainerAnvil) {
-+            ((net.minecraft.server.ContainerAnvil) container).levelCost = value;
-+        }
-+        // Paper end
-         getHandle().setContainerData(container, prop.getId(), value);
-         return true;
-     }
--- 
-2.21.0
-
diff --git a/Spigot-Server-Patches/0212-Prevent-logins-from-being-processed-when-the-player-.patch b/Spigot-Server-Patches/0187-Prevent-logins-from-being-processed-when-the-player-.patch
similarity index 84%
rename from Spigot-Server-Patches/0212-Prevent-logins-from-being-processed-when-the-player-.patch
rename to Spigot-Server-Patches/0187-Prevent-logins-from-being-processed-when-the-player-.patch
index 29ffff60a8..620a360963 100644
--- a/Spigot-Server-Patches/0212-Prevent-logins-from-being-processed-when-the-player-.patch
+++ b/Spigot-Server-Patches/0187-Prevent-logins-from-being-processed-when-the-player-.patch
@@ -1,4 +1,4 @@
-From 60b37d35e44ae9b29a142bf1a33b4b750906059a Mon Sep 17 00:00:00 2001
+From 381f712680dfeaafe48d34a457a51f7c691def20 Mon Sep 17 00:00:00 2001
 From: killme <killme-git@ibts.me>
 Date: Sun, 12 Nov 2017 19:40:01 +0100
 Subject: [PATCH] Prevent logins from being processed when the player has
@@ -6,17 +6,17 @@ Subject: [PATCH] Prevent logins from being processed when the player has
 
 
 diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
-index 74bc08f85c..15c01333e7 100644
+index 398f67f4b..fe912e0eb 100644
 --- a/src/main/java/net/minecraft/server/LoginListener.java
 +++ b/src/main/java/net/minecraft/server/LoginListener.java
-@@ -56,7 +56,11 @@ public class LoginListener implements PacketLoginInListener, ITickable {
+@@ -56,7 +56,11 @@ public class LoginListener implements PacketLoginInListener {
          }
          // Paper end
          if (this.g == LoginListener.EnumProtocolState.READY_TO_ACCEPT) {
--            this.b();
+-            this.c();
 +            // Paper start - prevent logins to be processed even though disconnect was called
 +            if (networkManager.isConnected()) {
-+                this.b();
++                this.c();
 +            }
 +            // Paper end
          } else if (this.g == LoginListener.EnumProtocolState.DELAY_ACCEPT) {
diff --git a/Spigot-Server-Patches/0188-Add-missing-coverages-for-getTileEntity-in-order-to-.patch b/Spigot-Server-Patches/0188-Add-missing-coverages-for-getTileEntity-in-order-to-.patch
deleted file mode 100644
index 9a853650af..0000000000
--- a/Spigot-Server-Patches/0188-Add-missing-coverages-for-getTileEntity-in-order-to-.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-From 22ee365ac0b8d43053a9aa2db059eb17738ef115 Mon Sep 17 00:00:00 2001
-From: Shane Freeder <theboyetronic@gmail.com>
-Date: Sat, 22 Jul 2017 15:22:59 +0100
-Subject: [PATCH] Add missing coverages for getTileEntity in order to attempt
- to avoid exeptions when calling getTileEntity
-
-
-diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
-index 15736f7575..ee09f4c5a0 100644
---- a/src/main/java/net/minecraft/server/WorldServer.java
-+++ b/src/main/java/net/minecraft/server/WorldServer.java
-@@ -217,6 +217,13 @@ public class WorldServer extends World implements IAsyncTaskHandler {
-                 result = fixTileEntity(pos, type, result);
-             }
-         }
-+        // Paper Start - add TE fix checks for shulkers, see nms.BlockShulkerBox
-+        else if (type instanceof BlockShulkerBox) {
-+            if (!(result instanceof TileEntityShulkerBox)) {
-+                result = fixTileEntity(pos, type, result);
-+            }
-+        }
-+        // Paper end
- 
-         return result;
-     }
--- 
-2.21.0
-
diff --git a/Spigot-Server-Patches/0213-use-CB-BlockState-implementations-for-captured-block.patch b/Spigot-Server-Patches/0188-use-CB-BlockState-implementations-for-captured-block.patch
similarity index 89%
rename from Spigot-Server-Patches/0213-use-CB-BlockState-implementations-for-captured-block.patch
rename to Spigot-Server-Patches/0188-use-CB-BlockState-implementations-for-captured-block.patch
index 421c1814e8..25703b5c7c 100644
--- a/Spigot-Server-Patches/0213-use-CB-BlockState-implementations-for-captured-block.patch
+++ b/Spigot-Server-Patches/0188-use-CB-BlockState-implementations-for-captured-block.patch
@@ -1,4 +1,4 @@
-From 8e4968e7640c46591f5442686ef86bc5cf1bd401 Mon Sep 17 00:00:00 2001
+From 63a4edb55045af43ed1e849de350c49842029cc9 Mon Sep 17 00:00:00 2001
 From: Shane Freeder <theboyetronic@gmail.com>
 Date: Thu, 16 Nov 2017 12:12:41 +0000
 Subject: [PATCH] use CB BlockState implementations for captured blocks
@@ -18,10 +18,10 @@ the blockstate that will be valid for restoration, as opposed to dropping
 information on restoration when the event is cancelled.
 
 diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
-index cdef374c61..d87b08a49e 100644
+index 4d86e7849..3737fca81 100644
 --- a/src/main/java/net/minecraft/server/World.java
 +++ b/src/main/java/net/minecraft/server/World.java
-@@ -395,7 +395,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
+@@ -342,7 +342,7 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
              // CraftBukkit start - capture blockstates
              CraftBlockState blockstate = null;
              if (this.captureBlockStates) {
diff --git a/Spigot-Server-Patches/0214-API-to-get-a-BlockState-without-a-snapshot.patch b/Spigot-Server-Patches/0189-API-to-get-a-BlockState-without-a-snapshot.patch
similarity index 92%
rename from Spigot-Server-Patches/0214-API-to-get-a-BlockState-without-a-snapshot.patch
rename to Spigot-Server-Patches/0189-API-to-get-a-BlockState-without-a-snapshot.patch
index f95b101366..a6ec8611bd 100644
--- a/Spigot-Server-Patches/0214-API-to-get-a-BlockState-without-a-snapshot.patch
+++ b/Spigot-Server-Patches/0189-API-to-get-a-BlockState-without-a-snapshot.patch
@@ -1,4 +1,4 @@
-From a6c89447b205715e04b8a8e86ad3f7af4733cdc9 Mon Sep 17 00:00:00 2001
+From ac4ff4469b68dab3d8f1f382ec05dfc687257495 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Mon, 6 Nov 2017 21:08:22 -0500
 Subject: [PATCH] API to get a BlockState without a snapshot
@@ -13,10 +13,10 @@ also Avoid NPE during CraftBlockEntityState load if could not get TE
 If Tile Entity was null, correct Sign to return empty lines instead of null
 
 diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
-index b3c5766a27..29fe031d85 100644
+index d8cc35352..4ac97a59c 100644
 --- a/src/main/java/net/minecraft/server/TileEntity.java
 +++ b/src/main/java/net/minecraft/server/TileEntity.java
-@@ -206,7 +206,12 @@ public abstract class TileEntity implements KeyedObject { // Paper
+@@ -207,7 +207,12 @@ public abstract class TileEntity implements KeyedObject { // Paper
      }
  
      // CraftBukkit start - add method
@@ -29,7 +29,7 @@ index b3c5766a27..29fe031d85 100644
          if (world == null) return null;
          // Spigot start
          org.bukkit.block.Block block = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
-@@ -215,7 +220,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
+@@ -216,7 +221,7 @@ public abstract class TileEntity implements KeyedObject { // Paper
              return null;
          }
          // Spigot end
@@ -39,10 +39,10 @@ index b3c5766a27..29fe031d85 100644
          return null;
      }
 diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-index 4b4fdf93f6..7ae4b7952f 100644
+index 8eabf8602..69b449507 100644
 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
 +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
-@@ -275,6 +275,20 @@ public class CraftBlock implements Block {
+@@ -294,6 +294,20 @@ public class CraftBlock implements Block {
      }
  
      public BlockState getState() {
@@ -64,7 +64,7 @@ index 4b4fdf93f6..7ae4b7952f 100644
  
          switch (material) {
 diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
-index 4f4121adca..082a1b6e20 100644
+index 4f4121adc..082a1b6e2 100644
 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
 +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
 @@ -23,20 +23,40 @@ public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState
@@ -114,7 +114,7 @@ index 4f4121adca..082a1b6e20 100644
  
      private T createSnapshot(T tileEntity, World world) {
 diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
-index e6f86cc4b1..3a8f643609 100644
+index e6f86cc4b..3a8f64360 100644
 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
 +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSign.java
 @@ -15,10 +15,12 @@ public class CraftSign extends CraftBlockEntityState<TileEntitySign> implements
diff --git a/Spigot-Server-Patches/0215-AsyncTabCompleteEvent.patch b/Spigot-Server-Patches/0190-AsyncTabCompleteEvent.patch
similarity index 92%
rename from Spigot-Server-Patches/0215-AsyncTabCompleteEvent.patch
rename to Spigot-Server-Patches/0190-AsyncTabCompleteEvent.patch
index 80fec6e18e..eb09d21c9c 100644
--- a/Spigot-Server-Patches/0215-AsyncTabCompleteEvent.patch
+++ b/Spigot-Server-Patches/0190-AsyncTabCompleteEvent.patch
@@ -1,4 +1,4 @@
-From ea000bfea5378094525b8c3778c8e8a9af11626b Mon Sep 17 00:00:00 2001
+From 1144e668d90e4453f729861abc04adee62832f27 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Sun, 26 Nov 2017 13:19:58 -0500
 Subject: [PATCH] AsyncTabCompleteEvent
@@ -14,12 +14,12 @@ completion, such as offline players.
 Also adds isCommand and getLocation to the sync TabCompleteEvent
 
 diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index 551740ec6c..2f00929f63 100644
+index 9a981a608..25c86b53e 100644
 --- a/src/main/java/net/minecraft/server/PlayerConnection.java
 +++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -507,10 +507,10 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
-     }
+@@ -521,10 +521,10 @@ public class PlayerConnection implements PacketListenerPlayIn {
  
+     @Override
      public void a(PacketPlayInTabComplete packetplayintabcomplete) {
 -        PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer());
 +        // PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async
@@ -30,7 +30,7 @@ index 551740ec6c..2f00929f63 100644
              return;
          }
          // CraftBukkit end
-@@ -520,12 +520,35 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -534,12 +534,35 @@ public class PlayerConnection implements PacketListenerPlayIn {
              stringreader.skip();
          }
  
@@ -68,12 +68,12 @@ index 551740ec6c..2f00929f63 100644
 +
      }
  
-     public void a(PacketPlayInSetCommandBlock packetplayinsetcommandblock) {
+     @Override
 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index 1e8c4a85cb..8315f63775 100644
+index cfcb7a4fd..2173f34fe 100644
 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
 +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -1724,7 +1724,7 @@ public final class CraftServer implements Server {
+@@ -1658,7 +1658,7 @@ public final class CraftServer implements Server {
              offers = tabCompleteChat(player, message);
          }
  
@@ -83,10 +83,10 @@ index 1e8c4a85cb..8315f63775 100644
  
          return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
 diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
-index 1e3aae3b8f..95d13c146b 100644
+index 24f4a16a6..a01d793e7 100644
 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
 +++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java
-@@ -28,6 +28,39 @@ public class ConsoleCommandCompleter implements Completer {
+@@ -27,6 +27,39 @@ public class ConsoleCommandCompleter implements Completer {
      public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
          final CraftServer server = this.server.server;
          final String buffer = line.line();
diff --git a/Spigot-Server-Patches/0216-Avoid-NPE-in-PathfinderGoalTempt.patch b/Spigot-Server-Patches/0191-Avoid-NPE-in-PathfinderGoalTempt.patch
similarity index 82%
rename from Spigot-Server-Patches/0216-Avoid-NPE-in-PathfinderGoalTempt.patch
rename to Spigot-Server-Patches/0191-Avoid-NPE-in-PathfinderGoalTempt.patch
index 2ff20c9150..457bbc4c59 100644
--- a/Spigot-Server-Patches/0216-Avoid-NPE-in-PathfinderGoalTempt.patch
+++ b/Spigot-Server-Patches/0191-Avoid-NPE-in-PathfinderGoalTempt.patch
@@ -1,14 +1,14 @@
-From 2382c61af38c805ec9cf6f4bf795381df4b06734 Mon Sep 17 00:00:00 2001
+From 243fcddd45f4e024f50c7acc018b3a301adc32f8 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Wed, 29 Nov 2017 22:18:54 -0500
 Subject: [PATCH] Avoid NPE in PathfinderGoalTempt
 
 
 diff --git a/src/main/java/net/minecraft/server/PathfinderGoalTempt.java b/src/main/java/net/minecraft/server/PathfinderGoalTempt.java
-index 5cf9b18963..1f3ae55a00 100644
+index fb395bcde..d1164dd68 100644
 --- a/src/main/java/net/minecraft/server/PathfinderGoalTempt.java
 +++ b/src/main/java/net/minecraft/server/PathfinderGoalTempt.java
-@@ -52,7 +52,7 @@ public class PathfinderGoalTempt extends PathfinderGoal {
+@@ -55,7 +55,7 @@ public class PathfinderGoalTempt extends PathfinderGoal {
                  }
                  this.target = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
              }
diff --git a/Spigot-Server-Patches/0192-GH-806-Respect-saving-disabled-before-unloading-all-.patch b/Spigot-Server-Patches/0192-GH-806-Respect-saving-disabled-before-unloading-all-.patch
deleted file mode 100644
index 23d403bd48..0000000000
--- a/Spigot-Server-Patches/0192-GH-806-Respect-saving-disabled-before-unloading-all-.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From bd45d8941e1364a7c28282e3fe90d3c5bc24fee8 Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Thu, 27 Jul 2017 00:06:43 -0400
-Subject: [PATCH] GH-806: Respect saving disabled before unloading all chunks
- in a world
-
-This behavior causes a save to occur even though saving was supposed to be turned off.
-
-It's triggered when Hell/End worlds are empty of players.
-
-diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index ab4f3b7223..e428d4485b 100644
---- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
-+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -186,7 +186,7 @@ public class PlayerChunkMap {
-             try (Timing ignored = world.timings.doChunkMapUnloadChunks.startTiming()) { // Paper
-             WorldProvider worldprovider = this.world.worldProvider;
- 
--            if (!worldprovider.canRespawn()) {
-+            if (!worldprovider.canRespawn() && !this.world.savingDisabled) { // Paper - respect saving disabled setting
-                 this.world.getChunkProvider().b();
-             }
-             } // Paper timing
--- 
-2.21.0
-
diff --git a/Spigot-Server-Patches/0217-PlayerPickupExperienceEvent.patch b/Spigot-Server-Patches/0192-PlayerPickupExperienceEvent.patch
similarity index 59%
rename from Spigot-Server-Patches/0217-PlayerPickupExperienceEvent.patch
rename to Spigot-Server-Patches/0192-PlayerPickupExperienceEvent.patch
index 5a1218c3b1..65424e605a 100644
--- a/Spigot-Server-Patches/0217-PlayerPickupExperienceEvent.patch
+++ b/Spigot-Server-Patches/0192-PlayerPickupExperienceEvent.patch
@@ -1,4 +1,4 @@
-From 1eaf18a755a9c7c9559ed65af9bbbebe454cc588 Mon Sep 17 00:00:00 2001
+From 2dba4612c8b3b409d05595711229a0f3028ce56c Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Tue, 19 Dec 2017 22:02:53 -0500
 Subject: [PATCH] PlayerPickupExperienceEvent
@@ -6,18 +6,18 @@ Subject: [PATCH] PlayerPickupExperienceEvent
 Allows plugins to cancel a player picking up an experience orb
 
 diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
-index 404a222b45..4bcae2c21b 100644
+index 49668f2c2..704a48c8e 100644
 --- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java
 +++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
-@@ -218,7 +218,7 @@ public class EntityExperienceOrb extends Entity {
- 
-     public void d(EntityHuman entityhuman) {
+@@ -219,7 +219,7 @@ public class EntityExperienceOrb extends Entity {
+     @Override
+     public void pickup(EntityHuman entityhuman) {
          if (!this.world.isClientSide) {
--            if (this.c == 0 && entityhuman.bJ == 0) {
-+            if (this.c == 0 && entityhuman.bJ == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(((EntityPlayer) entityhuman).getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper
-                 entityhuman.bJ = 2;
+-            if (this.d == 0 && entityhuman.bF == 0) {
++            if (this.d == 0 && entityhuman.bF == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(((EntityPlayer) entityhuman).getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper
+                 entityhuman.bF = 2;
                  entityhuman.receive(this, 1);
-                 ItemStack itemstack = EnchantmentManager.b(Enchantments.MENDING, (EntityLiving) entityhuman);
+                 Entry<EnumItemSlot, ItemStack> entry = EnchantmentManager.b(Enchantments.MENDING, (EntityLiving) entityhuman);
 -- 
 2.21.0
 
diff --git a/Spigot-Server-Patches/0218-ExperienceOrbMergeEvent.patch b/Spigot-Server-Patches/0193-ExperienceOrbMergeEvent.patch
similarity index 90%
rename from Spigot-Server-Patches/0218-ExperienceOrbMergeEvent.patch
rename to Spigot-Server-Patches/0193-ExperienceOrbMergeEvent.patch
index 542ec3a301..df946b77f5 100644
--- a/Spigot-Server-Patches/0218-ExperienceOrbMergeEvent.patch
+++ b/Spigot-Server-Patches/0193-ExperienceOrbMergeEvent.patch
@@ -1,4 +1,4 @@
-From 48181f892f95ba0aee460a1eee9a7f2a256cf3e3 Mon Sep 17 00:00:00 2001
+From c1554b6404351df0b3eacf9d551c9da16d38ba3b Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Tue, 19 Dec 2017 22:57:26 -0500
 Subject: [PATCH] ExperienceOrbMergeEvent
@@ -8,10 +8,10 @@ Plugins can cancel this if they want to ensure experience orbs do not lose impor
 metadata such as spawn reason, or conditionally move data from source to target.
 
 diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-index 2985c76f37..c02619bb57 100644
+index 8fca14243..8d3dca2a9 100644
 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
 +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
-@@ -404,7 +404,7 @@ public class CraftEventFactory {
+@@ -509,7 +509,7 @@ public class CraftEventFactory {
                      if (e instanceof EntityExperienceOrb) {
                          EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
                          // Paper start
diff --git a/Spigot-Server-Patches/0219-Ability-to-apply-mending-to-XP-API.patch b/Spigot-Server-Patches/0194-Ability-to-apply-mending-to-XP-API.patch
similarity index 79%
rename from Spigot-Server-Patches/0219-Ability-to-apply-mending-to-XP-API.patch
rename to Spigot-Server-Patches/0194-Ability-to-apply-mending-to-XP-API.patch
index 178fdfeabe..015b6a91c7 100644
--- a/Spigot-Server-Patches/0219-Ability-to-apply-mending-to-XP-API.patch
+++ b/Spigot-Server-Patches/0194-Ability-to-apply-mending-to-XP-API.patch
@@ -1,4 +1,4 @@
-From df166d912b5bec869afcc9174d8536446b786327 Mon Sep 17 00:00:00 2001
+From 773bc84cbbf0f96237d6f806536c5532b340efe1 Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Wed, 20 Dec 2017 17:36:49 -0500
 Subject: [PATCH] Ability to apply mending to XP API
@@ -10,22 +10,26 @@ of giving the player experience points.
 Both an API To standalone mend, and apply mending logic to .giveExp has been added.
 
 diff --git a/src/main/java/net/minecraft/server/EnchantmentManager.java b/src/main/java/net/minecraft/server/EnchantmentManager.java
-index 108ec49aa5..72f0bec4e1 100644
+index 6f64b8db3..b6a40e22a 100644
 --- a/src/main/java/net/minecraft/server/EnchantmentManager.java
 +++ b/src/main/java/net/minecraft/server/EnchantmentManager.java
-@@ -242,6 +242,7 @@ public class EnchantmentManager {
+@@ -241,6 +241,11 @@ public class EnchantmentManager {
          return getEnchantmentLevel(Enchantments.CHANNELING, itemstack) > 0;
      }
  
-+    public static ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, EntityLiving entityliving) { return b(enchantment, entityliving); } // Paper - OBFHELPER
-     public static ItemStack b(Enchantment enchantment, EntityLiving entityliving) {
-         List<ItemStack> list = enchantment.a(entityliving);
- 
++    // Paper - OBFHELPER
++    public static @Nullable ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, EntityLiving entityliving) {
++        Entry<EnumItemSlot, ItemStack> entry = b(enchantment, entityliving);
++        return entry != null ? entry.getValue() : null;
++    }
+     @Nullable
+     public static Entry<EnumItemSlot, ItemStack> b(Enchantment enchantment, EntityLiving entityliving) {
+         Map<EnumItemSlot, ItemStack> map = enchantment.a(entityliving);
 diff --git a/src/main/java/net/minecraft/server/EntityExperienceOrb.java b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
-index 4bcae2c21b..09d85764b0 100644
+index 704a48c8e..64d71a9a2 100644
 --- a/src/main/java/net/minecraft/server/EntityExperienceOrb.java
 +++ b/src/main/java/net/minecraft/server/EntityExperienceOrb.java
-@@ -246,10 +246,12 @@ public class EntityExperienceOrb extends Entity {
+@@ -251,10 +251,12 @@ public class EntityExperienceOrb extends Entity {
          }
      }
  
@@ -39,10 +43,10 @@ index 4bcae2c21b..09d85764b0 100644
          return i * 2;
      }
 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-index dafc2948c0..e6dadde80f 100644
+index bb50ae1ac..bea3ddf31 100644
 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
 +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
-@@ -1026,8 +1026,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+@@ -1052,8 +1052,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
          return GameMode.getByValue(getHandle().playerInteractManager.getGameMode().getId());
      }
  
diff --git a/Spigot-Server-Patches/0222-Make-max-squid-spawn-height-configurable.patch b/Spigot-Server-Patches/0195-Make-max-squid-spawn-height-configurable.patch
similarity index 68%
rename from Spigot-Server-Patches/0222-Make-max-squid-spawn-height-configurable.patch
rename to Spigot-Server-Patches/0195-Make-max-squid-spawn-height-configurable.patch
index be3d9977ee..e4588a599e 100644
--- a/Spigot-Server-Patches/0222-Make-max-squid-spawn-height-configurable.patch
+++ b/Spigot-Server-Patches/0195-Make-max-squid-spawn-height-configurable.patch
@@ -1,4 +1,4 @@
-From aee359f56881e681adaeaf7b2efde9bb243d4d58 Mon Sep 17 00:00:00 2001
+From 2a4121b6db835f78f36e5680d2a2c2bf76767766 Mon Sep 17 00:00:00 2001
 From: Zach Brown <zach.brown@destroystokyo.com>
 Date: Thu, 11 Jan 2018 16:47:28 -0600
 Subject: [PATCH] Make max squid spawn height configurable
@@ -7,12 +7,12 @@ I don't know why upstream made only the minimum height configurable but
 whatever
 
 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 99d6ccc598..07a8ef697f 100644
+index 2a50d6bab..c3e61bdfe 100644
 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
 +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -413,4 +413,9 @@ public class PaperWorldConfig {
-             log("Max Chunk Gens Per Tick: " + maxChunkGensPerTick);
-         }
+@@ -344,4 +344,9 @@ public class PaperWorldConfig {
+         expMergeMaxValue = getInt("experience-merge-max-value", -1);
+         log("Experience Merge Max Value: " + expMergeMaxValue);
      }
 +
 +    public double squidMaxSpawnHeight;
@@ -21,21 +21,19 @@ index 99d6ccc598..07a8ef697f 100644
 +    }
  }
 diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java
-index 1a347bae37..b9c76325db 100644
+index 815844dab..d5dff4b88 100644
 --- a/src/main/java/net/minecraft/server/EntitySquid.java
 +++ b/src/main/java/net/minecraft/server/EntitySquid.java
-@@ -167,7 +167,10 @@ public class EntitySquid extends EntityWaterAnimal {
-     }
+@@ -170,7 +170,8 @@ public class EntitySquid extends EntityWaterAnimal {
  
-     public boolean a(GeneratorAccess generatoraccess, boolean flag) {
+     @Override
+     public boolean a(GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn) {
 -        return this.locY > this.world.spigotConfig.squidSpawnRangeMin && this.locY < (double) generatoraccess.getSeaLevel(); // Spigot
-+        // Paper - Make max spawn height configurable
 +        final double maxHeight = world.paperConfig.squidMaxSpawnHeight > 0 ? world.paperConfig.squidMaxSpawnHeight : world.getSeaLevel();
-+        return this.locY > this.world.spigotConfig.squidSpawnRangeMin && this.locY < maxHeight; // Spigot
-+        // Paper end
++        return this.locY > this.world.spigotConfig.squidSpawnRangeMin && this.locY < maxHeight; // Spigot // Paper
      }
  
-     public void c(float f, float f1, float f2) {
+     public void a(float f, float f1, float f2) {
 -- 
 2.21.0
 
diff --git a/Spigot-Server-Patches/0195-Ocelot-despawns-should-honor-nametags-and-leash.patch b/Spigot-Server-Patches/0195-Ocelot-despawns-should-honor-nametags-and-leash.patch
deleted file mode 100644
index 527dc59e6c..0000000000
--- a/Spigot-Server-Patches/0195-Ocelot-despawns-should-honor-nametags-and-leash.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-From ad5ce22ff3f19ec60b6b8d096b019cedb7964ebb Mon Sep 17 00:00:00 2001
-From: BillyGalbreath <Blake.Galbreath@GMail.com>
-Date: Mon, 31 Jul 2017 01:54:40 -0500
-Subject: [PATCH] Ocelot despawns should honor nametags and leash
-
-
-diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java
-index 47aac5b057..ba074c10c6 100644
---- a/src/main/java/net/minecraft/server/EntityOcelot.java
-+++ b/src/main/java/net/minecraft/server/EntityOcelot.java
-@@ -61,7 +61,7 @@ public class EntityOcelot extends EntityTameableAnimal {
-     }
- 
-     public boolean isTypeNotPersistent() {
--        return !this.isTamed() /*&& this.ticksLived > 2400*/; // CraftBukkit
-+        return !this.isTamed() && !this.hasCustomName() && !this.isLeashed() /*&& this.ticksLived > 2400*/; // CraftBukkit - Paper (honor name and leash)
-     }
- 
-     protected void initAttributes() {
--- 
-2.21.0
-
diff --git a/Spigot-Server-Patches/0220-Configurable-Chunks-Sends-per-Tick-setting.patch b/Spigot-Server-Patches/0220-Configurable-Chunks-Sends-per-Tick-setting.patch
deleted file mode 100644
index 69f2c6cf37..0000000000
--- a/Spigot-Server-Patches/0220-Configurable-Chunks-Sends-per-Tick-setting.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-From c687ba7547ccb45fff41f690dd9b7a66fc1d395e Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Mon, 1 Jan 2018 15:41:59 -0500
-Subject: [PATCH] Configurable Chunks Sends per Tick setting
-
-Vanilla already had this limited, make it configurable.
-
-Limit how much exploration lags the server
-
-diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index c9422d545a..6a8b1c5e03 100644
---- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -393,4 +393,13 @@ public class PaperWorldConfig {
-         expMergeMaxValue = getInt("experience-merge-max-value", -1);
-         log("Experience Merge Max Value: " + expMergeMaxValue);
-     }
-+
-+    public int maxChunkSendsPerTick = 81;
-+    private void maxChunkSendsPerTick() {
-+        maxChunkSendsPerTick = getInt("max-chunk-sends-per-tick", maxChunkSendsPerTick);
-+        if (maxChunkSendsPerTick <= 0) {
-+            maxChunkSendsPerTick = 81;
-+        }
-+        log("Max Chunk Sends Per Tick: " + maxChunkSendsPerTick);
-+    }
- }
-diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index e428d4485b..f481e5a4ff 100644
---- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
-+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -164,7 +164,7 @@ public class PlayerChunkMap {
-         }
- 
-         if (!this.g.isEmpty()) {
--            j = 81;
-+            j = world.paperConfig.maxChunkSendsPerTick; // Paper
-             try (Timing ignored = world.timings.doChunkMapPendingSendToPlayers.startTiming()) { // Paper
-             Iterator iterator2 = this.g.iterator();
- 
--- 
-2.21.0
-
diff --git a/Spigot-Server-Patches/0221-Configurable-Max-Chunk-Gens-per-Tick.patch b/Spigot-Server-Patches/0221-Configurable-Max-Chunk-Gens-per-Tick.patch
deleted file mode 100644
index 85188e3bea..0000000000
--- a/Spigot-Server-Patches/0221-Configurable-Max-Chunk-Gens-per-Tick.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-From 9677c211f1a361076a780405a48c5aaad062f172 Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Mon, 1 Jan 2018 16:10:24 -0500
-Subject: [PATCH] Configurable Max Chunk Gens per Tick
-
-Limit the number of generations that can occur in a single tick, forcing them
-to be spread out more.
-
-Defaulting to 10 as an average generation is going to be 3-6ms, which means 10 will
-likely cause the server to lose TPS, but constrain how much.
-
-This should result in no noticeable speed reduction in generation for servers not
-lagging, and let larger servers reduce this value according to their own desires.
-
-diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-index 6a8b1c5e03..99d6ccc598 100644
---- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
-@@ -402,4 +402,15 @@ public class PaperWorldConfig {
-         }
-         log("Max Chunk Sends Per Tick: " + maxChunkSendsPerTick);
-     }
-+
-+    public int maxChunkGensPerTick = 10;
-+    private void maxChunkGensPerTick() {
-+        maxChunkGensPerTick = getInt("max-chunk-gens-per-tick", maxChunkGensPerTick);
-+        if (maxChunkGensPerTick <= 0) {
-+            maxChunkGensPerTick = Integer.MAX_VALUE;
-+            log("Max Chunk Gens Per Tick: Unlimited (NOT RECOMMENDED)");
-+        } else {
-+            log("Max Chunk Gens Per Tick: " + maxChunkGensPerTick);
-+        }
-+    }
- }
-diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
-index b9d90c4fb8..7d3f846a19 100644
---- a/src/main/java/net/minecraft/server/PlayerChunk.java
-+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
-@@ -21,6 +21,7 @@ public class PlayerChunk {
-     private int h;
-     private long i;
-     private boolean done;
-+    boolean chunkExists; // Paper
- 
-     public PlayerChunk(PlayerChunkMap playerchunkmap, int i, int j) {
-         this.playerChunkMap = playerchunkmap;
-@@ -29,6 +30,7 @@ public class PlayerChunk {
- 
-         chunkproviderserver.a(i, j);
-         this.chunk = chunkproviderserver.getChunkAt(i, j, true, false);
-+        this.chunkExists = this.chunk != null || org.bukkit.craftbukkit.chunkio.ChunkIOExecutor.hasQueuedChunkLoad(playerChunkMap.getWorld(), i, j); // Paper
-         markChunkUsed(); // Paper - delay chunk unloads
-     }
- 
-diff --git a/src/main/java/net/minecraft/server/PlayerChunkMap.java b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-index f481e5a4ff..679488a3cf 100644
---- a/src/main/java/net/minecraft/server/PlayerChunkMap.java
-+++ b/src/main/java/net/minecraft/server/PlayerChunkMap.java
-@@ -132,6 +132,7 @@ public class PlayerChunkMap {
-             // Spigot start
-             org.spigotmc.SlackActivityAccountant activityAccountant = this.world.getMinecraftServer().slackActivityAccountant;
-             activityAccountant.startActivity(0.5);
-+            int chunkGensAllowed = world.paperConfig.maxChunkGensPerTick; // Paper
-             // Spigot end
- 
-             Iterator iterator1 = this.h.iterator();
-@@ -141,6 +142,11 @@ public class PlayerChunkMap {
- 
-                 if (playerchunk1.f() == null) {
-                     boolean flag = playerchunk1.a(PlayerChunkMap.b);
-+                    // Paper start
-+                    if (flag && !playerchunk1.chunkExists && chunkGensAllowed-- <= 0) {
-+                        continue;
-+                    }
-+                    // Paper end
- 
-                     if (playerchunk1.a(flag)) {
-                         iterator1.remove();
-diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
-index 7ffb8f6172..33d5fc7d5e 100644
---- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
-+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java
-@@ -34,4 +34,10 @@ public class ChunkIOExecutor {
-     public static void tick() {
-         instance.finishActive();
-     }
-+
-+    // Paper start
-+    public static boolean hasQueuedChunkLoad(World world, int x, int z) {
-+        return instance.hasTask(new QueuedChunk(x, z, null, world, null));
-+    }
-+    // Paper end
- }
-diff --git a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java b/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
-index 193c3621c6..cf1258c559 100644
---- a/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
-+++ b/src/main/java/org/bukkit/craftbukkit/util/AsynchronousExecutor.java
-@@ -351,4 +351,10 @@ public final class AsynchronousExecutor<P, T, C, E extends Throwable> {
-     public void setActiveThreads(final int coreSize) {
-         pool.setCorePoolSize(coreSize);
-     }
-+
-+    // Paper start
-+    public boolean hasTask(P parameter) throws IllegalStateException {
-+        return tasks.get(parameter) != null;
-+    }
-+    // Paper end
- }
--- 
-2.21.0
-