From 0137105a6d07e152870b9fdfd43ea25a7917ca06 Mon Sep 17 00:00:00 2001 From: Myles Date: Fri, 31 May 2019 20:43:02 +0100 Subject: [PATCH 1/2] Fix #1358 by checking for null before processing --- .../ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java | 1 + .../protocols/protocol1_14to1_13_2/InventoryNameRewriter.java | 1 + 2 files changed, 2 insertions(+) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java index d6e888402..1e8c42544 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/ChatRewriter.java @@ -131,6 +131,7 @@ public class ChatRewriter { } private static void processTranslate(BaseComponent component) { + if (component == null) return; if (component instanceof TranslatableComponent) { String oldTranslate = ((TranslatableComponent) component).getTranslate(); String newTranslate; diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/InventoryNameRewriter.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/InventoryNameRewriter.java index 253cae5b1..0d810f7c7 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/InventoryNameRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_14to1_13_2/InventoryNameRewriter.java @@ -18,6 +18,7 @@ public class InventoryNameRewriter { } private static void processTranslate(BaseComponent component) { + if (component == null) return; if (component instanceof TranslatableComponent) { String oldTranslate = ((TranslatableComponent) component).getTranslate(); From 318db58be1bbbcf31ff334f6387363943bb5bdf1 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 5 Jun 2019 15:55:55 +0100 Subject: [PATCH 2/2] Servers older than 1.13.2 have a length limit on plugin message name --- .../packets/InventoryPackets.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index 52c41be67..b4c5f8198 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -1,7 +1,12 @@ package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets; import com.github.steveice10.opennbt.conversion.ConverterRegistry; -import com.github.steveice10.opennbt.tag.builtin.*; +import com.github.steveice10.opennbt.tag.builtin.CompoundTag; +import com.github.steveice10.opennbt.tag.builtin.IntTag; +import com.github.steveice10.opennbt.tag.builtin.ListTag; +import com.github.steveice10.opennbt.tag.builtin.ShortTag; +import com.github.steveice10.opennbt.tag.builtin.StringTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.primitives.Ints; @@ -717,7 +722,8 @@ public class InventoryPackets { return null; // Not valid } int separatorIndex = newId.indexOf(':'); - if (separatorIndex == -1 || separatorIndex == 0) { // Vanilla parses ``:`` and ```` as ``minecraft:`` + // Vanilla parses ``:`` and ```` as ``minecraft:`` (also ensure there's enough space) + if ((separatorIndex == -1 || separatorIndex == 0) && newId.length() <= 10) { newId = "minecraft:" + newId; } switch (newId) { @@ -744,7 +750,7 @@ public class InventoryPackets { case "wdl:request": return "WDL|REQUEST"; default: - return newId; + return newId.length() > 20 ? newId.substring(0, 20) : newId; } }