3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Servers older than 1.13.2 have a length limit on plugin message name

Dieser Commit ist enthalten in:
Myles 2019-06-05 15:55:55 +01:00
Ursprung 0137105a6d
Commit 318db58be1

Datei anzeigen

@ -1,7 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets; package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets;
import com.github.steveice10.opennbt.conversion.ConverterRegistry; 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.Joiner;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@ -717,7 +722,8 @@ public class InventoryPackets {
return null; // Not valid return null; // Not valid
} }
int separatorIndex = newId.indexOf(':'); 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; newId = "minecraft:" + newId;
} }
switch (newId) { switch (newId) {
@ -744,7 +750,7 @@ public class InventoryPackets {
case "wdl:request": case "wdl:request":
return "WDL|REQUEST"; return "WDL|REQUEST";
default: default:
return newId; return newId.length() > 20 ? newId.substring(0, 20) : newId;
} }
} }