Update to match release v3.7.1

This commit is contained in:
Aust1n46 2024-02-11 02:12:27 -06:00
parent d9fb354b83
commit 6207bdab2f
11 changed files with 197 additions and 59 deletions

View File

@ -168,7 +168,7 @@
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>4.6.0</version> <version>5.0.0-SNAPSHOT</version>
</dependency> </dependency>
<!--These are long depreciated. I would've removed them, but that is outside the scope of what I want to do here. <!--These are long depreciated. I would've removed them, but that is outside the scope of what I want to do here.
I am using the latest builds of these plugins to be published to SpigotMC.--> I am using the latest builds of these plugins to be published to SpigotMC.-->
@ -225,21 +225,21 @@
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId> <artifactId>bungeecord-api</artifactId>
<version>1.13-SNAPSHOT</version> <version>1.20-R0.1-SNAPSHOT</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.md-5</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId> <artifactId>bungeecord-api</artifactId>
<version>1.13-SNAPSHOT</version> <version>1.20-R0.1-SNAPSHOT</version>
<type>javadoc</type> <type>javadoc</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version> <version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -396,6 +396,15 @@ public class PluginMessageController {
sendPluginMessage(stream); sendPluginMessage(stream);
return; return;
} }
if (p.getPlayer().hasPermission("venturechat.ignore.bypass")) {
out.writeUTF("Ignore");
out.writeUTF("Bypass");
out.writeUTF(server);
out.writeUTF(receiver);
out.writeUTF(sender.toString());
sendPluginMessage(stream);
return;
}
out.writeUTF("Ignore"); out.writeUTF("Ignore");
out.writeUTF("Echo"); out.writeUTF("Echo");
out.writeUTF(server); out.writeUTF(server);
@ -428,6 +437,12 @@ public class PluginMessageController {
p.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_ON.toString().replace("{player}", receiverName)); p.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_ON.toString().replace("{player}", receiverName));
synchronize(p, true); synchronize(p, true);
} }
if (identifier.equals("Bypass")) {
String receiver = msgin.readUTF();
UUID sender = UUID.fromString(msgin.readUTF());
VentureChatPlayer p = playerApiService.getOnlineMineverseChatPlayer(sender);
p.getPlayer().sendMessage(LocalizedMessage.IGNORE_PLAYER_CANT.toString().replace("{player}", receiver));
}
} }
if (subchannel.equals("Mute")) { if (subchannel.equals("Mute")) {
String identifier = msgin.readUTF(); String identifier = msgin.readUTF();

View File

@ -212,6 +212,18 @@ public class VentureChatProxyController {
source.sendPluginMessage(server, outstream.toByteArray()); source.sendPluginMessage(server, outstream.toByteArray());
} }
} }
if (identifier.equals("Bypass")) {
String server = in.readUTF();
String player = in.readUTF();
String sender = in.readUTF();
out.writeUTF("Ignore");
out.writeUTF("Bypass");
out.writeUTF(player);
out.writeUTF(sender);
if(!source.getServer(server).isEmpty()) {
source.sendPluginMessage(server, outstream.toByteArray());
}
}
} }
if(subchannel.equals("Mute")) { if(subchannel.equals("Mute")) {
String identifier = in.readUTF(); String identifier = in.readUTF();

View File

@ -22,7 +22,7 @@ import venture.Aust1n46.chat.controllers.VentureChatSpigotFlatFileController;
import venture.Aust1n46.chat.guice.VentureChatPluginModule; import venture.Aust1n46.chat.guice.VentureChatPluginModule;
import venture.Aust1n46.chat.initiators.listeners.ChatListener; import venture.Aust1n46.chat.initiators.listeners.ChatListener;
import venture.Aust1n46.chat.initiators.listeners.LoginListener; import venture.Aust1n46.chat.initiators.listeners.LoginListener;
import venture.Aust1n46.chat.initiators.listeners.PacketListener; import venture.Aust1n46.chat.initiators.listeners.PacketListenerLegacyChat;
import venture.Aust1n46.chat.initiators.listeners.PreProcessCommandListener; import venture.Aust1n46.chat.initiators.listeners.PreProcessCommandListener;
import venture.Aust1n46.chat.initiators.listeners.SignListener; import venture.Aust1n46.chat.initiators.listeners.SignListener;
import venture.Aust1n46.chat.initiators.schedulers.UnmuteScheduler; import venture.Aust1n46.chat.initiators.schedulers.UnmuteScheduler;
@ -30,6 +30,7 @@ import venture.Aust1n46.chat.localization.Localization;
import venture.Aust1n46.chat.placeholderapi.VentureChatPlaceholders; import venture.Aust1n46.chat.placeholderapi.VentureChatPlaceholders;
import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.utilities.FormatUtils; import venture.Aust1n46.chat.utilities.FormatUtils;
import venture.Aust1n46.chat.xcut.VersionService;
/** /**
* VentureChat Minecraft plugin for servers running Spigot or Paper software. * VentureChat Minecraft plugin for servers running Spigot or Paper software.
@ -47,7 +48,7 @@ public class VentureChat extends JavaPlugin implements PluginMessageListener {
@Inject @Inject
private PreProcessCommandListener commandListener; private PreProcessCommandListener commandListener;
@Inject @Inject
private PacketListener packetListener; private PacketListenerLegacyChat packetListener;
@Inject @Inject
private VentureChatPlaceholders ventureChatPlaceholders; private VentureChatPlaceholders ventureChatPlaceholders;
@Inject @Inject
@ -56,6 +57,8 @@ public class VentureChat extends JavaPlugin implements PluginMessageListener {
private VentureChatPlayerApiService playerApiService; private VentureChatPlayerApiService playerApiService;
@Inject @Inject
private PluginMessageController pluginMessageController; private PluginMessageController pluginMessageController;
@Inject
private VersionService versionService;
private Permission permission = null; private Permission permission = null;
@ -157,8 +160,10 @@ public class VentureChat extends JavaPlugin implements PluginMessageListener {
pluginManager.registerEvents(signListener, this); pluginManager.registerEvents(signListener, this);
pluginManager.registerEvents(commandListener, this); pluginManager.registerEvents(commandListener, this);
pluginManager.registerEvents(loginListener, this); pluginManager.registerEvents(loginListener, this);
if (versionService.isUnder_1_19()) {
ProtocolLibrary.getProtocolManager().addPacketListener(packetListener); ProtocolLibrary.getProtocolManager().addPacketListener(packetListener);
} }
}
private boolean setupPermissions() { private boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class); RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);

View File

@ -17,7 +17,7 @@ import venture.Aust1n46.chat.service.VentureChatPlayerApiService;
import venture.Aust1n46.chat.xcut.VersionService; import venture.Aust1n46.chat.xcut.VersionService;
@Singleton @Singleton
public class PacketListener extends PacketAdapter { public class PacketListenerLegacyChat extends PacketAdapter {
@Inject @Inject
private VentureChatFormatService formatter; private VentureChatFormatService formatter;
@Inject @Inject
@ -26,13 +26,13 @@ public class PacketListener extends PacketAdapter {
private VersionService versionService; private VersionService versionService;
@Inject @Inject
public PacketListener(final VentureChat plugin) { public PacketListenerLegacyChat(final VentureChat plugin) {
super(plugin, ListenerPriority.MONITOR, new PacketType[] { PacketType.Play.Server.CHAT }); super(plugin, ListenerPriority.MONITOR, new PacketType[] { PacketType.Play.Server.CHAT });
} }
@Override @Override
public void onPacketSending(PacketEvent event) { public void onPacketSending(PacketEvent event) {
if (event.isCancelled() || event.getPacketType() != PacketType.Play.Server.CHAT) { if (event.isCancelled()) {
return; return;
} }

View File

@ -0,0 +1,16 @@
package venture.Aust1n46.chat.model;
public enum ClickAction {
SUGGEST_COMMAND, RUN_COMMAND, OPEN_URL, NONE;
private final String jsonValue;
ClickAction() {
jsonValue = name().toLowerCase();
}
@Override
public String toString() {
return jsonValue;
}
}

View File

@ -8,10 +8,10 @@ import lombok.Getter;
public class JsonAttribute { public class JsonAttribute {
private String name; private String name;
private List<String> hoverText; private List<String> hoverText;
private String clickAction; private ClickAction clickAction;
private String clickText; private String clickText;
public JsonAttribute(String name, List<String> hoverText, String clickAction, String clickText) { public JsonAttribute(String name, List<String> hoverText, ClickAction clickAction, String clickText) {
this.name = name; this.name = name;
this.hoverText = hoverText; this.hoverText = hoverText;
this.clickAction = clickAction; this.clickAction = clickAction;

View File

@ -14,6 +14,7 @@ import com.google.inject.Singleton;
import venture.Aust1n46.chat.initiators.application.VentureChat; import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.model.Alias; import venture.Aust1n46.chat.model.Alias;
import venture.Aust1n46.chat.model.ChatChannel; import venture.Aust1n46.chat.model.ChatChannel;
import venture.Aust1n46.chat.model.ClickAction;
import venture.Aust1n46.chat.model.GuiSlot; import venture.Aust1n46.chat.model.GuiSlot;
import venture.Aust1n46.chat.model.JsonAttribute; import venture.Aust1n46.chat.model.JsonAttribute;
import venture.Aust1n46.chat.model.JsonFormat; import venture.Aust1n46.chat.model.JsonFormat;
@ -81,8 +82,9 @@ public class ConfigService {
if (jsonAttributeSection != null) { if (jsonAttributeSection != null) {
for (String attribute : jsonAttributeSection.getKeys(false)) { for (String attribute : jsonAttributeSection.getKeys(false)) {
List<String> hoverText = jsonAttributeSection.getStringList(attribute + ".hover_text"); List<String> hoverText = jsonAttributeSection.getStringList(attribute + ".hover_text");
String clickAction = jsonAttributeSection.getString(attribute + ".click_action", "");
String clickText = jsonAttributeSection.getString(attribute + ".click_text", ""); String clickText = jsonAttributeSection.getString(attribute + ".click_text", "");
String clickActionText = jsonAttributeSection.getString(attribute + ".click_action", "none");
ClickAction clickAction = ClickAction.valueOf(clickActionText.toUpperCase());
jsonAttributes.add(new JsonAttribute(attribute, hoverText, clickAction, clickText)); jsonAttributes.add(new JsonAttribute(attribute, hoverText, clickAction, clickText));
} }
} }
@ -215,8 +217,11 @@ public class ConfigService {
public boolean isProxyEnabled() { public boolean isProxyEnabled() {
try { try {
return plugin.getServer().spigot().getConfig().getBoolean("settings.bungeecord") // return plugin.getServer().spigot().getConfig().getBoolean("settings.bungeecord")
|| plugin.getServer().spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled"); // || plugin.getServer().spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled");
return (plugin.getServer().spigot().getConfig().getBoolean("settings.bungeecord")
|| plugin.getServer().spigot().getPaperConfig().getBoolean("settings.velocity-support.enabled")
|| plugin.getServer().spigot().getPaperConfig().getBoolean("proxies.velocity.enabled"));
} catch (NoSuchMethodError exception) { // Thrown if server isn't Paper. } catch (NoSuchMethodError exception) { // Thrown if server isn't Paper.
return false; return false;
} }

View File

@ -14,6 +14,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,6 +29,7 @@ import com.google.inject.Singleton;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import venture.Aust1n46.chat.initiators.application.VentureChat; import venture.Aust1n46.chat.initiators.application.VentureChat;
import venture.Aust1n46.chat.model.ClickAction;
import venture.Aust1n46.chat.model.JsonAttribute; import venture.Aust1n46.chat.model.JsonAttribute;
import venture.Aust1n46.chat.model.JsonFormat; import venture.Aust1n46.chat.model.JsonFormat;
import venture.Aust1n46.chat.model.VentureChatPlayer; import venture.Aust1n46.chat.model.VentureChatPlayer;
@ -65,10 +67,10 @@ public class VentureChatFormatService {
*/ */
public String convertToJson(VentureChatPlayer sender, String format, String chat) { public String convertToJson(VentureChatPlayer sender, String format, String chat) {
JsonFormat JSONformat = configService.getJsonFormat(sender.getJsonFormat()); JsonFormat JSONformat = configService.getJsonFormat(sender.getJsonFormat());
String f = escapeJsonChars(format); // String f = escapeJsonChars(format);
String c = escapeJsonChars(chat); String c = escapeJsonChars(chat);
String json = "[\"\",{\"text\":\"\",\"extra\":["; String json = "[\"\",{\"text\":\"\",\"extra\":[";
json += convertPlaceholders(f, JSONformat, sender); json += convertPlaceholders(format, JSONformat, sender);
json += "]}"; json += "]}";
json += "," + convertLinks(c); json += "," + convertLinks(c);
json += "]"; json += "]";
@ -108,26 +110,59 @@ public class VentureChatFormatService {
indexStart = matcher.start(); indexStart = matcher.start();
indexEnd = matcher.end(); indexEnd = matcher.end();
placeholder = remaining.substring(indexStart, indexEnd); placeholder = remaining.substring(indexStart, indexEnd);
formattedPlaceholder = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder)); formattedPlaceholder = escapeJsonChars(FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), placeholder)));
temp += convertToJsonColors(lastCode + remaining.substring(0, indexStart)) + ","; temp += convertToJsonColors(escapeJsonChars(lastCode + remaining.substring(0, indexStart))) + ",";
lastCode = getLastCode(lastCode + remaining.substring(0, indexStart)); lastCode = getLastCode(lastCode + remaining.substring(0, indexStart));
String action = ""; // String action = "";
String text = ""; // String text = "";
String hover = ""; // String hover = "";
boolean placeholderHasJsonAttribute = false;
for (JsonAttribute jsonAttribute : format.getJsonAttributes()) { for (JsonAttribute jsonAttribute : format.getJsonAttributes()) {
if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) { if (placeholder.contains(jsonAttribute.getName().replace("{", "").replace("}", ""))) {
action = jsonAttribute.getClickAction(); // action = jsonAttribute.getClickAction();
text = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText())); // text = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()));
final StringBuilder hover = new StringBuilder();
for (String st : jsonAttribute.getHoverText()) { for (String st : jsonAttribute.getHoverText()) {
hover += FormatUtils.FormatStringAll(st) + "\n"; // hover += FormatUtils.FormatStringAll(st) + "\n";
} hover.append(FormatUtils.FormatStringAll(st) + "\n");
}
} }
final String hoverText;
if(!hover.isEmpty()) { if(!hover.isEmpty()) {
hover = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1))); hoverText = escapeJsonChars(FormatUtils.FormatStringAll(
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1))));
} else {
hoverText = StringUtils.EMPTY;
} }
temp += convertToJsonColors(lastCode + formattedPlaceholder, ",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text final ClickAction clickAction = jsonAttribute.getClickAction();
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hover) + "]}}") + ","; final String actionJson;
if (clickAction == ClickAction.NONE) {
actionJson = StringUtils.EMPTY;
} else {
final String clickText = escapeJsonChars(FormatUtils.FormatStringAll(
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText())));
actionJson = ",\"clickEvent\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"value\":\"" + clickText
+ "\"}";
}
final String hoverJson;
if (hoverText.isEmpty()) {
hoverJson = StringUtils.EMPTY;
} else {
hoverJson = ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
+ convertToJsonColors(hoverText) + "]}}";
}
temp += convertToJsonColors(lastCode + formattedPlaceholder, actionJson + hoverJson) + ",";
placeholderHasJsonAttribute = true;
break;
}
}
// if (!hover.isEmpty()) {
// hover = FormatUtils.FormatStringAll(PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), hover.substring(0, hover.length() - 1)));
// }
if (!placeholderHasJsonAttribute) {
temp += convertToJsonColors(lastCode + formattedPlaceholder) + ",";
}
// temp += convertToJsonColors(lastCode + formattedPlaceholder, ",\"clickEvent\":{\"action\":\"" + action + "\",\"value\":\"" + text
// + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hover) + "]}}") + ",";
lastCode = getLastCode(lastCode + formattedPlaceholder); lastCode = getLastCode(lastCode + formattedPlaceholder);
remaining = remaining.substring(indexEnd); remaining = remaining.substring(indexEnd);
} else { } else {
@ -165,7 +200,7 @@ public class VentureChatFormatService {
if (ChatColor.stripColor(link).contains("https://")) if (ChatColor.stripColor(link).contains("https://"))
https = "s"; https = "s";
temp += convertToJsonColors(lastCode + link, temp += convertToJsonColors(lastCode + link,
",\"underlined\":\"" + underlineURLs() + "\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" ",\"underlined\":" + underlineURLs() + ",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://"
+ ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) + ChatColor.stripColor(link.replace("http://", "").replace("https://", ""))
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}")
+ ","; + ",";
@ -307,15 +342,35 @@ public class VentureChatFormatService {
underlined = false; underlined = false;
} }
if (bold) if (bold)
if (versionService.isAtLeast_1_20_4()) {
modifier += ",\"bold\":true";
} else {
modifier += ",\"bold\":\"true\""; modifier += ",\"bold\":\"true\"";
}
if (obfuscated) if (obfuscated)
if (versionService.isAtLeast_1_20_4()) {
modifier += ",\"obfuscated\":true";
} else {
modifier += ",\"obfuscated\":\"true\""; modifier += ",\"obfuscated\":\"true\"";
}
if (italic) if (italic)
if (versionService.isAtLeast_1_20_4()) {
modifier += ",\"italic\":true";
} else {
modifier += ",\"italic\":\"true\""; modifier += ",\"italic\":\"true\"";
}
if (underlined) if (underlined)
if (versionService.isAtLeast_1_20_4()) {
modifier += ",\"underlined\":true";
} else {
modifier += ",\"underlined\":\"true\""; modifier += ",\"underlined\":\"true\"";
}
if (strikethrough) if (strikethrough)
if (versionService.isAtLeast_1_20_4()) {
modifier += ",\"strikethrough\":true";
} else {
modifier += ",\"strikethrough\":\"true\""; modifier += ",\"strikethrough\":\"true\"";
}
remaining = remaining.substring(colorLength); remaining = remaining.substring(colorLength);
colorLength = LEGACY_COLOR_CODE_LENGTH; colorLength = LEGACY_COLOR_CODE_LENGTH;
indexNextColor = remaining.indexOf(BUKKIT_COLOR_CODE_PREFIX); indexNextColor = remaining.indexOf(BUKKIT_COLOR_CODE_PREFIX);
@ -407,17 +462,47 @@ public class VentureChatFormatService {
} }
public PacketContainer createPacketPlayOutChat(String json) { public PacketContainer createPacketPlayOutChat(String json) {
final PacketContainer container;
if (versionService.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 (versionService.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 (versionService.isUnder_1_19()) { // 1.7 -> 1.19
WrappedChatComponent component = WrappedChatComponent.fromJson(json); WrappedChatComponent component = WrappedChatComponent.fromJson(json);
PacketContainer 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);
} else { // 1.19
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
container.getStrings().write(0, json);
container.getIntegers().write(0, 1);
}
return container; return container;
} }
public PacketContainer createPacketPlayOutChat(WrappedChatComponent component) { public PacketContainer createPacketPlayOutChat(WrappedChatComponent component) {
PacketContainer container = new PacketContainer(PacketType.Play.Server.CHAT); final PacketContainer container;
if (versionService.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 (versionService.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 (versionService.isUnder_1_19()) { // 1.7 -> 1.19
container = new PacketContainer(PacketType.Play.Server.CHAT);
container.getModifier().writeDefaults(); container.getModifier().writeDefaults();
container.getChatComponents().write(0, component); container.getChatComponents().write(0, component);
} else { // 1.19
container = new PacketContainer(PacketType.Play.Server.SYSTEM_CHAT);
container.getStrings().write(0, component.getJson());
container.getIntegers().write(0, 1);
}
return container; return container;
} }
@ -578,8 +663,13 @@ public class VentureChatFormatService {
return msg; return msg;
} }
public boolean underlineURLs() { public String underlineURLs() {
return plugin.getConfig().getBoolean("underlineurls", true); final boolean configValue = plugin.getConfig().getBoolean("underlineurls", true);
if (versionService.isAtLeast_1_20_4()) {
return String.valueOf(configValue);
} else {
return "\"" + configValue + "\"";
}
} }
public void broadcastToServer(String message) { public void broadcastToServer(String message) {

View File

@ -6,6 +6,9 @@ import com.google.inject.Singleton;
@Singleton @Singleton
public final class VersionService { public final class VersionService {
public static final MinecraftVersion SERVER_VERSION = MinecraftVersion.getCurrentVersion(); 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 VersionService() { private VersionService() {
} }
@ -67,22 +70,14 @@ public final class VersionService {
} }
public boolean isUnder_1_19() { public boolean isUnder_1_19() {
if (SERVER_VERSION.getMajor() < 1) { return !SERVER_VERSION.isAtLeast(MC1_19);
return true;
}
return SERVER_VERSION.getMajor() == 1 && SERVER_VERSION.getMinor() < 19;
} }
public boolean isAbove_1_19() { public boolean isAbove_1_19() {
if (SERVER_VERSION.getMajor() < 1) { return SERVER_VERSION.isAtLeast(MC1_19_1);
return false;
} }
if (SERVER_VERSION.getMajor() > 1) {
return true; public boolean isAtLeast_1_20_4() {
} return SERVER_VERSION.isAtLeast(MC1_20_4);
if (SERVER_VERSION.getMinor() > 19) {
return true;
}
return SERVER_VERSION.getMinor() == 19 && SERVER_VERSION.getBuild() > 0;
} }
} }

View File

@ -136,7 +136,7 @@ messageremovertext: '&c&o<message removed>'
# The name of the group is the permissions node for the format # The name of the group is the permissions node for the format
# Example: venturechat.json.Owner is the node for the group Owner # Example: venturechat.json.Owner is the node for the group Owner
# A lower priority overrides a higher priority if a player has more than 1 group # A lower priority overrides a higher priority if a player has more than 1 group
# Possible options for click_name and click_prefix are suggest_command, run_command, and open_url # Possible options for click_action are suggest_command, run_command, open_url, and none
jsonformatting: jsonformatting:
Default: # This default format is required! Do not delete or rename it! Default: # This default format is required! Do not delete or rename it!
priority: 2147483647 # Integer.MAX_VALUE priority: 2147483647 # Integer.MAX_VALUE