From 961991a316cc128ce65fa57bf84a3bb3859dbd05 Mon Sep 17 00:00:00 2001 From: Matsv Date: Mon, 12 Jun 2017 21:28:26 +0200 Subject: [PATCH] Fix null translate chat message fields --- .../protocol1_12to1_11_1/packets/ChatPackets1_12.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/ChatPackets1_12.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/ChatPackets1_12.java index 3f12ab6a..4cf944b1 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/ChatPackets1_12.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_12to1_11_1/packets/ChatPackets1_12.java @@ -10,6 +10,7 @@ package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets; +import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.api.rewriters.Rewriter; import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12; import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.AdvancementTranslations; @@ -50,7 +51,7 @@ public class ChatPackets1_12 extends Rewriter { } catch (Exception e) { // Only print if ViaVer debug is enabled if (Via.getManager().isDebug()) { - System.out.println("Failed to handle translations"); + ViaBackwards.getPlatform().getLogger().severe("Failed to handle translations"); e.printStackTrace(); } } @@ -58,15 +59,17 @@ public class ChatPackets1_12 extends Rewriter { }); } }); + } // TODO improve this, not copying will cause ConcurrentModificationException public void handleTranslations(JsonObject object) { JsonObject copiedObj = copy(object); + if (object.isJsonObject()) { for (Map.Entry entry : copiedObj.entrySet()) { // Get the text that doesn't exist for 1.11 < - if (entry.getKey().equalsIgnoreCase("translate")) { + if (entry.getKey().equalsIgnoreCase("translate") && AdvancementTranslations.has(entry.getValue().getAsString())) { String trans = entry.getValue().getAsString(); object.remove("translate"); object.addProperty("translate", AdvancementTranslations.get(trans));