Allow urls to be clickable in chat

This commit is contained in:
destro174
2021-08-17 22:54:24 +02:00
parent 47fb205001
commit aebb1b83a5
4 changed files with 57 additions and 2 deletions
@@ -17,6 +17,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.Template;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -58,6 +59,8 @@ public class ChatHandler {
if(updatedMessage.contains("[i]"))
updatedMessage = updatedMessage.replace("[i]", "<[i]>");
updatedMessage = Utility.formatText(updatedMessage);
List<Template> templates = new ArrayList<>(List.of(
Template.of("message", updatedMessage),
Template.of("sendername", player.getName()),
@@ -110,6 +113,8 @@ public class ChatHandler {
if(updatedMessage.contains("[i]"))
updatedMessage = updatedMessage.replace("[i]", "<[i]>"); // end of todo
updatedMessage = Utility.formatText(updatedMessage);
List<Template> templates = new ArrayList<>(List.of(
Template.of("sender", senderName),
Template.of("prefix", prefix),
@@ -145,6 +150,8 @@ public class ChatHandler {
if(updatedMessage.contains("[i]")) updatedMessage = updatedMessage.replace("[i]", "<[i]>");
updatedMessage = Utility.formatText(updatedMessage);
List<Template> templates = new ArrayList<>(List.of(
Template.of("sender", senderName),
Template.of("message", updatedMessage),
@@ -179,6 +186,8 @@ public class ChatHandler {
if(updatedMessage.contains("[i]")) updatedMessage = updatedMessage.replace("[i]", "<[i]>");
updatedMessage = Utility.formatText(updatedMessage);
List<Template> templates = new ArrayList<>(List.of(
Template.of("sender", senderName),
Template.of("sendername", senderName),
@@ -76,6 +76,8 @@ public class ChatListener implements Listener, ChatRenderer {
if(message.contains("[i]"))
message = message.replace("[i]", "<[i]>"); // end of todo
message = Utility.formatText(message);
List<Template> templates = new ArrayList<>(List.of(
Template.of("message", message),
Template.of("[i]", ChatHandler.itemComponent(player.getInventory().getItemInMainHand()))