110 lines
3.5 KiB
Diff
110 lines
3.5 KiB
Diff
--- a/net/minecraft/network/ServerStatusResponse.java
|
|
+++ b/net/minecraft/network/ServerStatusResponse.java
|
|
@@ -19,13 +19,24 @@
|
|
private ServerStatusResponse.Players field_151324_b;
|
|
private ServerStatusResponse.Version field_151325_c;
|
|
private String field_151323_d;
|
|
+ private transient net.minecraftforge.fml.network.FMLStatusPing forgeData;
|
|
|
|
+ public net.minecraftforge.fml.network.FMLStatusPing getForgeData() {
|
|
+ return this.forgeData;
|
|
+ }
|
|
+
|
|
+ public void setForgeData(net.minecraftforge.fml.network.FMLStatusPing data){
|
|
+ this.forgeData = data;
|
|
+ invalidateJson();
|
|
+ }
|
|
+
|
|
public ITextComponent func_151317_a() {
|
|
return this.field_151326_a;
|
|
}
|
|
|
|
public void func_151315_a(ITextComponent p_151315_1_) {
|
|
this.field_151326_a = p_151315_1_;
|
|
+ invalidateJson();
|
|
}
|
|
|
|
public ServerStatusResponse.Players func_151318_b() {
|
|
@@ -34,6 +45,7 @@
|
|
|
|
public void func_151319_a(ServerStatusResponse.Players p_151319_1_) {
|
|
this.field_151324_b = p_151319_1_;
|
|
+ invalidateJson();
|
|
}
|
|
|
|
public ServerStatusResponse.Version func_151322_c() {
|
|
@@ -42,16 +54,51 @@
|
|
|
|
public void func_151321_a(ServerStatusResponse.Version p_151321_1_) {
|
|
this.field_151325_c = p_151321_1_;
|
|
+ invalidateJson();
|
|
}
|
|
|
|
public void func_151320_a(String p_151320_1_) {
|
|
this.field_151323_d = p_151320_1_;
|
|
+ invalidateJson();
|
|
}
|
|
|
|
public String func_151316_d() {
|
|
return this.field_151323_d;
|
|
}
|
|
|
|
+ private java.util.concurrent.Semaphore mutex = new java.util.concurrent.Semaphore(1);
|
|
+ private String json = null;
|
|
+ /**
|
|
+ * Returns this object as a Json string.
|
|
+ * Converting to JSON if a cached version is not available.
|
|
+ *
|
|
+ * Also to prevent potentially large memory allocations on the server
|
|
+ * this is moved from the SPacketServerInfo writePacket function
|
|
+ *
|
|
+ * As this method is called from the network threads so thread safety is important!
|
|
+ */
|
|
+ public String getJson() {
|
|
+ String ret = this.json;
|
|
+ if (ret == null) {
|
|
+ mutex.acquireUninterruptibly();
|
|
+ ret = this.json;
|
|
+ if (ret == null) {
|
|
+ ret = net.minecraft.network.status.server.SServerInfoPacket.field_149297_a.toJson(this);
|
|
+ this.json = ret;
|
|
+ }
|
|
+ mutex.release();
|
|
+ }
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Invalidates the cached json, causing the next call to getJson to rebuild it.
|
|
+ * This is needed externally because PlayerCountData.setPlayer's is public.
|
|
+ */
|
|
+ public void invalidateJson() {
|
|
+ this.json = null;
|
|
+ }
|
|
+
|
|
public static class Players {
|
|
private final int field_151336_a;
|
|
private final int field_151334_b;
|
|
@@ -143,6 +190,10 @@
|
|
serverstatusresponse.func_151320_a(JSONUtils.func_151200_h(jsonobject, "favicon"));
|
|
}
|
|
|
|
+ if (jsonobject.has("forgeData")) {
|
|
+ serverstatusresponse.setForgeData(net.minecraftforge.fml.network.FMLStatusPing.Serializer.deserialize(JSONUtils.func_152754_s(jsonobject, "forgeData"), p_deserialize_3_));
|
|
+ }
|
|
+
|
|
return serverstatusresponse;
|
|
}
|
|
|
|
@@ -164,6 +215,10 @@
|
|
jsonobject.addProperty("favicon", p_serialize_1_.func_151316_d());
|
|
}
|
|
|
|
+ if(p_serialize_1_.getForgeData() != null){
|
|
+ jsonobject.add("forgeData", net.minecraftforge.fml.network.FMLStatusPing.Serializer.serialize(p_serialize_1_.getForgeData(), p_serialize_3_));
|
|
+ }
|
|
+
|
|
return jsonobject;
|
|
}
|
|
}
|