mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Support 1.20.4
This commit is contained in:
parent
0dfd13f2de
commit
d87c255059
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>mineverse.Aust1n46.chat</groupId>
|
||||
<artifactId>VentureChat</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<version>3.7.0</version>
|
||||
<url>https://bitbucket.org/Aust1n46/venturechat/src/master</url>
|
||||
<scm>
|
||||
<url>https://bitbucket.org/Aust1n46/venturechat/src/master</url>
|
||||
|
@ -343,15 +343,35 @@ public class Format {
|
||||
underlined = false;
|
||||
}
|
||||
if (bold)
|
||||
modifier += ",\"bold\":\"true\"";
|
||||
if (VersionHandler.isAtLeast_1_20_4()) {
|
||||
modifier += ",\"bold\":true";
|
||||
} else {
|
||||
modifier += ",\"bold\":\"true\"";
|
||||
}
|
||||
if (obfuscated)
|
||||
modifier += ",\"obfuscated\":\"true\"";
|
||||
if (VersionHandler.isAtLeast_1_20_4()) {
|
||||
modifier += ",\"obfuscated\":true";
|
||||
} else {
|
||||
modifier += ",\"obfuscated\":\"true\"";
|
||||
}
|
||||
if (italic)
|
||||
modifier += ",\"italic\":\"true\"";
|
||||
if (VersionHandler.isAtLeast_1_20_4()) {
|
||||
modifier += ",\"italic\":true";
|
||||
} else {
|
||||
modifier += ",\"italic\":\"true\"";
|
||||
}
|
||||
if (underlined)
|
||||
modifier += ",\"underlined\":\"true\"";
|
||||
if (VersionHandler.isAtLeast_1_20_4()) {
|
||||
modifier += ",\"underlined\":true";
|
||||
} else {
|
||||
modifier += ",\"underlined\":\"true\"";
|
||||
}
|
||||
if (strikethrough)
|
||||
modifier += ",\"strikethrough\":\"true\"";
|
||||
if (VersionHandler.isAtLeast_1_20_4()) {
|
||||
modifier += ",\"strikethrough\":true";
|
||||
} else {
|
||||
modifier += ",\"strikethrough\":\"true\"";
|
||||
}
|
||||
remaining = remaining.substring(colorLength);
|
||||
colorLength = LEGACY_COLOR_CODE_LENGTH;
|
||||
indexNextColor = remaining.indexOf(BUKKIT_COLOR_CODE_PREFIX);
|
||||
@ -448,16 +468,20 @@ public class Format {
|
||||
|
||||
public static PacketContainer createPacketPlayOutChat(String json) {
|
||||
final PacketContainer container;
|
||||
if (VersionHandler.isAbove_1_19()) {
|
||||
if (VersionHandler.isAtLeast_1_20_4()) { // 1.20.4+
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getChatComponents().write(0, WrappedChatComponent.fromJson(json));
|
||||
container.getBooleans().write(0, false);
|
||||
} else if (VersionHandler.isAbove_1_19()) { // 1.19.1 -> 1.20.3
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getStrings().write(0, json);
|
||||
container.getBooleans().write(0, false);
|
||||
} else if (VersionHandler.isUnder_1_19()) {
|
||||
} else if (VersionHandler.isUnder_1_19()) { // 1.7 -> 1.19
|
||||
WrappedChatComponent component = WrappedChatComponent.fromJson(json);
|
||||
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||
container.getModifier().writeDefaults();
|
||||
container.getChatComponents().write(0, component);
|
||||
} else {
|
||||
} else { // 1.19
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getStrings().write(0, json);
|
||||
container.getIntegers().write(0, 1);
|
||||
@ -467,15 +491,19 @@ public class Format {
|
||||
|
||||
public static PacketContainer createPacketPlayOutChat(WrappedChatComponent component) {
|
||||
final PacketContainer container;
|
||||
if (VersionHandler.isAbove_1_19()) {
|
||||
if (VersionHandler.isAtLeast_1_20_4()) { // 1.20.4+
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getChatComponents().write(0, component);
|
||||
container.getBooleans().write(0, false);
|
||||
} else if (VersionHandler.isAbove_1_19()) { // 1.19.1 -> 1.20.3
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getStrings().write(0, component.getJson());
|
||||
container.getBooleans().write(0, false);
|
||||
} else if (VersionHandler.isUnder_1_19()) {
|
||||
} else if (VersionHandler.isUnder_1_19()) { // 1.7 -> 1.19
|
||||
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||
container.getModifier().writeDefaults();
|
||||
container.getChatComponents().write(0, component);
|
||||
} else {
|
||||
} else { // 1.19
|
||||
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||
container.getStrings().write(0, component.getJson());
|
||||
container.getIntegers().write(0, 1);
|
||||
|
@ -7,6 +7,7 @@ public final class VersionHandler {
|
||||
public static final MinecraftVersion SERVER_VERSION = MinecraftVersion.getCurrentVersion();
|
||||
private static final MinecraftVersion MC1_19 = new MinecraftVersion(1, 19, 0);
|
||||
private static final MinecraftVersion MC1_19_1 = new MinecraftVersion(1, 19, 1);
|
||||
private static final MinecraftVersion MC1_20_4 = new MinecraftVersion(1, 20, 4);
|
||||
|
||||
private VersionHandler() {
|
||||
}
|
||||
@ -74,4 +75,8 @@ public final class VersionHandler {
|
||||
public static boolean isAbove_1_19() {
|
||||
return SERVER_VERSION.isAtLeast(MC1_19_1);
|
||||
}
|
||||
|
||||
public static boolean isAtLeast_1_20_4() {
|
||||
return SERVER_VERSION.isAtLeast(MC1_20_4);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user