From d30162681565df295c3fbf3c459271026c52eaa6 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com>
Date: Fri, 15 Aug 2014 14:35:58 -0500
Subject: [PATCH] Update from upstream SpigotMC Fix Corrupted Trapped Chests
 SpigotMC/Spigot@08de30ca3e031224947742a6ecde18bbad3e9d31 Don't time async
 events SpigotMC/Spigot@c3a9e71da35f319fe47538c53f209426d9ed58d6

---
 Bukkit-Patches/0002-Spigot-Timings.patch      | 15 ++++++-----
 .../0174-Fix-Corrupted-Trapped-Chest.patch    | 26 +++++++++++++++++++
 2 files changed, 35 insertions(+), 6 deletions(-)
 create mode 100644 CraftBukkit-Patches/0174-Fix-Corrupted-Trapped-Chest.patch

diff --git a/Bukkit-Patches/0002-Spigot-Timings.patch b/Bukkit-Patches/0002-Spigot-Timings.patch
index e62d19f759..1a8f448f8f 100644
--- a/Bukkit-Patches/0002-Spigot-Timings.patch
+++ b/Bukkit-Patches/0002-Spigot-Timings.patch
@@ -1,4 +1,4 @@
-From 1a8060d85c71cd9047243fd1fb8d8484601abf99 Mon Sep 17 00:00:00 2001
+From 8436d82f19ccc283c93fa2a2a2df7621437dd5ae Mon Sep 17 00:00:00 2001
 From: Aikar <aikar@aikar.co>
 Date: Sun, 2 Jun 2013 10:42:57 +1000
 Subject: [PATCH] Spigot Timings
@@ -242,7 +242,7 @@ index d2fe422..1d51908 100644
      }
  
 diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
-index b178c0d..6611342 100644
+index b178c0d..fe723c9 100644
 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
 +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
 @@ -39,6 +39,7 @@ import org.bukkit.plugin.PluginLoader;
@@ -261,7 +261,7 @@ index b178c0d..6611342 100644
  
      /**
       * This class was not meant to be constructed explicitly
-@@ -283,13 +285,16 @@ public final class JavaPluginLoader implements PluginLoader {
+@@ -283,13 +285,19 @@ public final class JavaPluginLoader implements PluginLoader {
                  }
              }
  
@@ -272,13 +272,16 @@ index b178c0d..6611342 100644
                          if (!eventClass.isAssignableFrom(event.getClass())) {
                              return;
                          }
-+                        timings.startTiming(); // Spigot
++                        // Spigot start
++                        boolean isAsync = event.isAsynchronous();
++                        if (!isAsync) timings.startTiming();
                          method.invoke(listener, event);
-+                        timings.stopTiming(); // Spigot
++                        if (!isAsync) timings.stopTiming();
++                        // Spigot end
                      } catch (InvocationTargetException ex) {
                          throw new EventException(ex.getCause());
                      } catch (Throwable t) {
-@@ -297,7 +302,7 @@ public final class JavaPluginLoader implements PluginLoader {
+@@ -297,7 +305,7 @@ public final class JavaPluginLoader implements PluginLoader {
                      }
                  }
              };
diff --git a/CraftBukkit-Patches/0174-Fix-Corrupted-Trapped-Chest.patch b/CraftBukkit-Patches/0174-Fix-Corrupted-Trapped-Chest.patch
new file mode 100644
index 0000000000..e78e4a274b
--- /dev/null
+++ b/CraftBukkit-Patches/0174-Fix-Corrupted-Trapped-Chest.patch
@@ -0,0 +1,26 @@
+From baa91fa0bb4aee82819f9ccb4aa2f6c8889365ca Mon Sep 17 00:00:00 2001
+From: Aikar <aikar@aikar.co>
+Date: Fri, 15 Aug 2014 00:56:41 -0400
+Subject: [PATCH] Fix Corrupted Trapped Chest
+
+The CraftBukkit code that auto repairs corrupted tile entities never was updated for Trapped Chest.
+If a Trapped Chest gets its Tile Entity corrupted, it will crash the server every time the chunk is loaded.
+
+This will now fix Trapped Chests too.
+
+diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
+index d93eb8b..f9dc0fc 100644
+--- a/src/main/java/net/minecraft/server/WorldServer.java
++++ b/src/main/java/net/minecraft/server/WorldServer.java
+@@ -87,7 +87,7 @@ public class WorldServer extends World {
+         TileEntity result = super.getTileEntity(i, j, k);
+         Block type = getType(i, j, k);
+ 
+-        if (type == Blocks.CHEST) {
++        if (type == Blocks.CHEST || type == Blocks.TRAPPED_CHEST) { // Spigot
+             if (!(result instanceof TileEntityChest)) {
+                 result = fixTileEntity(i, j, k, type, result);
+             }
+-- 
+1.9.1
+