From b9e19e2441c2f7a760fd4875b0551415abc3d7ff Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Wed, 20 Aug 2025 01:14:29 -0500 Subject: [PATCH] Update for 1.21.8 (#149) * implement json format changes for 1.21.5 update deps, update message sound and safety wrap it * imports --- pom.xml | 56 +++++++++---------- .../Aust1n46/chat/utilities/Format.java | 33 ++++++----- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/pom.xml b/pom.xml index d0f10d7..36d539f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 mineverse.Aust1n46.chat VentureChat - 3.7.2 + 3.8.0 https://bitbucket.org/Aust1n46/venturechat/src/master https://bitbucket.org/Aust1n46/venturechat/src/master @@ -30,10 +30,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.11.0 - 1.8 - 1.8 + 17 + 17 @@ -56,7 +56,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.2.4 + 3.4.1 @@ -91,22 +91,10 @@ jitpack.io https://jitpack.io - - placeholderapi - https://repo.extendedclip.com/content/repositories/placeholderapi/ - dmulloy2-repo https://repo.dmulloy2.net/repository/public/ - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - bungeecord-repo - https://oss.sonatype.org/content/repositories/snapshots - essentialsx-repo https://repo.essentialsx.net/releases/ @@ -116,15 +104,15 @@ https://repo.velocitypowered.com/snapshots/ - papermc - https://papermc.io/repo/repository/maven-public/ - + papermc + https://repo.papermc.io/repository/maven-public/ + io.papermc.paper paper-api - 1.17.1-R0.1-SNAPSHOT + 1.21.8-R0.1-SNAPSHOT provided @@ -134,10 +122,9 @@ compile - me.clip + com.github.placeholderapi placeholderapi - 2.10.9 - provided + 2.11.6 com.github.MilkBowl @@ -152,9 +139,9 @@ - com.comphenix.protocol + net.dmulloy2 ProtocolLib - 5.0.0-SNAPSHOT + 5.4.0 @@ -216,11 +203,22 @@ provided - org.spigotmc - spigot-api - 1.20-R0.1-SNAPSHOT + net.kyori + adventure-api + 4.24.0 provided + + net.kyori + adventure-platform-bukkit + 4.4.1 + provided + + + com.googlecode.json-simple + json-simple + 1.1.1 + junit junit diff --git a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java index 6e365f5..3dff956 100644 --- a/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java +++ b/src/main/java/mineverse/Aust1n46/chat/utilities/Format.java @@ -3,13 +3,12 @@ package mineverse.Aust1n46.chat.utilities; import static mineverse.Aust1n46.chat.MineverseChat.getInstance; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; +import mineverse.Aust1n46.chat.MineverseChat; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -134,14 +133,14 @@ public class Format { } else { final String clickText = escapeJsonChars(Format.FormatStringAll( PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()))); - actionJson = ",\"clickEvent\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"value\":\"" + clickText + actionJson = ",\"click_event\":{\"action\":\"" + jsonAttribute.getClickAction().toString() + "\",\"command\":\"" + clickText + "\"}"; } final String hoverJson; if (hoverText.isEmpty()) { hoverJson = StringUtils.EMPTY; } else { - hoverJson = ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + hoverJson = ",\"hover_event\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(hoverText) + "]}}"; } temp += convertToJsonColors(lastCode + formattedPlaceholder, actionJson + hoverJson) + ","; @@ -191,9 +190,9 @@ public class Format { https = "s"; temp += convertToJsonColors(lastCode + link, ",\"underlined\":" + underlineURLs() - + ",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + + ",\"click_event\":{\"action\":\"open_url\",\"url\":\"http" + https + "://" + ChatColor.stripColor(link.replace("http://", "").replace("https://", "")) - + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + + "\"},\"hover_event\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + convertToJsonColors(lastCode + link) + "]}}") + ","; lastCode = getLastCode(lastCode + link); @@ -455,9 +454,9 @@ public class Format { if (player.hasPermission("venturechat.gui")) { json = json.substring(0, json.length() - 1); json += "," + Format.convertToJsonColors(Format.FormatStringAll(getInstance().getConfig().getString("guiicon")), - ",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/vchatgui " + sender + " " + channelName + ",\"click_event\":{\"action\":\"run_command\",\"command\":\"/vchatgui " + sender + " " + channelName + " " + hash - + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + + "\"},\"hover_event\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + Format.convertToJsonColors( Format.FormatStringAll(getInstance().getConfig().getString("guitext"))) + "]}}") @@ -960,15 +959,23 @@ public class Format { public static void playMessageSound(MineverseChatPlayer mcp) { Player player = mcp.getPlayer(); String soundName = getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND); - if(!soundName.equalsIgnoreCase("None")) { - Sound messageSound = getSound(soundName); - player.playSound(player.getLocation(), messageSound, 1, 0); + if (!soundName.equalsIgnoreCase("None")) { + try { + Sound messageSound = getSound(soundName); + player.playSound(player.getLocation(), messageSound, 1, 0); + } catch (final Exception e) { + if (MineverseChat.getInstance().getConfig().getString("loglevel", "info").equals("debug")) { + Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Error playing sound, defaulting to none")); + } + } } } private static Sound getSound(String soundName) { - if(Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList()).contains(soundName)) { - return Sound.valueOf(soundName); + for (Sound sound : Sound.values()) { + if (sound.toString().equalsIgnoreCase(soundName)) { + return sound; + } } Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!")); return getDefaultMessageSound();