From 150d9f4933c325c054e63031587c0d82ef942ff1 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Fri, 4 Aug 2023 16:29:38 +0200 Subject: [PATCH] 15.9 - In MiniMessage messages placeholders were erroneously not supported by PlaceholderAPI - Smaller API changes in T2Csend --- pom.xml | 2 +- .../SPIGOT/api/messages/T2ChoverModule.java | 35 ---------- .../SPIGOT/api/messages/T2CminiMessage.java | 9 ++- .../SPIGOT/api/messages/T2Csend.java | 66 ++++++++----------- 4 files changed, 35 insertions(+), 77 deletions(-) diff --git a/pom.xml b/pom.xml index 531be8a..fc90667 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 15.8 + 15.9 diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2ChoverModule.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2ChoverModule.java index 9a0d774..7dbbd17 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2ChoverModule.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2ChoverModule.java @@ -8,25 +8,11 @@ import org.bukkit.entity.Player; public class T2ChoverModule { - /** - * @deprecated reason this method is deprecated
- * The T2Code Hover Module will be removed soon,
- * please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'
- * and the Kyori MiniMessage format! - */ - @Deprecated public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) { modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null") + "/*/" + (actionValue != null ? actionValue : "null"), player); } - /** - * @deprecated reason this method is deprecated
- * The T2Code Hover Module will be removed soon,
- * please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'
- * and the Kyori MiniMessage format! - */ - @Deprecated public static void modulePlayer(String msg, Player player) { if (msg.contains("/*/")) { t2cmodule(msg, player); @@ -35,24 +21,10 @@ public class T2ChoverModule { T2CminiMessage.sendPlayerMiniMessage(msg, player); } - /** - * @deprecated reason this method is deprecated
- * The T2Code Hover Module will be removed soon,
- * please use 'T2CminiMessage.sendSenderMiniMessage(msg, sender);'
- * and the Kyori MiniMessage format! - */ - @Deprecated public static void moduleSender(String msg, CommandSender sender) { T2CminiMessage.sendSenderMiniMessage(msg, sender); } - /** - * @deprecated reason this method is deprecated
- * The T2Code Hover Module will be removed soon,
- * please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'
- * and the Kyori MiniMessage format! - */ - @Deprecated public static void moduleConsole(String msg) { if (T2CodeLibMain.getMmIsLoad()) { T2CminiMessage.sendConsoleMiniMessage(msg); @@ -61,13 +33,6 @@ public class T2ChoverModule { Bukkit.getConsoleSender().sendMessage(msg); } - /** - * @deprecated reason this method is deprecated
- * The T2Code Hover Module will be removed soon,
- * please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'
- * and the Kyori MiniMessage format! - */ - @Deprecated private static void t2cmodule(String msg, Player player) { String[] split = msg.split("/\\*/"); int i = split.length; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java index 12d8940..a6b5166 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java @@ -11,7 +11,12 @@ public class T2CminiMessage { private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure(); public static void sendSenderMiniMessage(String msg, CommandSender sender) { - bukkitAudiences.sender(sender).sendMessage(replace(msg)); + String string = ""; + if (sender instanceof Player) { + Player player = (Player) sender; + string =T2Creplace.replace("",player,msg); + } else string = msg; + bukkitAudiences.sender(sender).sendMessage(replace(string)); } public static void sendConsoleMiniMessage(String msg) { @@ -19,7 +24,7 @@ public class T2CminiMessage { } public static void sendPlayerMiniMessage(String msg, Player player) { - bukkitAudiences.player(player).sendMessage(replace(msg)); + bukkitAudiences.player(player).sendMessage(replace(T2Creplace.replace("", player, msg))); } protected static Component replace(String text) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java index 1c40be2..8fb8196 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Csend.java @@ -7,71 +7,47 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; public class T2Csend { - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated public static void console(String msg) { if (msg == null || msg.contains("[empty]")) return; T2ChoverModule.moduleConsole(msg); } - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated public static void player(Player player, String msg) { if (msg == null || msg.contains("[empty]")) return; T2ChoverModule.modulePlayer(msg, player); } - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated public static void sender(CommandSender sender, String msg) { if (msg == null || msg.contains("[empty]")) return; T2ChoverModule.moduleSender(msg, sender); } - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated public static void console(Object object) { - String msg = String.valueOf(object); - if (msg == null || msg.contains("[empty]")) return; - T2ChoverModule.moduleConsole(msg); + for (String msg : list(object)){ + if (msg == null || msg.contains("[empty]")) continue; + T2ChoverModule.moduleConsole(msg); + } } - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated public static void player(Player player, Object object) { - String msg = String.valueOf(object); - if (msg == null || msg.contains("[empty]")) return; - T2ChoverModule.modulePlayer(msg, player); + for (String msg : list(object)){ + if (msg == null || msg.contains("[empty]")) continue; + T2ChoverModule.modulePlayer(msg, player); + } } - /** - * @deprecated reason this method is deprecated
- * Please note that these methods will be rebuilt to MiniMessage in the future and from then on the T2Code Hover Module will be removed! - */ - @Deprecated + public static void sender(CommandSender sender, Object object) { - String msg = String.valueOf(object); - if (msg == null || msg.contains("[empty]")) return; - T2ChoverModule.moduleSender(msg, sender); + for (String msg : list(object)){ + if (msg == null || msg.contains("[empty]")) return; + T2ChoverModule.moduleSender(msg, sender); + } } public static void title(Player player, @Nullable String title, @Nullable String subtitle) { @@ -106,4 +82,16 @@ public class T2Csend { public static void error(Plugin plugin, String msg) { plugin.getLogger().log(Level.SEVERE, msg); } + + private static ArrayList list(Object object){ + ArrayList list = new ArrayList<>(); + + if (object instanceof List){ + list= (ArrayList) object; + } + if (object instanceof String){ + list.add((String) object); + } + return list; + } }