From 6260d7ba7fc8e1ddfcb64a0cff9d6d89add4ca4a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 23 Jun 2020 04:30:45 -0400
Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b2f1908c SPIGOT-5783: Add helpful info to UnknownDependencyException
e4f46260 SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
529a9a69 SPIGOT-5751: Clarify behaviour of block drop-related API methods

CraftBukkit Changes:
8ea9b138 Remove outdated build delay.
ffc2b251 Revert "#675: Fix redirected CommandNodes sometimes not being properly redirected"
cb701f6b #675: Fix redirected CommandNodes sometimes not being properly redirected
c9d7c16b SPIGOT-2623: Add EntityEquipment methods to get/set ItemStacks by slot.
fad2494a #673: Fix Craftworld#isChunkLoaded
8637ec00 SPIGOT-5751: Made breakNaturally and getDrops returns the correct item if no argument is given

Spigot Changes:
a99063f7 Rebuild patches

Fixes #3602
---
 .../Add-effect-to-block-break-naturally.patch |  2 +-
 ...-Plugin-Tickets-to-API-Chunk-Methods.patch |  8 ++---
 .../Add-effect-to-block-break-naturally.patch |  2 +-
 ...ks-when-attempting-to-unload-a-chunk.patch | 29 -------------------
 Spigot-Server-Patches/POM-Changes.patch       |  2 +-
 ...oleAppender-for-console-improvements.patch |  2 +-
 .../improve-CraftWorld-isChunkLoaded.patch    |  3 +-
 paper                                         |  7 +++++
 work/Bukkit                                   |  2 +-
 work/CraftBukkit                              |  2 +-
 work/Spigot                                   |  2 +-
 11 files changed, 19 insertions(+), 42 deletions(-)
 delete mode 100644 Spigot-Server-Patches/Don-t-load-chunks-when-attempting-to-unload-a-chunk.patch

diff --git a/Spigot-API-Patches/Add-effect-to-block-break-naturally.patch b/Spigot-API-Patches/Add-effect-to-block-break-naturally.patch
index c86f74b5b2..01ae314d0a 100644
--- a/Spigot-API-Patches/Add-effect-to-block-break-naturally.patch
+++ b/Spigot-API-Patches/Add-effect-to-block-break-naturally.patch
@@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +++ b/src/main/java/org/bukkit/block/Block.java
 @@ -0,0 +0,0 @@ public interface Block extends Metadatable {
       */
-     boolean breakNaturally(@NotNull ItemStack tool);
+     boolean breakNaturally(@Nullable ItemStack tool);
  
 +    // Paper start
 +    /**
diff --git a/Spigot-Server-Patches/Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/Spigot-Server-Patches/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
index 745c2b16fe..c8bc1e5932 100644
--- a/Spigot-Server-Patches/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
+++ b/Spigot-Server-Patches/Add-Plugin-Tickets-to-API-Chunk-Methods.patch
@@ -72,11 +72,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
      public Chunk getChunkAt(Block block) {
          Preconditions.checkArgument(block != null, "null block");
 @@ -0,0 +0,0 @@ public class CraftWorld implements World {
+     public boolean unloadChunkRequest(int x, int z) {
          org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
-         net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAtIfLoadedImmediately(x, z); // Paper
-         if (chunk != null) {
--            world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE);
-+            world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 0, Unit.INSTANCE); // Paper
+         if (isChunkLoaded(x, z)) {
+-            world.getChunkProvider().removeTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 1, Unit.INSTANCE);
++            world.getChunkProvider().removeTicket(TicketType.PLUGIN, new ChunkCoordIntPair(x, z), 0, Unit.INSTANCE); // Paper
          }
  
          return true;
diff --git a/Spigot-Server-Patches/Add-effect-to-block-break-naturally.patch b/Spigot-Server-Patches/Add-effect-to-block-break-naturally.patch
index 6ac0e0adc2..cf767a46d0 100644
--- a/Spigot-Server-Patches/Add-effect-to-block-break-naturally.patch
+++ b/Spigot-Server-Patches/Add-effect-to-block-break-naturally.patch
@@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          net.minecraft.server.Block block = iblockdata.getBlock();
 @@ -0,0 +0,0 @@ public class CraftBlock implements Block {
          // Modelled off EntityHuman#hasBlock
-         if (block != Blocks.AIR && (iblockdata.getMaterial().isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) {
+         if (block != Blocks.AIR && (item == null || iblockdata.getMaterial().isAlwaysDestroyable() || nmsItem.canDestroySpecialBlock(iblockdata))) {
              net.minecraft.server.Block.dropItems(iblockdata, world.getMinecraftWorld(), position, world.getTileEntity(position), null, nmsItem);
 +            if (triggerEffect) world.triggerEffect(org.bukkit.Effect.STEP_SOUND.getId(), position, net.minecraft.server.Block.getCombinedId(block.getBlockData())); // Paper
              result = true;
diff --git a/Spigot-Server-Patches/Don-t-load-chunks-when-attempting-to-unload-a-chunk.patch b/Spigot-Server-Patches/Don-t-load-chunks-when-attempting-to-unload-a-chunk.patch
deleted file mode 100644
index c1dd5c185e..0000000000
--- a/Spigot-Server-Patches/Don-t-load-chunks-when-attempting-to-unload-a-chunk.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Aikar <aikar@aikar.co>
-Date: Wed, 8 Apr 2020 21:07:08 -0400
-Subject: [PATCH] Don't load chunks when attempting to unload a chunk
-
-Big Brain Logic
-
-diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
-@@ -0,0 +0,0 @@ public class CraftWorld implements World {
-     @Override
-     public boolean unloadChunkRequest(int x, int z) {
-         org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
--        net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
-+        net.minecraft.server.IChunkAccess chunk = world.getChunkProvider().getChunkAtIfLoadedImmediately(x, z); // Paper
-         if (chunk != null) {
-             world.getChunkProvider().removeTicket(TicketType.PLUGIN, chunk.getPos(), 1, Unit.INSTANCE);
-         }
-@@ -0,0 +0,0 @@ public class CraftWorld implements World {
- 
-     private boolean unloadChunk0(int x, int z, boolean save) {
-         org.spigotmc.AsyncCatcher.catchOp("chunk unload"); // Spigot
--        net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk) world.getChunkProvider().getChunkAt(x, z, ChunkStatus.FULL, false);
-+        net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAtIfLoadedImmediately(x, z); // Paper
-         if (chunk == null) {
-             return true;
-         }
diff --git a/Spigot-Server-Patches/POM-Changes.patch b/Spigot-Server-Patches/POM-Changes.patch
index 33301b8118..28508323ff 100644
--- a/Spigot-Server-Patches/POM-Changes.patch
+++ b/Spigot-Server-Patches/POM-Changes.patch
@@ -196,7 +196,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 @@ -0,0 +0,0 @@ public class Main {
                  }
  
-                 if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
+                 if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
 -                    Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
 +                    Date buildDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(Main.class.getPackage().getImplementationVendor()); // Paper
  
diff --git a/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch b/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch
index bf78f66354..a42f1c07b0 100644
--- a/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch
+++ b/Spigot-Server-Patches/Use-TerminalConsoleAppender-for-console-improvements.patch
@@ -325,7 +325,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +                    System.setProperty(TerminalConsoleAppender.JLINE_OVERRIDE_PROPERTY, "false"); // Paper
                  }
  
-                 if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
+                 if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
 @@ -0,0 +0,0 @@ public class Main {
                      System.out.println("Unable to read system info");
                  }
diff --git a/Spigot-Server-Patches/improve-CraftWorld-isChunkLoaded.patch b/Spigot-Server-Patches/improve-CraftWorld-isChunkLoaded.patch
index 9a9aefe365..013b83f911 100644
--- a/Spigot-Server-Patches/improve-CraftWorld-isChunkLoaded.patch
+++ b/Spigot-Server-Patches/improve-CraftWorld-isChunkLoaded.patch
@@ -16,8 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      @Override
      public boolean isChunkLoaded(int x, int z) {
--        net.minecraft.server.Chunk chunk = world.getChunkProvider().getChunkAt(x, z, false);
--        return chunk != null;
+-        return world.getChunkProvider().isChunkLoaded(x, z);
 +        return world.getChunkProvider().getChunkAtIfLoadedImmediately(x, z) != null; // Paper
      }
  
diff --git a/paper b/paper
index 687c3813e6..6106243b08 100755
--- a/paper
+++ b/paper
@@ -129,6 +129,13 @@ case "$1" in
         rm -rf work
         echo "Cleaned build files"
     ;;
+    "con" | "continue")
+        if [ -d ".git/rebase-apply" ]; then
+            git -c commit.gpgsign=false am --continue
+        elif [ -d ".git/rebase-merge" ]; then
+            git -c commit.gpgsign=false rebase --continue
+        fi
+    ;;
     "e" | "edit")
         case "$2" in
             "s" | "server")
diff --git a/work/Bukkit b/work/Bukkit
index e269963640..b2f1908c59 160000
--- a/work/Bukkit
+++ b/work/Bukkit
@@ -1 +1 @@
-Subproject commit e2699636407094a6e25843907291cde511fbb19d
+Subproject commit b2f1908c59d22a693ee7ef10f480081436145251
diff --git a/work/CraftBukkit b/work/CraftBukkit
index 1b2830a3b3..8ea9b1386b 160000
--- a/work/CraftBukkit
+++ b/work/CraftBukkit
@@ -1 +1 @@
-Subproject commit 1b2830a3b3aa5ecf4d2f44696654fc028a2c53a0
+Subproject commit 8ea9b1386bc7f131c3df3ed0b87b49a5a3e811ba
diff --git a/work/Spigot b/work/Spigot
index 2f5d615f15..a99063f771 160000
--- a/work/Spigot
+++ b/work/Spigot
@@ -1 +1 @@
-Subproject commit 2f5d615f157752a2b28b0986b34cc708d5e77674
+Subproject commit a99063f77142a462546e31413de6c6190e913f11