From 3646fad1979ffb8a41d3b312f8857d93f3f75ae5 Mon Sep 17 00:00:00 2001 From: dinnerwolph Date: Sat, 21 Jul 2018 02:51:07 +0200 Subject: [PATCH] fix server icon --- .../Protocol1_13To1_12_2.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java index 00554e957..6cedb48df 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/Protocol1_13To1_12_2.java @@ -1,5 +1,7 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.chat.ComponentSerializer; @@ -17,7 +19,6 @@ import us.myles.ViaVersion.api.remapper.ValueCreator; import us.myles.ViaVersion.api.remapper.ValueTransformer; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.packets.State; -import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets; @@ -28,6 +29,8 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.TabCompleteTracker; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Particle1_13Type; +import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; +import us.myles.ViaVersion.util.GsonUtil; import java.util.Map; @@ -118,6 +121,28 @@ public class Protocol1_13To1_12_2 extends Protocol { // Outgoing packets + registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.STRING); + handler(new PacketHandler() { + @Override + public void handle(PacketWrapper wrapper) throws Exception { + String response = wrapper.get(Type.STRING, 0); + try { + JsonObject json = GsonUtil.getGson().fromJson(response, JsonObject.class); + if (json.has("favicon")) { + json.addProperty("favicon", json.get("favicon").getAsString().replace("\n", "")); + } + wrapper.set(Type.STRING, 0, GsonUtil.getGson().toJson(json)); + } catch (JsonParseException e) { + e.printStackTrace(); + } + } + }); + } + }); + // New packet 0x04 - Login Plugin Message // Statistics