From a0e810eaf976e9c2ef86bb68345b28576e5212c6 Mon Sep 17 00:00:00 2001
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
Date: Sun, 31 Aug 2014 13:56:05 -0500
Subject: [PATCH] Rebase (Update) from upstream SpigotMC Don't send requests of
every player was found in the global api cache
SpigotMC/Spigot@841270ff1ee8f22fe9d83f7e1c25325882c4930b Correctly set the
response code for the cached lookups and return the ...
SpigotMC/Spigot@f170b7899c0351a4230cd73820280a1afb051053 Don't try and re-set
the global api cache on reload
SpigotMC/Spigot@b410a00a66a78fb6c908af13a29f9881933d5dac Use a compile time
sneaky throw hack. SpigotMC/Spigot@508462b96b96b9ac5881c188829563c56b2ecc69
Fix a missed rename in WorldGenGroundBush
SpigotMC/Spigot@0614d8fae98c9f4dd17ae77f2bccaec763838478
---
...Undeprecate-Player-updateInventory-V.patch | 4 +-
CraftBukkit-Patches/0002-mc-dev-imports.patch | 39 +++++------
...r-a-global-cache-for-any-request-on-.patch | 64 +++++++++++++------
...-missed-rename-in-WorldGenGroundBush.patch | 20 ++++++
4 files changed, 88 insertions(+), 39 deletions(-)
create mode 100644 CraftBukkit-Patches/0178-Fix-a-missed-rename-in-WorldGenGroundBush.patch
diff --git a/Bukkit-Patches/0029-Undeprecate-Player-updateInventory-V.patch b/Bukkit-Patches/0029-Undeprecate-Player-updateInventory-V.patch
index c7ba2c081..6a596fbad 100644
--- a/Bukkit-Patches/0029-Undeprecate-Player-updateInventory-V.patch
+++ b/Bukkit-Patches/0029-Undeprecate-Player-updateInventory-V.patch
@@ -20,4 +20,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void updateInventory();
/**
---
\ No newline at end of file
+--
+1.8.4.2
+
diff --git a/CraftBukkit-Patches/0002-mc-dev-imports.patch b/CraftBukkit-Patches/0002-mc-dev-imports.patch
index eba9d560f..ea0ba618a 100644
--- a/CraftBukkit-Patches/0002-mc-dev-imports.patch
+++ b/CraftBukkit-Patches/0002-mc-dev-imports.patch
@@ -5,24 +5,6 @@ Subject: [PATCH] mc-dev imports
Imported files which are only modified by Spigot, not upstream. Files here should be completely unmodified aside from trivial changes such as adding throws statements to ensure proper compilation. You may need to add unrelated files in order to ensure a compilable result in the face of synthetic methods.
-diff --git a/pom.xml b/pom.xml
-index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
---- a/pom.xml
-+++ b/pom.xml
-@@ -0,0 +0,0 @@
- 1.3
- test
-
-+
-+ org.spigotmc
-+ sneaky-throw
-+ 1.0
-+ system
-+ ${project.basedir}/../SneakyThrow.jar
-+
-
-
-
diff --git a/src/main/java/net/minecraft/server/AttributeRanged.java b/src/main/java/net/minecraft/server/AttributeRanged.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
@@ -4212,6 +4194,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return new WorldGenVillageStart(this.c, this.b, i, j, this.f);
+ }
+}
+diff --git a/src/main/java/org/spigotmc/SneakyThrow.java b/src/main/java/org/spigotmc/SneakyThrow.java
+new file mode 100644
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
+--- /dev/null
++++ b/src/main/java/org/spigotmc/SneakyThrow.java
+@@ -0,0 +0,0 @@
++package org.spigotmc;
++
++public class SneakyThrow
++{
++
++ public static void sneaky(Throwable t)
++ {
++ throw SneakyThrow.superSneaky( t );
++ }
++
++ private static T superSneaky(Throwable t) throws T
++ {
++ throw (T) t;
++ }
++}
diff --git a/src/main/resources/org/spigotmc/SneakyThrow.class b/src/main/resources/org/spigotmc/SneakyThrow.class
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
diff --git a/CraftBukkit-Patches/0164-Add-an-option-for-a-global-cache-for-any-request-on-.patch b/CraftBukkit-Patches/0164-Add-an-option-for-a-global-cache-for-any-request-on-.patch
index 99f6733a0..c224be9f8 100644
--- a/CraftBukkit-Patches/0164-Add-an-option-for-a-global-cache-for-any-request-on-.patch
+++ b/CraftBukkit-Patches/0164-Add-an-option-for-a-global-cache-for-any-request-on-.patch
@@ -38,6 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private final Proxy proxy;
+ private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ private ByteArrayInputStream inputStream;
++ private InputStream errorStream;
+ private boolean outClosed = false;
+
+ private static final Cache cache = CacheBuilder.newBuilder()
@@ -95,37 +96,57 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ .append( "," );
+ }
+ }
-+ missingUsers.deleteCharAt( missingUsers.length() - 1 ).append( "]" );
-+ HttpURLConnection connection;
-+ if ( proxy == null )
++ if ( missingUsers.length() > 1 )
+ {
-+ connection = (HttpURLConnection) cachedStreamHandler.getDefaultConnection( url );
++ missingUsers.deleteCharAt( missingUsers.length() - 1 ).append( "]" );
++ }
++ if ( missingUsers.length() > 2 )
++ {
++ HttpURLConnection connection;
++ if ( proxy == null )
++ {
++ connection = (HttpURLConnection) cachedStreamHandler.getDefaultConnection( url );
++ } else
++ {
++ connection = (HttpURLConnection) cachedStreamHandler.getDefaultConnection( url, proxy );
++ }
++ connection.setRequestMethod( "POST" );
++ connection.setRequestProperty( "Content-Type", "application/json" );
++ connection.setDoInput( true );
++ connection.setDoOutput( true );
++ OutputStream out = connection.getOutputStream();
++ out.write( missingUsers.toString().getBytes( Charsets.UTF_8 ) );
++ out.flush();
++ out.close();
++ JsonArray newUsers = new JsonParser().parse( new InputStreamReader( connection.getInputStream(), Charsets.UTF_8 ) ).getAsJsonArray();
++ for ( JsonElement user : newUsers )
++ {
++ JsonObject u = user.getAsJsonObject();
++ cache.put( u.get( "name" ).getAsString(), u.toString() );
++ reply.append( u.toString() ).append( "," );
++ }
++ responseCode = connection.getResponseCode();
++ errorStream = connection.getErrorStream();
+ } else
+ {
-+ connection = (HttpURLConnection) cachedStreamHandler.getDefaultConnection( url, proxy );
++ responseCode = HTTP_OK;
+ }
-+ connection.setRequestMethod( "POST" );
-+ connection.setRequestProperty( "Content-Type", "application/json" );
-+ connection.setDoInput( true );
-+ connection.setDoOutput( true );
-+ OutputStream out = connection.getOutputStream();
-+ out.write( missingUsers.toString().getBytes( Charsets.UTF_8 ) );
-+ out.flush();
-+ out.close();
-+ JsonArray newUsers = new JsonParser().parse( new InputStreamReader( connection.getInputStream(), Charsets.UTF_8 ) ).getAsJsonArray();
-+ for ( JsonElement user : newUsers )
++ if ( reply.length() > 1 )
+ {
-+ JsonObject u = user.getAsJsonObject();
-+ cache.put( u.get( "name" ).getAsString(), u.toString() );
-+ reply.append( u.toString() ).append( "," );
++ reply.deleteCharAt( reply.length() - 1 );
+ }
-+ reply.deleteCharAt( reply.length() - 1 );
+ inputStream = new ByteArrayInputStream( reply.append( "]" ).toString().getBytes( Charsets.UTF_8 ) );
+ }
+ return inputStream;
+ }
+
+ @Override
++ public InputStream getErrorStream()
++ {
++ return errorStream;
++ }
++
++ @Override
+ public OutputStream getOutputStream() throws IOException
+ {
+ if ( outClosed )
@@ -154,6 +175,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+public class CachedStreamHandlerFactory implements URLStreamHandlerFactory
+{
++ public static boolean isSet = false;
++
+ @Override
+ public URLStreamHandler createURLStreamHandler(String protocol)
+ {
@@ -275,10 +298,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ private static void globalAPICache()
+ {
-+ if ( getBoolean( "settings.global-api-cache", false ) )
++ if ( getBoolean( "settings.global-api-cache", false ) && !CachedStreamHandlerFactory.isSet )
+ {
+ Bukkit.getLogger().info( "Global API cache enabled - All requests to Mojang's API will be " +
+ "handled by Spigot" );
++ CachedStreamHandlerFactory.isSet = true;
+ URL.setURLStreamHandlerFactory(new CachedStreamHandlerFactory());
+ }
+ }
diff --git a/CraftBukkit-Patches/0178-Fix-a-missed-rename-in-WorldGenGroundBush.patch b/CraftBukkit-Patches/0178-Fix-a-missed-rename-in-WorldGenGroundBush.patch
new file mode 100644
index 000000000..cdd6e7412
--- /dev/null
+++ b/CraftBukkit-Patches/0178-Fix-a-missed-rename-in-WorldGenGroundBush.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Thinkofdeath
+Date: Sat, 30 Aug 2014 18:36:32 +0100
+Subject: [PATCH] Fix a missed rename in WorldGenGroundBush
+
+
+diff --git a/src/main/java/net/minecraft/server/WorldGenGroundBush.java b/src/main/java/net/minecraft/server/WorldGenGroundBush.java
+index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/server/WorldGenGroundBush.java
++++ b/src/main/java/net/minecraft/server/WorldGenGroundBush.java
+@@ -0,0 +0,0 @@ public class WorldGenGroundBush extends WorldGenTrees {
+ this.a = j;
+ }
+
+- public boolean a(World world, Random random, int i, int j, int k) {
++ public boolean generate(World world, Random random, int i, int j, int k) { // Spigot
+ Block block;
+
+ while (((block = world.getType(i, j, k)).getMaterial() == Material.AIR || block.getMaterial() == Material.LEAVES) && j > 0) {
+--
\ No newline at end of file