implement json format changes for 1.21.5

update deps, update message sound and safety wrap it
This commit is contained in:
Aust1n46 2025-08-20 01:03:52 -05:00
parent d964918a7b
commit c456640e5a
2 changed files with 48 additions and 43 deletions

56
pom.xml
View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>mineverse.Aust1n46.chat</groupId> <groupId>mineverse.Aust1n46.chat</groupId>
<artifactId>VentureChat</artifactId> <artifactId>VentureChat</artifactId>
<version>3.7.2</version> <version>3.8.0</version>
<url>https://bitbucket.org/Aust1n46/venturechat/src/master</url> <url>https://bitbucket.org/Aust1n46/venturechat/src/master</url>
<scm> <scm>
<url>https://bitbucket.org/Aust1n46/venturechat/src/master</url> <url>https://bitbucket.org/Aust1n46/venturechat/src/master</url>
@ -30,10 +30,10 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.11.0</version>
<configuration> <configuration>
<source>1.8</source> <source>17</source>
<target>1.8</target> <target>17</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -56,7 +56,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version> <version>3.4.1</version>
<configuration> <configuration>
<relocations> <relocations>
<relocation> <relocation>
@ -91,22 +91,10 @@
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository> <repository>
<id>dmulloy2-repo</id> <id>dmulloy2-repo</id>
<url>https://repo.dmulloy2.net/repository/public/</url> <url>https://repo.dmulloy2.net/repository/public/</url>
</repository> </repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository> <repository>
<id>essentialsx-repo</id> <id>essentialsx-repo</id>
<url>https://repo.essentialsx.net/releases/</url> <url>https://repo.essentialsx.net/releases/</url>
@ -116,15 +104,15 @@
<url>https://repo.velocitypowered.com/snapshots/</url> <url>https://repo.velocitypowered.com/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>papermc</id> <id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url> <url>https://repo.papermc.io/repository/maven-public/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version> <version>1.21.8-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -134,10 +122,9 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>com.github.placeholderapi</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.10.9</version> <version>2.11.6</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
@ -152,9 +139,9 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.comphenix.protocol</groupId> <groupId>net.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId> <artifactId>ProtocolLib</artifactId>
<version>5.0.0-SNAPSHOT</version> <version>5.4.0</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.-->
@ -216,11 +203,22 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>net.kyori</groupId>
<artifactId>spigot-api</artifactId> <artifactId>adventure-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version> <version>4.24.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -10,10 +10,9 @@ 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 mineverse.Aust1n46.chat.MineverseChat;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
@ -134,14 +133,14 @@ public class Format {
} else { } else {
final String clickText = escapeJsonChars(Format.FormatStringAll( final String clickText = escapeJsonChars(Format.FormatStringAll(
PlaceholderAPI.setBracketPlaceholders(icp.getPlayer(), jsonAttribute.getClickText()))); 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; final String hoverJson;
if (hoverText.isEmpty()) { if (hoverText.isEmpty()) {
hoverJson = StringUtils.EMPTY; hoverJson = StringUtils.EMPTY;
} else { } else {
hoverJson = ",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" hoverJson = ",\"hover_event\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
+ convertToJsonColors(hoverText) + "]}}"; + convertToJsonColors(hoverText) + "]}}";
} }
temp += convertToJsonColors(lastCode + formattedPlaceholder, actionJson + hoverJson) + ","; temp += convertToJsonColors(lastCode + formattedPlaceholder, actionJson + hoverJson) + ",";
@ -191,9 +190,9 @@ public class Format {
https = "s"; https = "s";
temp += convertToJsonColors(lastCode + link, temp += convertToJsonColors(lastCode + link,
",\"underlined\":" + underlineURLs() ",\"underlined\":" + underlineURLs()
+ ",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http" + https + "://" + ",\"click_event\":{\"action\":\"open_url\",\"url\":\"http" + https + "://"
+ ChatColor.stripColor(link.replace("http://", "").replace("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) + "]}}") + convertToJsonColors(lastCode + link) + "]}}")
+ ","; + ",";
lastCode = getLastCode(lastCode + link); lastCode = getLastCode(lastCode + link);
@ -455,9 +454,9 @@ public class Format {
if (player.hasPermission("venturechat.gui")) { if (player.hasPermission("venturechat.gui")) {
json = json.substring(0, json.length() - 1); json = json.substring(0, json.length() - 1);
json += "," + Format.convertToJsonColors(Format.FormatStringAll(getInstance().getConfig().getString("guiicon")), 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 + " " + hash
+ "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[" + "\"},\"hover_event\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":["
+ Format.convertToJsonColors( + Format.convertToJsonColors(
Format.FormatStringAll(getInstance().getConfig().getString("guitext"))) Format.FormatStringAll(getInstance().getConfig().getString("guitext")))
+ "]}}") + "]}}")
@ -960,15 +959,23 @@ public class Format {
public static void playMessageSound(MineverseChatPlayer mcp) { public static void playMessageSound(MineverseChatPlayer mcp) {
Player player = mcp.getPlayer(); Player player = mcp.getPlayer();
String soundName = getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND); String soundName = getInstance().getConfig().getString("message_sound", DEFAULT_MESSAGE_SOUND);
if(!soundName.equalsIgnoreCase("None")) { if (!soundName.equalsIgnoreCase("None")) {
Sound messageSound = getSound(soundName); try {
player.playSound(player.getLocation(), messageSound, 1, 0); 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) { private static Sound getSound(String soundName) {
if(Arrays.asList(Sound.values()).stream().map(Sound::toString).collect(Collectors.toList()).contains(soundName)) { for (Sound sound : Sound.values()) {
return Sound.valueOf(soundName); if (sound.toString().equalsIgnoreCase(soundName)) {
return sound;
}
} }
Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!")); Bukkit.getConsoleSender().sendMessage(Format.FormatStringAll("&8[&eVentureChat&8]&c - Message sound invalid!"));
return getDefaultMessageSound(); return getDefaultMessageSound();