SPIGOT-522: Remove the global api cache option

This was useful when plugins first started upgrading to uuid because each
plugin would implement their own way for grabbing uuid's from mojang. Because
none of them shared the result they would quickly hit the limits on the api
causing the conversion to either fail or pause for long periods of time. The
global api cache was a (very hacky) way to force all plugins to share a cache
but caused a few issues with plugins that expected a full implementation of
the HTTPURLConnection. Due to the fact that most servers/plugins have updated
now it seems to be a good time to remove this as its usefulness mostly has
expired.
This commit is contained in:
Thinkofdeath 2015-02-06 10:08:31 +00:00 committed by Zach
parent ddb3f1daa3
commit 461353e2cb
32 changed files with 82 additions and 394 deletions

View File

@ -1,4 +1,4 @@
From 66d4c61becd3e269beb5b6896c019ce508908ac6 Mon Sep 17 00:00:00 2001
From 992fa59ab974b0247d71f5df8f14ea14d0b61c20 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 2 Jun 2013 15:57:09 +1000
Subject: [PATCH] Add Particle API
@ -271,10 +271,10 @@ index 2474a2d..37f29e2 100644
+ public enum Type {SOUND, VISUAL, PARTICLE}
}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 828d228..af3d3c4 100644
index c763abe..e3c6ef4 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -1167,6 +1167,56 @@ public interface World extends PluginMessageRecipient, Metadatable {
@@ -1170,6 +1170,56 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean isGameRule(String rule);

View File

@ -1,14 +1,14 @@
From dddf63f99fe12e810fec21e34b24dadbc4e2f6ab Mon Sep 17 00:00:00 2001
From 3a923e0e77a0d3c1670e90a01188a2bccbd476e8 Mon Sep 17 00:00:00 2001
From: drXor <mcyoungsota@gmail.com>
Date: Sun, 23 Feb 2014 16:16:29 -0400
Subject: [PATCH] Silenceable Lightning API
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index af3d3c4..1688943 100644
index e3c6ef4..4f05aa7 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -1212,6 +1212,30 @@ public interface World extends PluginMessageRecipient, Metadatable {
@@ -1215,6 +1215,30 @@ public interface World extends PluginMessageRecipient, Metadatable {
{
throw new UnsupportedOperationException( "Not supported yet." );
}

View File

@ -1,4 +1,4 @@
From ab476d816607afbd11988be3f340b97f31621b2a Mon Sep 17 00:00:00 2001
From 6181b9fe69fce239f2b0407f0ee379715a388f3f Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Mon, 14 Apr 2014 10:38:04 +1000
Subject: [PATCH] Obfuscation Helpers
@ -6,10 +6,10 @@ Subject: [PATCH] Obfuscation Helpers
Provides several friendly named methods which map to a obfuscated method. Obfuscated methods which are used frequently should be added to this file to ease with updates to new Minecraft versions.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index fe25804..5e53661 100644
index ff1b38a..392b895 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1294,6 +1294,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -1298,6 +1298,12 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
}

View File

@ -1,4 +1,4 @@
From 6df3453869ca09397fb5aa4cf8a2b07241297082 Mon Sep 17 00:00:00 2001
From 29c05c2c47f5a655cf0e5aa4131ca33c891ec256 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 10 Jan 2013 00:18:11 -0500
Subject: [PATCH] Spigot Timings
@ -242,7 +242,7 @@ index d2a0954..71e1e6e 100644
this.world.methodProfiler.b();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5e53661..49429d7 100644
index 392b895..072559e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -45,6 +45,7 @@ import joptsimple.OptionSet;
@ -283,7 +283,7 @@ index 5e53661..49429d7 100644
}
public void z() {
@@ -649,16 +655,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -653,16 +659,23 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
this.methodProfiler.c("levels");
@ -307,7 +307,7 @@ index 5e53661..49429d7 100644
// Send time updates to everyone, it will get the right time from the world the player is in.
if (this.ticks % 20 == 0) {
for (int i = 0; i < this.getPlayerList().players.size(); ++i) {
@@ -666,6 +679,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -670,6 +683,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(entityplayer.world.getTime(), entityplayer.getPlayerTime(), entityplayer.world.getGameRules().getBoolean("doDaylightCycle"))); // Add support for per player time
}
}
@ -315,7 +315,7 @@ index 5e53661..49429d7 100644
int i;
@@ -689,7 +703,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -693,7 +707,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
CrashReport crashreport;
try {
@ -325,7 +325,7 @@ index 5e53661..49429d7 100644
} catch (Throwable throwable1) {
crashreport = CrashReport.a(throwable1, "Exception ticking world");
worldserver.a(crashreport);
@@ -697,7 +713,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -701,7 +717,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
}
try {
@ -335,7 +335,7 @@ index 5e53661..49429d7 100644
} catch (Throwable throwable2) {
crashreport = CrashReport.a(throwable2, "Exception ticking world entities");
worldserver.a(crashreport);
@@ -706,7 +724,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -710,7 +728,9 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
this.methodProfiler.b();
this.methodProfiler.a("tracker");
@ -345,7 +345,7 @@ index 5e53661..49429d7 100644
this.methodProfiler.b();
this.methodProfiler.b();
// } // CraftBukkit
@@ -715,14 +735,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -719,14 +739,20 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
}
this.methodProfiler.c("connection");

View File

@ -1,14 +1,14 @@
From b4306dcb539d3b55885f8c9b82fff57093e56f78 Mon Sep 17 00:00:00 2001
From 7340408d6585299ec6f8eaa21f41f5afc26aa1ee Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Mon, 4 Mar 2013 18:45:52 +1100
Subject: [PATCH] PlayerItemDamageEvent
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 0502bcb..204ae01 100644
index 0457ede..3e0d808 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -305,6 +305,11 @@ public final class ItemStack {
@@ -323,6 +323,11 @@ public final class ItemStack {
}
public boolean isDamaged(int i, Random random) {
@ -20,7 +20,7 @@ index 0502bcb..204ae01 100644
if (!this.e()) {
return false;
} else {
@@ -319,7 +324,16 @@ public final class ItemStack {
@@ -337,7 +342,16 @@ public final class ItemStack {
}
i -= k;
@ -38,7 +38,7 @@ index 0502bcb..204ae01 100644
return false;
}
}
@@ -332,7 +346,7 @@ public final class ItemStack {
@@ -350,7 +364,7 @@ public final class ItemStack {
public void damage(int i, EntityLiving entityliving) {
if (!(entityliving instanceof EntityHuman) || !((EntityHuman) entityliving).abilities.canInstantlyBuild) {
if (this.e()) {

View File

@ -1,4 +1,4 @@
From a04f9c5ed261f87073902b047999ef2ab889e5ec Mon Sep 17 00:00:00 2001
From 3e0d4f9c080db7ca0ef0059d6f57c9b8c92a1fe5 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 19:21:58 +1000
Subject: [PATCH] Configurable Messages
@ -23,10 +23,10 @@ index f8bac48..e036bc6 100644
this.b.close(chatcomponenttext);
} else {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 6d8df63..fad41c2 100644
index 6ce88ca..ee2172d 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -379,7 +379,7 @@ public abstract class PlayerList {
@@ -388,7 +388,7 @@ public abstract class PlayerList {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, s);
} else if (!this.isWhitelisted(gameprofile)) {
// return "You are not white-listed on this server!";
@ -35,7 +35,7 @@ index 6d8df63..fad41c2 100644
} else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.l.get(socketaddress);
@@ -393,7 +393,7 @@ public abstract class PlayerList {
@@ -402,7 +402,7 @@ public abstract class PlayerList {
} else {
// return this.players.size() >= this.maxPlayers ? "The server is full!" : null;
if (this.players.size() >= this.maxPlayers) {

View File

@ -1,4 +1,4 @@
From 8b42dfb535896005418744a289fa89140c388497 Mon Sep 17 00:00:00 2001
From 27d70b3b78bff6f102233cbf6d91f5686f1caba9 Mon Sep 17 00:00:00 2001
From: Alex Ciuba <alexciuba@gmail.com>
Date: Tue, 11 Jun 2013 15:23:03 -0400
Subject: [PATCH] Prevent Ghost Players Caused by Plugins
@ -6,10 +6,10 @@ Subject: [PATCH] Prevent Ghost Players Caused by Plugins
Check if the player is still connected after firing event. Fixes BUKKIT-4327
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index fad41c2..b370b6d 100644
index ee2172d..aeb5ee4 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -506,6 +506,11 @@ public abstract class PlayerList {
@@ -515,6 +515,11 @@ public abstract class PlayerList {
Player respawnPlayer = cserver.getPlayer(entityplayer1);
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
cserver.getPluginManager().callEvent(respawnEvent);

View File

@ -1,4 +1,4 @@
From 4b2d54406c33c04c83feee237533eda052a001dc Mon Sep 17 00:00:00 2001
From 8990c2a7f271fd7e9b64c1a8316c9804aa77eb45 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 1 Dec 2013 18:18:41 +1100
Subject: [PATCH] BungeeCord Support
@ -119,10 +119,10 @@ index 97920b0..0b86011 100644
this.d = EnumProtocol.a(packetdataserializer.e());
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index b370b6d..fdb4b3c 100644
index aeb5ee4..cfdaea2 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -364,7 +364,7 @@ public abstract class PlayerList {
@@ -373,7 +373,7 @@ public abstract class PlayerList {
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), gameprofile, new PlayerInteractManager(server.getWorldServer(0)));
Player player = entity.getBukkitEntity();

View File

@ -1,4 +1,4 @@
From 15c185d1e7b721f1b6ee9ae1ad34da1eb43b6b4d Mon Sep 17 00:00:00 2001
From 8c7e514a2e848e8965c974934bfbf5d96d9012f0 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 13 Dec 2013 11:58:58 +1100
Subject: [PATCH] Configurable Amount of Netty Threads
@ -6,7 +6,7 @@ Subject: [PATCH] Configurable Amount of Netty Threads
This brings back the option that the Spigot version of netty saw. By default Netty will try and use cores*2 threads, however if running multiple servers on the same machine, this can be too many threads. Additionally some people have 16 core servers. If 32 Netty threads are allowed in this setup, then the lock contention, and thus blocking between threads becomes much greater, leading to decreased performance.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 2fa1626..abef561 100644
index 9cdb2fb..e54a72b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -61,7 +61,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@ -27,7 +27,7 @@ index 2fa1626..abef561 100644
this.Z = new UserCache(this, file1);
this.p = this.h();
// this.convertable = new WorldLoaderServer(file); // CraftBukkit - moved to DedicatedServer.init
@@ -1329,7 +1329,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -1333,7 +1333,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
}
// Spigot End
public ServerConnection ao() {

View File

@ -1,14 +1,14 @@
From 687b9034da295f5f73a587e926cea6bdbae5a14b Mon Sep 17 00:00:00 2001
From 5fcbd44f2fec14fbf432c011c81867e18f0d6dc4 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 10 Jan 2014 15:15:50 +1100
Subject: [PATCH] Fix ItemStack Unbreakable Code
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
index 204ae01..a00c3f4 100644
index 3e0d808..596db09 100644
--- a/src/main/java/net/minecraft/server/ItemStack.java
+++ b/src/main/java/net/minecraft/server/ItemStack.java
@@ -252,7 +252,13 @@ public final class ItemStack {
@@ -270,7 +270,13 @@ public final class ItemStack {
}
public boolean e() {

View File

@ -1,14 +1,14 @@
From 38335859827f906d56c01a393617dd0c7657ef2c Mon Sep 17 00:00:00 2001
From 6c4c7dafa44b36d83dbdf021021ebff2e6474434 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 12 Jan 2014 20:56:41 +1100
Subject: [PATCH] Try and Debug Crash Reports Crashing
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a8bab04..7ce37c0 100644
index 520434e..131b872 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -715,7 +715,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -719,7 +719,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
worldserver.doTick();
worldserver.timings.doTick.stopTiming(); // Spigot
} catch (Throwable throwable1) {
@ -22,7 +22,7 @@ index a8bab04..7ce37c0 100644
worldserver.a(crashreport);
throw new ReportedException(crashreport);
}
@@ -725,7 +731,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -729,7 +735,13 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
worldserver.tickEntities();
worldserver.timings.tickEntities.stopTiming(); // Spigot
} catch (Throwable throwable2) {

View File

@ -1,14 +1,14 @@
From aa5ad03334792e42180430130d71e2eab671db50 Mon Sep 17 00:00:00 2001
From c20de67c341941215e431d126a920b379da92952 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 26 Jan 2014 21:48:34 +1100
Subject: [PATCH] Configurable Ping Sample Size
diff --git a/src/main/java/net/minecraft/server/PacketStatusListener.java b/src/main/java/net/minecraft/server/PacketStatusListener.java
index 22749e7..8327d0c 100644
index 939907b..17d37ac 100644
--- a/src/main/java/net/minecraft/server/PacketStatusListener.java
+++ b/src/main/java/net/minecraft/server/PacketStatusListener.java
@@ -100,6 +100,13 @@ public class PacketStatusListener implements PacketStatusInListener {
@@ -113,6 +113,13 @@ public class PacketStatusListener implements PacketStatusInListener {
}
ServerPingPlayerSample playerSample = new ServerPingPlayerSample(event.getMaxPlayers(), profiles.size());

View File

@ -1,4 +1,4 @@
From 9293172464819467adb51bef352f4cf549550b78 Mon Sep 17 00:00:00 2001
From 1cbaf47c2abbfbe4f6d78e513b9fe641d290ddf8 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Fri, 11 Apr 2014 11:16:34 +0100
Subject: [PATCH] Display 'Spigot' in client crashes, server lists and Mojang
@ -6,10 +6,10 @@ Subject: [PATCH] Display 'Spigot' in client crashes, server lists and Mojang
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d213ae4..8521259 100644
index b72c4e2..52dd494 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1038,7 +1038,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
@@ -1042,7 +1042,7 @@ public abstract class MinecraftServer implements ICommandListener, Runnable, IAs
}
public String getServerModName() {

View File

@ -1,14 +1,14 @@
From 1ac757efee70086ed46d638f69360780980e0dd3 Mon Sep 17 00:00:00 2001
From cbc9037817804247e73096f7a5195bb0cb549616 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Wed, 16 Apr 2014 11:14:38 +1000
Subject: [PATCH] Correct Ban Expiration
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index fdb4b3c..7eb2077 100644
index cfdaea2..3817428 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -376,7 +376,7 @@ public abstract class PlayerList {
@@ -385,7 +385,7 @@ public abstract class PlayerList {
}
// return s;

View File

@ -1,11 +1,11 @@
From bde43dc3ef143eaf43e4deb7db9647e5aff7e472 Mon Sep 17 00:00:00 2001
From 25732da0b82a3de2f0fb7a36c9ac99948c707de9 Mon Sep 17 00:00:00 2001
From: ninja <xninja@openmailbox.org>
Date: Tue, 8 Apr 2014 14:05:19 +0200
Subject: [PATCH] Implement PlayerSpawnLocationEvent.
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 7eb2077..3fabad4 100644
index 3817428..7466eec 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -36,6 +36,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
@ -16,7 +16,7 @@ index 7eb2077..3fabad4 100644
// CraftBukkit end
public abstract class PlayerList {
@@ -99,6 +100,19 @@ public abstract class PlayerList {
@@ -105,6 +106,19 @@ public abstract class PlayerList {
s1 = networkmanager.getSocketAddress().toString();
}

View File

@ -1,312 +0,0 @@
From fb7d83ce2ad9423ad93cac0640bc0e65827b09ee Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Mon, 28 Jul 2014 11:42:11 +0100
Subject: [PATCH] Add an option for a global cache for any request on Mojang's
api to handle plugins that don't use UserCache (or any cache)
diff --git a/src/main/java/org/spigotmc/CachedMojangAPIConnection.java b/src/main/java/org/spigotmc/CachedMojangAPIConnection.java
new file mode 100644
index 0000000..4eed6fd
--- /dev/null
+++ b/src/main/java/org/spigotmc/CachedMojangAPIConnection.java
@@ -0,0 +1,145 @@
+package org.spigotmc;
+
+import com.google.common.base.Charsets;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.Proxy;
+import java.net.URL;
+import java.util.concurrent.TimeUnit;
+
+public class CachedMojangAPIConnection extends HttpURLConnection
+{
+ private final CachedStreamHandlerFactory.CachedStreamHandler cachedStreamHandler;
+ private final Proxy proxy;
+ private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ private ByteArrayInputStream inputStream;
+ private InputStream errorStream;
+ private boolean outClosed = false;
+
+ private static final Cache<String, String> cache = CacheBuilder.newBuilder()
+ .maximumSize( 10000 )
+ .expireAfterAccess( 1, TimeUnit.HOURS )
+ .build();
+
+ public CachedMojangAPIConnection(CachedStreamHandlerFactory.CachedStreamHandler cachedStreamHandler, URL url, Proxy proxy)
+ {
+ super( url );
+ this.cachedStreamHandler = cachedStreamHandler;
+ this.proxy = proxy;
+ }
+
+ @Override
+ public void disconnect()
+ {
+
+ }
+
+ @Override
+ public boolean usingProxy()
+ {
+ return proxy != null;
+ }
+
+ @Override
+ public void connect() throws IOException
+ {
+
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException
+ {
+ if ( inputStream == null )
+ {
+ outClosed = true;
+ JsonArray users = new JsonParser().parse( new String( outputStream.toByteArray(), Charsets.UTF_8 ) ).getAsJsonArray();
+ StringBuilder reply = new StringBuilder( "[" );
+ StringBuilder missingUsers = new StringBuilder( "[" );
+ for ( JsonElement user : users )
+ {
+ String username = user.getAsString().toLowerCase();
+ String info = cache.getIfPresent( username );
+ if ( info != null )
+ {
+ reply.append( info ).append( "," );
+ } else
+ {
+ missingUsers
+ .append( "\"" )
+ .append( username )
+ .append( "\"" )
+ .append( "," );
+ }
+ }
+ if ( missingUsers.length() > 1 )
+ {
+ 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
+ {
+ responseCode = HTTP_OK;
+ }
+ if ( 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 )
+ {
+ throw new RuntimeException( "Write after send" );
+ }
+ return outputStream;
+ }
+}
diff --git a/src/main/java/org/spigotmc/CachedStreamHandlerFactory.java b/src/main/java/org/spigotmc/CachedStreamHandlerFactory.java
new file mode 100644
index 0000000..b9a8736
--- /dev/null
+++ b/src/main/java/org/spigotmc/CachedStreamHandlerFactory.java
@@ -0,0 +1,117 @@
+package org.spigotmc;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+public class CachedStreamHandlerFactory implements URLStreamHandlerFactory
+{
+ public static boolean isSet = false;
+
+ @Override
+ public URLStreamHandler createURLStreamHandler(String protocol)
+ {
+ if ( protocol.equals( "http" ) || protocol.equals( "https" ) )
+ {
+ return new CachedStreamHandler( protocol );
+ }
+ return null;
+ }
+
+ public class CachedStreamHandler extends URLStreamHandler
+ {
+ private final String protocol;
+ private final URLStreamHandler handler;
+ private final Method openCon;
+ private final Method openConProxy;
+
+ public CachedStreamHandler(String protocol)
+ {
+ this.protocol = protocol;
+ if ( protocol.equals( "http" ) )
+ {
+ handler = new sun.net.www.protocol.http.Handler();
+ } else
+ {
+ handler = new sun.net.www.protocol.https.Handler();
+ }
+ try
+ {
+ openCon = handler.getClass().getDeclaredMethod( "openConnection", URL.class );
+ openCon.setAccessible( true );
+ openConProxy = handler.getClass().getDeclaredMethod( "openConnection", URL.class, Proxy.class );
+ openConProxy.setAccessible( true );
+ } catch ( NoSuchMethodException e )
+ {
+ throw new RuntimeException( e );
+ }
+ }
+
+ @Override
+ protected URLConnection openConnection(URL u) throws IOException
+ {
+ if ( u.getHost().equals( "api.mojang.com" )
+ || u.getPath().startsWith( "/profiles/minecraft" ) )
+ {
+ return cachedConnection( u );
+ }
+ return getDefaultConnection( u );
+ }
+
+ @Override
+ protected URLConnection openConnection(URL u, Proxy p) throws IOException
+ {
+ if ( u.getHost().equals( "api.mojang.com" )
+ || u.getPath().startsWith( "/profiles/minecraft" ) )
+ {
+ return cachedConnection( u, p );
+ }
+ return getDefaultConnection( u, p );
+ }
+
+ private URLConnection cachedConnection(URL u)
+ {
+ return cachedConnection( u, null );
+ }
+
+ private URLConnection cachedConnection(URL u, Proxy p)
+ {
+ return new CachedMojangAPIConnection( this, u, p );
+ }
+
+ public URLConnection getDefaultConnection(URL u)
+ {
+ try
+ {
+ return (URLConnection) openCon.invoke( handler, u );
+ } catch ( IllegalAccessException e )
+ {
+ e.printStackTrace();
+ } catch ( InvocationTargetException e )
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public URLConnection getDefaultConnection(URL u, Proxy p)
+ {
+ try
+ {
+ return (URLConnection) openConProxy.invoke( handler, u, p );
+ } catch ( IllegalAccessException e )
+ {
+ e.printStackTrace();
+ } catch ( InvocationTargetException e )
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 4ecb3cd..d3abf1f 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -6,6 +6,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
@@ -360,4 +361,15 @@ public class SpigotConfig
attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage );
( (AttributeRanged) GenericAttributes.e ).b = attackDamage;
}
+
+ private static void globalAPICache()
+ {
+ 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());
+ }
+ }
}
--
2.1.0

View File

@ -1,4 +1,4 @@
From 53d5708c80bc7e87eec68fa31aca82c38b93ad89 Mon Sep 17 00:00:00 2001
From eaf2b27a126ac66cd87adea0b79e617045362c94 Mon Sep 17 00:00:00 2001
From: Maxim Van de Wynckel <maxim_vdw@hotmail.com>
Date: Wed, 30 Jul 2014 01:19:51 +0200
Subject: [PATCH] Only fetch an online UUID in online mode

View File

@ -1,4 +1,4 @@
From 6d51afec989a8a2f8fb435866eeb2ece33199d46 Mon Sep 17 00:00:00 2001
From 37fb7bb5623fa984c30102af7dd732e698e4e543 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Thu, 31 Jul 2014 17:48:20 +0100
Subject: [PATCH] Filter attribute modifiers which cause the attribute to go
@ -6,7 +6,7 @@ Subject: [PATCH] Filter attribute modifiers which cause the attribute to go
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index a4b09fa..3a87cb7 100644
index cea57d4..02f727a 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -41,6 +41,8 @@ import java.util.Set;

View File

@ -1,4 +1,4 @@
From 002687c1dc026ab3a98608c2a9279604164cd60e Mon Sep 17 00:00:00 2001
From 5c85e0a147eeb3ff7ae92c57d17b9cfa4e62e4bf Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Fri, 8 Aug 2014 19:57:03 +1000
Subject: [PATCH] Plug WorldMap Memory Leak

View File

@ -1,4 +1,4 @@
From 9d192185af240b3d207acb11e1308aaa30a956cd Mon Sep 17 00:00:00 2001
From 46265c68f5fc26803e2acb7c62e6884737b2eeff 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

View File

@ -1,4 +1,4 @@
From 5973bc2910615bddecb6be2e5e5701e5188c35cc Mon Sep 17 00:00:00 2001
From 4dd56e8358ed665e09bf8b459e06a77b5bd60999 Mon Sep 17 00:00:00 2001
From: drXor <mcyoung@mit.edu>
Date: Fri, 15 Aug 2014 18:11:09 -0400
Subject: [PATCH] Remove uneeded validation

View File

@ -1,4 +1,4 @@
From f2ffac7dc7d11bcc6682d99279c2068e4fd77e4d Mon Sep 17 00:00:00 2001
From 39d5514ed69b19092fce19a6f4edda5e59a45c31 Mon Sep 17 00:00:00 2001
From: lazertester <austin.techhead@gmail.com>
Date: Sun, 17 Aug 2014 19:56:17 +1000
Subject: [PATCH] Add Hunger Config Values
@ -43,7 +43,7 @@ index 23aca22..1b44990 100644
}
} else if (this.foodLevel <= 0) {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index c3a2d01..3f145b3 100644
index e094aeb..0a67739 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -326,4 +326,16 @@ public class SpigotWorldConfig

View File

@ -1,14 +1,14 @@
From c6ddb075e315c7b4685064cd33a0b48800811a06 Mon Sep 17 00:00:00 2001
From bb9f1daaae6e48911f8054ed0360cce7523fbe21 Mon Sep 17 00:00:00 2001
From: Minecrell <dev@minecrell.net>
Date: Sun, 17 Aug 2014 12:42:53 +0200
Subject: [PATCH] Make debug logging togglable.
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index d3abf1f..a8140a5 100644
index 4ecb3cd..c03388d 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -18,6 +18,9 @@ import gnu.trove.map.hash.TObjectIntHashMap;
@@ -17,6 +17,9 @@ import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.server.AttributeRanged;
import net.minecraft.server.GenericAttributes;
import net.minecraft.server.MinecraftServer;
@ -18,9 +18,9 @@ index d3abf1f..a8140a5 100644
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@@ -372,4 +375,27 @@ public class SpigotConfig
URL.setURLStreamHandlerFactory(new CachedStreamHandlerFactory());
}
@@ -360,4 +363,27 @@ public class SpigotConfig
attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage );
( (AttributeRanged) GenericAttributes.e ).b = attackDamage;
}
+
+ public static boolean debug;

View File

@ -1,4 +1,4 @@
From e97963548a76c81455fa488e57562f54b06b7c6e Mon Sep 17 00:00:00 2001
From a67c0c9c88796b03060c0721a923de982c9cdf0d Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Tue, 19 Aug 2014 11:04:21 +0100
Subject: [PATCH] Skip invalid enchants in CraftMetaItem
@ -8,7 +8,7 @@ CraftMetaItem would add a null enchantment into the enchantment map which causes
NullPointers later
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 070b23a..e011d85 100644
index 99d3226..e28f077 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -450,7 +450,11 @@ class CraftMetaItem implements ItemMeta, Repairable {

View File

@ -1,4 +1,4 @@
From ac2db9e7acabd4d35edf027e486f0df245e22522 Mon Sep 17 00:00:00 2001
From 79ab88c862a9310340d15158c5e156c5d0d77d36 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 20 Aug 2014 18:12:32 -0400
Subject: [PATCH] Limit TNT Detonations per tick
@ -31,7 +31,7 @@ index 439bb00..a61655f 100644
public void j() {
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 3f145b3..46377ab 100644
index 0a67739..a88942e 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -338,4 +338,15 @@ public class SpigotWorldConfig

View File

@ -1,11 +1,11 @@
From fe442b774bccc0b933b6caa89b1eda7b5af10480 Mon Sep 17 00:00:00 2001
From ad306896f643462f28b7e095234c17bf7310bf27 Mon Sep 17 00:00:00 2001
From: libraryaddict <redwarfare@live.com>
Date: Fri, 22 Aug 2014 05:35:16 -0400
Subject: [PATCH] Added isUnbreakable and setUnbreakable to ItemMeta
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index fef0971..b1d26dc 100644
index e28f077..f3f505d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -207,6 +207,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
@ -137,5 +137,5 @@ index fef0971..b1d26dc 100644
@Override
--
1.9.5.msysgit.0
2.1.0

View File

@ -1,4 +1,4 @@
From fc33200a5c8c5656efde5c6741cc9ae4964399d0 Mon Sep 17 00:00:00 2001
From eb813a2db272a0721c02a49ad64ea143102d257c Mon Sep 17 00:00:00 2001
From: drXor <mcyoung@mit.edu>
Date: Sat, 9 Aug 2014 13:56:51 -0400
Subject: [PATCH] Configurable Hanging Tick
@ -18,7 +18,7 @@ index 6570340..b74c55e 100644
if (!this.dead && !this.survives()) {
// CraftBukkit start - fire break events
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
index 46377ab..420c584 100644
index a88942e..b4f32f0 100644
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -349,4 +349,10 @@ public class SpigotWorldConfig

View File

@ -1,4 +1,4 @@
From 7340d2e1adbc4990ad6ffa71e1ed56883b409967 Mon Sep 17 00:00:00 2001
From 3f4058f9d9c8039b1d96f54e87e823e201435941 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sun, 21 Sep 2014 10:06:01 +1000
Subject: [PATCH] Fix Some Memory Leaks

View File

@ -1,4 +1,4 @@
From 9dc746a98e36dfe3866f26582a57ea278ec09230 Mon Sep 17 00:00:00 2001
From b911d5b814c9b30d5da1a0545c34f75cd78b0d03 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Tue, 30 Sep 2014 21:43:15 +1000
Subject: [PATCH] Refactor ItemDoor Place

View File

@ -1,4 +1,4 @@
From 4a40255409dfc0f9edbef50ee38b55db91474429 Mon Sep 17 00:00:00 2001
From 9368d77a99cb9630efbddf2db873dd0f7a97ee1a Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Tue, 30 Sep 2014 21:49:10 +1000
Subject: [PATCH] Don't Fire InventoryCloseEvent Unless Required

View File

@ -1,4 +1,4 @@
From 3b859f8d9d144e22949ff40876ed027402dbdcf5 Mon Sep 17 00:00:00 2001
From 06a72830d5a89704ea9b527d6231ace86df7e050 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 13 Dec 2014 13:06:05 +1100
Subject: [PATCH] BungeeCord Chat API

View File

@ -1,4 +1,4 @@
From b64766d95feb117f268112b6c5c4bf0704a7a254 Mon Sep 17 00:00:00 2001
From 2da2b3d8eadb057e19c25d9ae9f306b4139fb085 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thinkofdeath@spigotmc.org>
Date: Sat, 27 Dec 2014 21:08:51 +0000
Subject: [PATCH] Disable Explosion avoiding for all mobs