mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
commit
beb5a10bff
@ -430,7 +430,11 @@ public class Format {
|
|||||||
|
|
||||||
public static PacketContainer createPacketPlayOutChat(String json) {
|
public static PacketContainer createPacketPlayOutChat(String json) {
|
||||||
final PacketContainer container;
|
final PacketContainer container;
|
||||||
if (VersionHandler.isUnder_1_19()) {
|
if (VersionHandler.isAbove_1_19()) {
|
||||||
|
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
|
||||||
|
container.getStrings().write(0, json);
|
||||||
|
container.getBooleans().write(0, false);
|
||||||
|
} else if (VersionHandler.isUnder_1_19()) {
|
||||||
WrappedChatComponent component = WrappedChatComponent.fromJson(json);
|
WrappedChatComponent component = WrappedChatComponent.fromJson(json);
|
||||||
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||||
container.getModifier().writeDefaults();
|
container.getModifier().writeDefaults();
|
||||||
@ -445,7 +449,11 @@ public class Format {
|
|||||||
|
|
||||||
public static PacketContainer createPacketPlayOutChat(WrappedChatComponent component) {
|
public static PacketContainer createPacketPlayOutChat(WrappedChatComponent component) {
|
||||||
final PacketContainer container;
|
final PacketContainer container;
|
||||||
if (VersionHandler.isUnder_1_19()) {
|
if (VersionHandler.isAbove_1_19()) {
|
||||||
|
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()) {
|
||||||
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
container = new PacketContainer(PacketType.Play.Server.CHAT);
|
||||||
container.getModifier().writeDefaults();
|
container.getModifier().writeDefaults();
|
||||||
container.getChatComponents().write(0, component);
|
container.getChatComponents().write(0, component);
|
||||||
|
@ -1,67 +1,76 @@
|
|||||||
package mineverse.Aust1n46.chat.versions;
|
package mineverse.Aust1n46.chat.versions;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
|
|
||||||
//This class contains methods for determining what version of Minecraft the server is running.
|
//This class contains methods for determining what version of Minecraft the server is running.
|
||||||
public class VersionHandler {
|
public final class VersionHandler {
|
||||||
|
|
||||||
|
public static final MinecraftVersion SERVER_VERSION = MinecraftVersion.getCurrentVersion();
|
||||||
|
|
||||||
|
private VersionHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean is1_7() {
|
public static boolean is1_7() {
|
||||||
return Bukkit.getVersion().contains("1.7");
|
return SERVER_VERSION.getMinor() == 7 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_8() {
|
public static boolean is1_8() {
|
||||||
return Bukkit.getVersion().contains("1.8");
|
return SERVER_VERSION.getMinor() == 8 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_9() {
|
public static boolean is1_9() {
|
||||||
return Bukkit.getVersion().contains("1.9");
|
return SERVER_VERSION.getMinor() == 9 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_10() {
|
public static boolean is1_10() {
|
||||||
return Bukkit.getVersion().contains("1.10");
|
return SERVER_VERSION.getMinor() == 10 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_11() {
|
public static boolean is1_11() {
|
||||||
return Bukkit.getVersion().contains("1.11");
|
return SERVER_VERSION.getMinor() == 11 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_12() {
|
public static boolean is1_12() {
|
||||||
return Bukkit.getVersion().contains("1.12");
|
return SERVER_VERSION.getMinor() == 12 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_13() {
|
public static boolean is1_13() {
|
||||||
return Bukkit.getVersion().contains("1.13");
|
return SERVER_VERSION.getMinor() == 13 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_14() {
|
public static boolean is1_14() {
|
||||||
return Bukkit.getVersion().contains("1.14");
|
return SERVER_VERSION.getBuild() != 4 && SERVER_VERSION.getMinor() == 14 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_14_4() {
|
public static boolean is1_14_4() {
|
||||||
return Bukkit.getVersion().contains("1.14.4");
|
return SERVER_VERSION.getBuild() == 4 && SERVER_VERSION.getMinor() == 14 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_15() {
|
public static boolean is1_15() {
|
||||||
return Bukkit.getVersion().contains("1.15");
|
return SERVER_VERSION.getMinor() == 15 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_16() {
|
public static boolean is1_16() {
|
||||||
return Bukkit.getVersion().contains("1.16");
|
return SERVER_VERSION.getMinor() == 16 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_17() {
|
public static boolean is1_17() {
|
||||||
return Bukkit.getVersion().contains("1.17");
|
return SERVER_VERSION.getMinor() == 17 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_18() {
|
public static boolean is1_18() {
|
||||||
return Bukkit.getVersion().contains("1.18");
|
return SERVER_VERSION.getMinor() == 18 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_19() {
|
public static boolean is1_19() {
|
||||||
return Bukkit.getVersion().contains("1.19");
|
return SERVER_VERSION.getBuild() == 0 && SERVER_VERSION.getMinor() == 19 && SERVER_VERSION.getMajor() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUnder_1_19() {
|
public static boolean isUnder_1_19() {
|
||||||
return is1_7() || is1_8() || is1_9() || is1_10() || is1_11() || is1_12() || is1_13() || is1_14() || is1_15() || is1_16() || is1_17() || is1_18();
|
return !SERVER_VERSION.isAtLeast(MinecraftVersion.WILD_UPDATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isAbove_1_19() {
|
||||||
|
return !is1_19() && SERVER_VERSION.isAtLeast(MinecraftVersion.WILD_UPDATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user