- In MiniMessage messages placeholders were erroneously not supported by PlaceholderAPI
- Smaller API changes in T2Csend
This commit is contained in:
JaTiTV 2023-08-04 16:29:38 +02:00
parent f40c47e6ab
commit 150d9f4933
4 changed files with 35 additions and 77 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>15.8</version> <version>15.9</version>
<!--version>VERSION_snapshot-0</version--> <!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version--> <!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version--> <!--version>VERSION_dev-0</version-->

View File

@ -8,25 +8,11 @@ import org.bukkit.entity.Player;
public class T2ChoverModule { public class T2ChoverModule {
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void modulePlayer(String text, String hover, String action, String actionValue, Player player) { 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") modulePlayer((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null")
+ "/*/" + (actionValue != null ? actionValue : "null"), player); + "/*/" + (actionValue != null ? actionValue : "null"), player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void modulePlayer(String msg, Player player) { public static void modulePlayer(String msg, Player player) {
if (msg.contains("/*/")) { if (msg.contains("/*/")) {
t2cmodule(msg, player); t2cmodule(msg, player);
@ -35,24 +21,10 @@ public class T2ChoverModule {
T2CminiMessage.sendPlayerMiniMessage(msg, player); T2CminiMessage.sendPlayerMiniMessage(msg, player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendSenderMiniMessage(msg, sender);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void moduleSender(String msg, CommandSender sender) { public static void moduleSender(String msg, CommandSender sender) {
T2CminiMessage.sendSenderMiniMessage(msg, sender); T2CminiMessage.sendSenderMiniMessage(msg, sender);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
public static void moduleConsole(String msg) { public static void moduleConsole(String msg) {
if (T2CodeLibMain.getMmIsLoad()) { if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendConsoleMiniMessage(msg); T2CminiMessage.sendConsoleMiniMessage(msg);
@ -61,13 +33,6 @@ public class T2ChoverModule {
Bukkit.getConsoleSender().sendMessage(msg); Bukkit.getConsoleSender().sendMessage(msg);
} }
/**
* @deprecated reason this method is deprecated <br/>
* The T2Code Hover Module will be removed soon,<br/>
* please use 'T2CminiMessage.sendPlayerMiniMessage(msg, player);'<br/>
* and the Kyori MiniMessage format!
*/
@Deprecated
private static void t2cmodule(String msg, Player player) { private static void t2cmodule(String msg, Player player) {
String[] split = msg.split("/\\*/"); String[] split = msg.split("/\\*/");
int i = split.length; int i = split.length;

View File

@ -11,7 +11,12 @@ public class T2CminiMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure(); private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void sendSenderMiniMessage(String msg, CommandSender sender) { 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) { public static void sendConsoleMiniMessage(String msg) {
@ -19,7 +24,7 @@ public class T2CminiMessage {
} }
public static void sendPlayerMiniMessage(String msg, Player player) { 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) { protected static Component replace(String text) {

View File

@ -7,71 +7,47 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
public class T2Csend { public class T2Csend {
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void console(String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleConsole(msg); T2ChoverModule.moduleConsole(msg);
} }
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void player(Player player, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.modulePlayer(msg, player); T2ChoverModule.modulePlayer(msg, player);
} }
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void sender(CommandSender sender, String msg) {
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender); T2ChoverModule.moduleSender(msg, sender);
} }
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void console(Object object) {
String msg = String.valueOf(object); for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.moduleConsole(msg); T2ChoverModule.moduleConsole(msg);
}
} }
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void player(Player player, Object object) {
String msg = String.valueOf(object); for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) continue;
T2ChoverModule.modulePlayer(msg, player); T2ChoverModule.modulePlayer(msg, player);
}
} }
/**
* @deprecated reason this method is deprecated <br/>
* 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) { public static void sender(CommandSender sender, Object object) {
String msg = String.valueOf(object); for (String msg : list(object)){
if (msg == null || msg.contains("[empty]")) return; if (msg == null || msg.contains("[empty]")) return;
T2ChoverModule.moduleSender(msg, sender); T2ChoverModule.moduleSender(msg, sender);
}
} }
public static void title(Player player, @Nullable String title, @Nullable String subtitle) { 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) { public static void error(Plugin plugin, String msg) {
plugin.getLogger().log(Level.SEVERE, msg); plugin.getLogger().log(Level.SEVERE, msg);
} }
private static ArrayList<String> list(Object object){
ArrayList<String> list = new ArrayList<>();
if (object instanceof List){
list= (ArrayList<String>) object;
}
if (object instanceof String){
list.add((String) object);
}
return list;
}
} }