diff --git a/pom.xml b/pom.xml index 4ff1bfc..1f6ed4e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,9 +6,10 @@ net.t2code T2CodeLib - 14.0 + 14.1 jar + T2CodeLib diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/bungeePlayers/T2CbungeePlayers.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/bungeePlayers/T2CbungeePlayers.java index 16a400d..f6221b9 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/bungeePlayers/T2CbungeePlayers.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/bungeePlayers/T2CbungeePlayers.java @@ -51,7 +51,6 @@ public class T2CbungeePlayers implements PluginMessageListener { } catch (IOException e) { e.printStackTrace(); } - } public static void callAllBungeePlayers() { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Creplace.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Creplace.java index 651191f..5e0f4c3 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Creplace.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Creplace.java @@ -23,6 +23,47 @@ public class T2Creplace { .replace("[nl]", "\n"))); } + public static Object replaceObject(String prefix, Object object) { + if (object instanceof String) { + object = replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü") + .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") + .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"); + } + + if ((object instanceof List) || (object instanceof ArrayList)) { + List in = (List) object; + List output = new ArrayList<>(); + for (String input : in) { + output.add(replaceLegacyColor(input).replace("[prefix]", prefix) + .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") + .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") + .replace("[nl]", "\n")); + } + object = output; + } + return object; + } + + public static Object replaceObject(String prefix, Player player, Object object) { + if (object instanceof String) { + object = PlaceholderAPI.setPlaceholders(player, replaceLegacyColor((String) object).replace("[prefix]", prefix).replace("[ue]", "ü") + .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") + .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n")); + } + if (object instanceof List) { + List in = (List) object; + List output = new ArrayList<>(); + for (String input : in) { + output.add(PlaceholderAPI.setPlaceholders(player, replaceLegacyColor(input).replace("[prefix]", prefix) + .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") + .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") + .replace("[nl]", "\n"))); + } + object = output; + } + return object; + } + public static List replace(String prefix, List Text) { List output = new ArrayList<>(); for (String input : Text) { @@ -35,7 +76,7 @@ public class T2Creplace { } public static List replace(String prefix, Player player, List Text) { - List output = new ArrayList(); + List output = new ArrayList<>(); if (player == null) { return Collections.singletonList("player is null"); } @@ -52,7 +93,7 @@ public class T2Creplace { } public static List replacePrice(String prefix, List Text, String price) { - List rp = new ArrayList(); + List rp = new ArrayList<>(); for (String s : Text) { rp.add(replaceLegacyColor(s).replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") @@ -82,7 +123,7 @@ public class T2Creplace { } public static List replacePrice(String prefix, Player player, List Text, String price) { - List rp = new ArrayList(); + List rp = new ArrayList<>(); for (String s : Text) { rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") 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 c91a365..bef3343 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 @@ -24,6 +24,29 @@ public class T2Csend { T2ChoverModule.modulePlayer(msg, player); } + public static void sender(CommandSender sender, String msg) { + if (msg == null || msg.contains("[empty]")) return; + T2ChoverModule.moduleSender(msg, sender); + } + + public static void console(Object object) { + String msg = String.valueOf(object); + if (msg == null || msg.contains("[empty]")) return; + T2ChoverModule.moduleConsole(msg); + } + + public static void player(Player player, Object object) { + String msg = String.valueOf(object); + if (msg == null || msg.contains("[empty]")) return; + T2ChoverModule.modulePlayer(msg, player); + } + + public static void sender(CommandSender sender, Object object) { + String msg = String.valueOf(object); + if (msg == null || msg.contains("[empty]")) return; + T2ChoverModule.moduleSender(msg, sender); + } + public static void title(Player player, @Nullable String title, @Nullable String subtitle) { player.sendTitle(title, subtitle); } @@ -32,11 +55,6 @@ public class T2Csend { player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); } - public static void sender(CommandSender sender, String msg) { - if (msg == null || msg.contains("[empty]")) return; - T2ChoverModule.moduleSender(msg, sender); - } - public static void debug(Plugin plugin, String msg) { debug(plugin, msg, null); } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java index 29b0abd..f9c54c2 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/yaml/T2Cconfig.java @@ -17,6 +17,11 @@ public class T2Cconfig { YamlConfiguration.set(path, value); } } + public static void set(String path, Object value, YamlConfiguration YamlConfiguration) { + if (!YamlConfiguration.contains(path)) { + YamlConfiguration.set(path, value); + } + } public static void set(String path, YamlConfiguration YamlConfiguration) { YamlConfiguration.set(path, null); @@ -119,6 +124,10 @@ public class T2Cconfig { return T2Creplace.replace(prefix, yamlConfiguration.getString(path)); } + public static Object selectObject(String prefix, String path, YamlConfiguration yamlConfiguration) { + return T2Creplace.replaceObject(prefix, yamlConfiguration.get(path)); + } + public static Integer selectInt(String path, YamlConfiguration yamlConfiguration) { return (yamlConfiguration.getInt(path)); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java index 50b494f..c7d3e9f 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -108,6 +108,9 @@ public final class T2CodeLibMain extends JavaPlugin { Metrics.Bstats(plugin, Util.getBstatsID()); if (SelectLibConfig.getBungee()) { Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); + + + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bonlp"); if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:bonlp")) { T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bonlp");