From df22ddd9d2424080949badf71e5fe85e1c8cc2eb Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 7 Jul 2022 06:54:15 +0200 Subject: [PATCH 1/4] 12.4_dev-1 --- pom.xml | 4 ++-- src/main/java/net/t2code/lib/Spigot/Lib/commands/Tab.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a17616d..213b65f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 12.3 - + 12.4_dev-1 + net.t2code jar diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/commands/Tab.java b/src/main/java/net/t2code/lib/Spigot/Lib/commands/Tab.java index 6abb6cd..7e66b81 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/commands/Tab.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/commands/Tab.java @@ -75,7 +75,7 @@ public class Tab { } - private static Boolean passend(String command, String arg) { + public static Boolean passend(String command, String arg) { for (int i = 0; i < arg.toUpperCase().length(); i++) { if (arg.toUpperCase().length() >= command.toUpperCase().length()) { return false; -- 2.34.1 From c89afa3c68f4574733a8ed1eef2e75313145bc54 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 7 Jul 2022 13:43:50 +0200 Subject: [PATCH 2/4] add MiniMessages and small code changes --- .idea/libraries/Maven__junit_junit_4_10.xml | 13 --- .../Maven__org_hamcrest_hamcrest_core_1_1.xml | 13 --- T2CodeLib.iml | 16 +++- pom.xml | 22 +++++ .../lib/Spigot/Lib/messages/HoverModule.java | 24 +++-- .../Spigot/Lib/plugins/T2CPluginManager.java | 22 +++++ .../lib/Spigot/Lib/replace/Replace.java | 91 +++++++++++++------ .../lib/Spigot/Lib/update/UpdateAPI.java | 2 +- .../t2code/lib/Spigot/system/CmdExecuter.java | 5 + .../net/t2code/lib/Spigot/system/Metrics.java | 2 +- .../t2code/lib/Spigot/system/T2CodeMain.java | 14 ++- .../Spigot/system/config/ConfigCreate.java | 39 ++------ .../Spigot/system/config/SelectLibConfig.java | 42 +++++++-- .../Spigot/system/languages/SelectLibMsg.java | 6 +- 14 files changed, 204 insertions(+), 107 deletions(-) delete mode 100644 .idea/libraries/Maven__junit_junit_4_10.xml delete mode 100644 .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml create mode 100644 src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java diff --git a/.idea/libraries/Maven__junit_junit_4_10.xml b/.idea/libraries/Maven__junit_junit_4_10.xml deleted file mode 100644 index ed8bf5f..0000000 --- a/.idea/libraries/Maven__junit_junit_4_10.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml deleted file mode 100644 index acdf443..0000000 --- a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/T2CodeLib.iml b/T2CodeLib.iml index 18e2db2..10d72ff 100644 --- a/T2CodeLib.iml +++ b/T2CodeLib.iml @@ -44,7 +44,7 @@ - + @@ -53,5 +53,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 213b65f..4f2455d 100644 --- a/pom.xml +++ b/pom.xml @@ -57,10 +57,12 @@ + spigot-repo https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + Builders-Paradise https://repo.t2code.net/repository/Builders-Paradise/ @@ -69,14 +71,17 @@ T2Code https://repo.t2code.net/repository/T2Code/ + jitpack.io https://jitpack.io + placeholderapi https://repo.extendedclip.com/content/repositories/placeholderapi/ + BenCodez Repo https://nexus.bencodez.com/repository/maven-public/ @@ -84,12 +89,15 @@ + org.spigotmc spigot-api 1.19-R0.1-SNAPSHOT provided + + net.t2code bungee @@ -100,23 +108,37 @@ LuckyBox-API 4.2.7 + com.github.MilkBowl VaultAPI 1.7 provided + me.clip placeholderapi 2.11.1 provided + com.bencodez votingplugin LATEST provided + + + net.kyori + adventure-text-minimessage + 4.11.0 + + + net.kyori + adventure-platform-bukkit + 4.1.1 + diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java b/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java index f6bf1f3..d38c1cf 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java @@ -1,7 +1,13 @@ package net.t2code.lib.Spigot.Lib.messages; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; import net.md_5.bungee.api.chat.ClickEvent; + + +import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.system.T2CodeMain; +import net.t2code.lib.Spigot.system.config.SelectLibConfig; import org.bukkit.entity.Player; public class HoverModule { @@ -12,20 +18,26 @@ public class HoverModule { } public static void module(String msg, Player player) { - if (!msg.contains("/*/")) { - player.sendMessage(msg); + if (msg.contains("/*/") || !SelectLibConfig.getMiniMessage()) { + t2cmodule(msg, player); return; } + MiniMessage mm = MiniMessage.miniMessage(); + Component parsed = mm.deserialize(Replace.convertColorCode(msg)); + T2CodeMain.adventure.player(player).sendMessage(parsed); + } + + private static void t2cmodule(String msg, Player player) { String[] split = msg.split("/\\*/"); int i = split.length; String text = null; String hover = null; String action = null; String actionValue = null; - if (i > 0) text= split[0]; - if (i > 1) hover =split[1]; - if (i > 2)action = split[2]; - if (i > 3)actionValue = split[3]; + if (i > 0) text = split[0]; + if (i > 1) hover = split[1]; + if (i > 2) action = split[2]; + if (i > 3) actionValue = split[3]; TextBuilder textBuilder = new TextBuilder(text); if (hover != null && !hover.equals("null")) { diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java new file mode 100644 index 0000000..f70ef77 --- /dev/null +++ b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java @@ -0,0 +1,22 @@ +package net.t2code.lib.Spigot.Lib.plugins; + +import org.bukkit.Bukkit; + +import java.util.Objects; + +public class T2CPluginManager { + + public static void restart(String plugin) { + + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onEnable(); + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onDisable(); + } + + public static void enable(String plugin) { + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onEnable(); + } + + public static void disable(String plugin) { + Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onDisable(); + } +} diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java b/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java index 61020c2..47a6536 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java @@ -3,36 +3,32 @@ package net.t2code.lib.Spigot.Lib.replace; import me.clip.placeholderapi.PlaceholderAPI; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.system.T2CodeMain; -import net.t2code.lib.Spigot.system.config.SelectLibConfig; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; import java.util.List; public class Replace { public static String replace(String prefix, String Text) { - return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") + + return replaceLegacyColor(Text).replace("[prefix]", prefix).replace("[ue]", "ü") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") - .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n") - ; + .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n"); } public static String replace(String prefix, Player player, String Text) { - return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") + return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") - .replace("[nl]", "\n")); + .replace("[nl]", "\n"))); } public static List replace(String prefix, List Text) { List output = new ArrayList<>(); for (String input : Text) { - output.add(input.replace("[prefix]", prefix).replace("&", "§") + output.add(replaceLegacyColor(input).replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[nl]", "\n")); @@ -49,7 +45,7 @@ public class Replace { return Collections.singletonList("Text is null"); } for (String input : Text) { - output.add(PlaceholderAPI.setPlaceholders(player, input.replace("[prefix]", prefix).replace("&", "§") + 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"))); @@ -60,7 +56,7 @@ public class Replace { public static List replacePrice(String prefix, List Text, String price) { List rp = new ArrayList(); for (String s : Text) { - rp.add(s.replace("[prefix]", prefix).replace("&", "§") + rp.add(replaceLegacyColor(s).replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") .replace("[nl]", "\n").replace("[price]", String.valueOf(price))); @@ -69,40 +65,81 @@ public class Replace { } public static String removeColorCode(String value) { - String text = value.replace("&", "§"); - while (text.contains("§")) { - int stelle = text.indexOf("§"); - if (text.length() >= stelle + 2) { - text = text.substring(0, stelle) + text.substring(stelle + 2); - } else { - text = text.substring(0, stelle) + text.substring(stelle + 1); - } - } - return (text); + return value.replace("&0", "").replace("&1", "").replace("&2", "").replace("&3", "") + .replace("&4", "").replace("&5", "").replace("&6", "").replace("&7", "") + .replace("&8", "").replace("&9", "").replace("&a", "").replace("&b", "") + .replace("&c", "").replace("&d", "").replace("&e", "").replace("&f", "") + .replace("&k", "").replace("&l", "").replace("&m", "").replace("&n", "") + .replace("&o", "").replace("&r", ""); + // String text = value.replace("&", "§"); + // while (text.contains("§")) { + // int stelle = text.indexOf("§"); + // if (text.length() >= stelle + 2) { + // text = text.substring(0, stelle) + text.substring(stelle + 2); + // } else { + // text = text.substring(0, stelle) + text.substring(stelle + 1); + // } + // } + // return (text); } public static List replacePrice(String prefix, Player player, List Text, String price) { List rp = new ArrayList(); for (String s : Text) { - rp.add(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix).replace("&", "§") + rp.add(replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, s.replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä").replace("[nl]", "\n") - .replace("[price]", String.valueOf(price)))); + .replace("[price]", String.valueOf(price))))); } return rp; } public static String replacePrice(String prefix, String Text, String price) { - return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") + return replaceLegacyColor(Text).replace("[prefix]", prefix) + .replace("&o", "§o").replace("&r", "§r").replace("[ue]", "ü") .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") .replace("[ae]", "ä").replace("[AE]", "Ä").replace("[price]", String.valueOf(price)) .replace("[nl]", "\n"); } public static String replacePrice(String prefix, Player player, String Text, String price) { - return PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix).replace("&", "§") + return replaceLegacyColor(PlaceholderAPI.setPlaceholders(player, Text.replace("[prefix]", prefix) .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") - .replace("[price]", String.valueOf(price)).replace("[nl]", "\n")); + .replace("[price]", String.valueOf(price)).replace("[nl]", "\n"))); + } + + public static String replaceLegacyColor(String text) { + return text.replace("&0", "§0").replace("&1", "§1").replace("&2", "§2").replace("&3", "§3") + .replace("&4", "§4").replace("&5", "§5").replace("&6", "§6").replace("&7", "§7") + .replace("&8", "§8").replace("&9", "§9").replace("&a", "§a").replace("&b", "§b") + .replace("&c", "§c").replace("&d", "§d").replace("&e", "§e").replace("&f", "§f") + .replace("&k", "§k").replace("&l", "§l").replace("&m", "§m").replace("&n", "§n") + .replace("&o", "§o").replace("&r", "§r"); + } + + public static String convertColorCode(String msg) { + return msg.replace("§0", "") + .replace("§1", "") + .replace("§2", "") + .replace("§3", "") + .replace("§4", "") + .replace("§5", "") + .replace("§6", "") + .replace("§7", "") + .replace("§8", "") + .replace("§9", "") + .replace("§a", "") + .replace("§b", "") + .replace("§c", "") + .replace("§d", "") + .replace("§e", "") + .replace("§f", "") + .replace("§k", "") + .replace("§l", "") + .replace("§m", "") + .replace("§n", "") + .replace("§o", "") + .replace("§r", ""); } } diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java index c0aa0c4..9fa4085 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java @@ -21,7 +21,7 @@ public class UpdateAPI { public static HashMap PluginVersionen = new HashMap<>(); public static void join(Plugin plugin, String prefix, String perm, Player player, String spigot, String discord) { - if (!SelectLibConfig.UpdateCheckOnJoin) { + if (!SelectLibConfig.getUpdateCheckOnJoin()) { return; } String pluginVersion = plugin.getDescription().getVersion(); diff --git a/src/main/java/net/t2code/lib/Spigot/system/CmdExecuter.java b/src/main/java/net/t2code/lib/Spigot/system/CmdExecuter.java index 5676623..21d9d29 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/CmdExecuter.java +++ b/src/main/java/net/t2code/lib/Spigot/system/CmdExecuter.java @@ -3,6 +3,7 @@ package net.t2code.lib.Spigot.system; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; +import net.t2code.lib.Spigot.system.config.SelectLibConfig; import net.t2code.lib.Util; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -32,6 +33,9 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { case "ver": T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), T2CodeMain.getAutor(), T2CodeMain.getVersion(), UpdateAPI.PluginVersionen.get(T2CodeMain.getPerm().getName()).publicVersion); return false; + case "reloadconfig": + SelectLibConfig.onSelect(); + return false; case "debug": if (args.length != 2) { send.sender(sender, "§4Use: §7/t2code debug createReportLog"); @@ -53,6 +57,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { private static HashMap arg1 = new HashMap() {{ put("debug", "t2code.admin"); put("info", "t2code.admin"); + put("reloadconfig", "t2code.admin"); }}; @Override diff --git a/src/main/java/net/t2code/lib/Spigot/system/Metrics.java b/src/main/java/net/t2code/lib/Spigot/system/Metrics.java index a4c7f02..45e4e95 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/Metrics.java +++ b/src/main/java/net/t2code/lib/Spigot/system/Metrics.java @@ -31,7 +31,7 @@ public class Metrics { public static void Bstats(Plugin plugin, int bstatsID) { int pluginId = bstatsID; // <-- Replace with the id of your plugin! Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId); - metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.UpdateCheckOnJoin))); + metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectLibConfig.getUpdateCheckOnJoin()))); } private final Plugin plugin; diff --git a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java index e0a6de8..09625c5 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java +++ b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java @@ -1,7 +1,6 @@ package net.t2code.lib.Spigot.system; -import com.bencodez.votingplugin.VotingPluginHooks; -import com.bencodez.votingplugin.user.UserManager; +import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; import net.t2code.lib.Spigot.Lib.items.ItemVersion; @@ -19,6 +18,7 @@ import net.t2code.lib.Spigot.system.languages.SelectLibMsg; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import org.checkerframework.checker.nullness.qual.NonNull; import java.io.File; import java.util.List; @@ -29,6 +29,9 @@ public final class T2CodeMain extends JavaPlugin { return plugin.getDataFolder(); } + public static BukkitAudiences adventure; + + private static T2CodeMain plugin; private static Economy eco = null; private static Permission perm = null; @@ -101,6 +104,7 @@ public final class T2CodeMain extends JavaPlugin { plugin = this; autor = plugin.getDescription().getAuthors(); version = plugin.getDescription().getVersion(); + this.adventure = BukkitAudiences.create(this); long long_; long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord); if (Util.getSnapshot()) { @@ -173,11 +177,15 @@ public final class T2CodeMain extends JavaPlugin { @Override public void onDisable() { // Plugin shutdown logic - if (SelectLibConfig.InventoriesCloseByServerStop) { + if (SelectLibConfig.getInventoriesCloseByServerStop()) { for (Player player : Bukkit.getOnlinePlayers()) { player.closeInventory(); } } + if(this.adventure != null) { + this.adventure.close(); + this.adventure = null; + } Vault.vaultDisable(); T2CodeTemplate.onDisable(prefix, autor, version, spigot, discord); } diff --git a/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java b/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java index 2f9dffe..93a97b2 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java +++ b/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java @@ -11,24 +11,6 @@ import java.io.IOException; public class ConfigCreate { - private static Boolean UpdateCheckOnJoin = true; - private static Integer UpdateCheckTimeInterval = 60; - private static Boolean Debug = false; - private static String language = "english"; - - - private static Boolean mySQL = false; - private static String Storage = "YML"; - private static String ip = "localhost"; - private static Integer port = 3306; - private static String database = "database"; - private static String user = "root"; - private static String password = "password"; - private static Boolean SSL = false; - - private static Boolean Bungee = false; - private static String thisServer = "server"; - public static void configCreate() { Long long_ = Long.valueOf(System.currentTimeMillis()); if (new File(T2CodeMain.getPath(), "config.yml").exists()){ @@ -39,24 +21,15 @@ public class ConfigCreate { File config = new File(T2CodeMain.getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); - Config.set("Plugin.UpdateCheck.OnJoin", UpdateCheckOnJoin, yamlConfiguration); - Config.set("Plugin.UpdateCheck.TimeInterval", UpdateCheckTimeInterval, yamlConfiguration); - Config.set("Plugin.language", language, yamlConfiguration); + Config.set("Plugin.UpdateCheck.OnJoin", true, yamlConfiguration); + Config.set("Plugin.UpdateCheck.TimeInterval", 60, yamlConfiguration); + Config.set("Plugin.language", "english", yamlConfiguration); - Config.set("BungeeCord.Enable", Bungee, yamlConfiguration); - Config.set("BungeeCord.ThisServer", thisServer, yamlConfiguration); + Config.set("BungeeCord.Enable", false, yamlConfiguration); + Config.set("BungeeCord.ThisServer", "server", yamlConfiguration); Config.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); - // Config.set("Storage.MySQL.Enable", mySQL, yamlConfiguration); - // Config.set("Storage.Type", Storage, yamlConfiguration); - // Config.set("Storage.MySQL.IP", ip, yamlConfiguration); - // Config.set("Storage.MySQL.Port", port, yamlConfiguration); - // Config.set("Storage.MySQL.Database", database, yamlConfiguration); - // Config.set("Storage.MySQL.User", user, yamlConfiguration); - // Config.set("Storage.MySQL.Password", password, yamlConfiguration); - // Config.set("Storage.MySQL.SSL", SSL, yamlConfiguration); - - + Config.set("PlayerMessage.MiniMessage", false,yamlConfiguration); try { yamlConfiguration.save(config); diff --git a/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java b/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java index f5ee551..5ccb2cd 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java +++ b/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java @@ -8,12 +8,13 @@ import java.io.File; public class SelectLibConfig { - public static Boolean UpdateCheckOnJoin; - public static Boolean t2cTestDevelopment; - public static Integer UpdateCheckTimeInterval; - public static Boolean Debug; - public static String language; - public static Boolean InventoriesCloseByServerStop; + private static Boolean UpdateCheckOnJoin; + private static Boolean t2cTestDevelopment; + private static Integer UpdateCheckTimeInterval; + private static Boolean Debug; + private static String language; + private static Boolean InventoriesCloseByServerStop; + private static Boolean miniMessage; public static void onSelect() { File config = new File(T2CodeMain.getPath(), "config.yml"); @@ -25,5 +26,34 @@ public class SelectLibConfig { Debug = yamlConfiguration.getBoolean("Plugin.Debug"); language = yamlConfiguration.getString("Plugin.language"); InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); + miniMessage = yamlConfiguration.getBoolean("PlayerMessage.MiniMessage"); + } + + public static Boolean getUpdateCheckOnJoin() { + return UpdateCheckOnJoin; + } + + public static Boolean getT2cTestDevelopment() { + return t2cTestDevelopment; + } + + public static Integer getUpdateCheckTimeInterval() { + return UpdateCheckTimeInterval; + } + + public static Boolean getDebug() { + return Debug; + } + + public static String getLanguage() { + return language; + } + + public static Boolean getInventoriesCloseByServerStop() { + return InventoriesCloseByServerStop; + } + + public static Boolean getMiniMessage() { + return miniMessage; } } diff --git a/src/main/java/net/t2code/lib/Spigot/system/languages/SelectLibMsg.java b/src/main/java/net/t2code/lib/Spigot/system/languages/SelectLibMsg.java index 7f01bc5..f58db68 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/languages/SelectLibMsg.java +++ b/src/main/java/net/t2code/lib/Spigot/system/languages/SelectLibMsg.java @@ -26,17 +26,17 @@ public class SelectLibMsg { File msg; - msg = new File(T2CodeMain.getPath(), "languages/" + SelectLibConfig.language + "_messages.yml"); + msg = new File(T2CodeMain.getPath(), "languages/" + SelectLibConfig.getLanguage() + "_messages.yml"); if (!msg.isFile()) { send.console(Prefix); send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - send.console(Prefix + " §4The selected §c" + SelectLibConfig.language + " §4language file was not found."); + send.console(Prefix + " §4The selected §c" + SelectLibConfig.getLanguage() + " §4language file was not found."); send.console(Prefix + " §6The default language §eEnglish §6is used!"); send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); send.console(Prefix); msg = new File(T2CodeMain.getPath(), "languages/" + "english_messages.yml"); selectMSG = "english"; - } else selectMSG = SelectLibConfig.language; + } else selectMSG = SelectLibConfig.getLanguage(); YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg); vaultNotSetUp = Replace.replace(prefix, yamlConfiguration_msg.getString("Plugin.VaultNotSetUp")); -- 2.34.1 From 8f05d5c677053ce53e40635200451b77342fb572 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Fri, 8 Jul 2022 19:06:22 +0200 Subject: [PATCH 3/4] 12.4 --- .idea/misc.xml | 2 +- pom.xml | 2 +- .../lib/Spigot/Lib/messages/HoverModule.java | 23 +++++++--- .../t2code/lib/Spigot/Lib/messages/send.java | 4 +- .../lib/Spigot/Lib/replace/Replace.java | 46 +++++++++---------- .../lib/Spigot/Lib/update/UpdateAPI.java | 12 ++--- .../t2code/lib/Spigot/system/T2CodeMain.java | 5 +- .../Spigot/system/config/ConfigCreate.java | 2 - .../Spigot/system/config/SelectLibConfig.java | 5 -- 9 files changed, 51 insertions(+), 50 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index df3b2af..9573c79 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -13,7 +13,7 @@ - + diff --git a/pom.xml b/pom.xml index 4f2455d..1830d0c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 12.4_dev-1 + 12.4 net.t2code diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java b/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java index d38c1cf..9919e51 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/messages/HoverModule.java @@ -7,25 +7,36 @@ import net.md_5.bungee.api.chat.ClickEvent; import net.t2code.lib.Spigot.Lib.replace.Replace; import net.t2code.lib.Spigot.system.T2CodeMain; -import net.t2code.lib.Spigot.system.config.SelectLibConfig; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class HoverModule { - public static void module(String text, String hover, String action, String actionValue, Player player) { - module((text != null ? text : "null") + "/*/" + (hover != null ? hover : "null") + "/*/" + (action != null ? action : "null") + 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); } + private static final MiniMessage mm = MiniMessage.miniMessage(); - public static void module(String msg, Player player) { - if (msg.contains("/*/") || !SelectLibConfig.getMiniMessage()) { + public static void modulePlayer(String msg, Player player) { + if (msg.contains("/*/")) { t2cmodule(msg, player); return; } - MiniMessage mm = MiniMessage.miniMessage(); + miniMessage(msg,player); + } + public static void moduleSender(String msg, CommandSender sender) { + miniMessage(msg,sender); + } + + public static void miniMessage(String msg, Player player){ Component parsed = mm.deserialize(Replace.convertColorCode(msg)); T2CodeMain.adventure.player(player).sendMessage(parsed); } + public static void miniMessage(String msg, CommandSender sender){ + Component parsed = mm.deserialize(Replace.convertColorCode(msg)); + T2CodeMain.adventure.sender(sender).sendMessage(parsed); + } private static void t2cmodule(String msg, Player player) { String[] split = msg.split("/\\*/"); diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/messages/send.java b/src/main/java/net/t2code/lib/Spigot/Lib/messages/send.java index 192f178..0b70dba 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/messages/send.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/messages/send.java @@ -20,7 +20,7 @@ public class send { public static void player( Player player, String msg) { if (msg == null || msg.contains("[empty]")) return; - HoverModule.module(msg, player); + HoverModule.modulePlayer(msg, player); } public static void title( Player player, String msg, String msg2) { @@ -37,7 +37,7 @@ public class send { public static void sender( CommandSender sender, String msg) { if (msg == null || msg.contains("[empty]")) return; - sender.sendMessage(msg); + HoverModule.moduleSender(msg, sender); } public static void debug( Plugin plugin, String msg) { diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java b/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java index 47a6536..3e73ce9 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/replace/Replace.java @@ -118,28 +118,28 @@ public class Replace { .replace("&o", "§o").replace("&r", "§r"); } - public static String convertColorCode(String msg) { - return msg.replace("§0", "") - .replace("§1", "") - .replace("§2", "") - .replace("§3", "") - .replace("§4", "") - .replace("§5", "") - .replace("§6", "") - .replace("§7", "") - .replace("§8", "") - .replace("§9", "") - .replace("§a", "") - .replace("§b", "") - .replace("§c", "") - .replace("§d", "") - .replace("§e", "") - .replace("§f", "") - .replace("§k", "") - .replace("§l", "") - .replace("§m", "") - .replace("§n", "") - .replace("§o", "") - .replace("§r", ""); + public static String convertColorCode(String text) { + return text.replace("&0", "").replace("§0", "") + .replace("&1", "").replace("§1", "") + .replace("&2", "").replace("§2", "") + .replace("&3", "").replace("§3", "") + .replace("&4", "").replace("§4", "") + .replace("&5", "").replace("§5", "") + .replace("&6", "").replace("§6", "") + .replace("&7", "").replace("§7", "") + .replace("&8", "").replace("§8", "") + .replace("&9", "").replace("§9", "") + .replace("&a", "").replace("§a", "") + .replace("&b", "").replace("§b", "") + .replace("&c", "").replace("§c", "") + .replace("&d", "").replace("§d", "") + .replace("&e", "").replace("§e", "") + .replace("&f", "").replace("§f", "") + .replace("&k", "").replace("§k", "") + .replace("&l", "").replace("§l", "") + .replace("&m", "").replace("§m", "") + .replace("&n", "").replace("§n", "") + .replace("&o", "").replace("§o", "") + .replace("&r", "").replace("§r", ""); } } diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java index 9fa4085..f8e5da4 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/update/UpdateAPI.java @@ -81,19 +81,19 @@ public class UpdateAPI { send.player(player, Prefix); if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("dev")) { - HoverModule.module(Prefix + " §6A new §4DEV§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); + HoverModule.modulePlayer(Prefix + " §6A new §4DEV§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); } if (publicVersion.toLowerCase().contains("beta")) { - HoverModule.module(Prefix + " §6A new §2BETA§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); + HoverModule.modulePlayer(Prefix + " §6A new §2BETA§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); } if (publicVersion.toLowerCase().contains("snapshot")) { - HoverModule.module(Prefix + " §6A new §eSNAPSHOT§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); + HoverModule.modulePlayer(Prefix + " §6A new §eSNAPSHOT§6 version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); } } else { - HoverModule.module(Prefix + " §6A new version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); + HoverModule.modulePlayer(Prefix + " §6A new version was found!", "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); } - HoverModule.module(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion, "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); - HoverModule.module(Prefix + " §6You can find more information on Discord.", "§e" + Discord, "OPEN_URL", Discord, player); + HoverModule.modulePlayer(Prefix + " §c" + pluginVersion + " §7-> §a" + publicVersion, "§6You can download it here: §e" + Spigot, "OPEN_URL", Spigot, player); + HoverModule.modulePlayer(Prefix + " §6You can find more information on Discord.", "§e" + Discord, "OPEN_URL", Discord, player); send.player(player, Prefix); } diff --git a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java index 09625c5..3dfc3fc 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java +++ b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java @@ -18,7 +18,6 @@ import net.t2code.lib.Spigot.system.languages.SelectLibMsg; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -import org.checkerframework.checker.nullness.qual.NonNull; import java.io.File; import java.util.List; @@ -128,7 +127,7 @@ public final class T2CodeMain extends JavaPlugin { if (MCVersion.minecraft1_19) { send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); send.console(prefix ); - send.warning(this, "The 1.19 is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + send.warning(this, "The 1.19.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); send.console(prefix); send.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); try { @@ -172,8 +171,6 @@ public final class T2CodeMain extends JavaPlugin { Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); T2CodeTemplate.onLoadFooter(prefix, long_); } - - @Override public void onDisable() { // Plugin shutdown logic diff --git a/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java b/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java index 93a97b2..dbc7886 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java +++ b/src/main/java/net/t2code/lib/Spigot/system/config/ConfigCreate.java @@ -29,8 +29,6 @@ public class ConfigCreate { Config.set("BungeeCord.ThisServer", "server", yamlConfiguration); Config.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); - Config.set("PlayerMessage.MiniMessage", false,yamlConfiguration); - try { yamlConfiguration.save(config); } catch (IOException e) { diff --git a/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java b/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java index 5ccb2cd..c431a2b 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java +++ b/src/main/java/net/t2code/lib/Spigot/system/config/SelectLibConfig.java @@ -14,7 +14,6 @@ public class SelectLibConfig { private static Boolean Debug; private static String language; private static Boolean InventoriesCloseByServerStop; - private static Boolean miniMessage; public static void onSelect() { File config = new File(T2CodeMain.getPath(), "config.yml"); @@ -26,7 +25,6 @@ public class SelectLibConfig { Debug = yamlConfiguration.getBoolean("Plugin.Debug"); language = yamlConfiguration.getString("Plugin.language"); InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); - miniMessage = yamlConfiguration.getBoolean("PlayerMessage.MiniMessage"); } public static Boolean getUpdateCheckOnJoin() { @@ -53,7 +51,4 @@ public class SelectLibConfig { return InventoriesCloseByServerStop; } - public static Boolean getMiniMessage() { - return miniMessage; - } } -- 2.34.1 From 14741afb8d5a32529b38a0365c29aac6ee1a800f Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Thu, 14 Jul 2022 21:37:58 +0200 Subject: [PATCH 4/4] 12.5 --- pom.xml | 2 +- .../lib/Spigot/Lib/plugins/PluginCheck.java | 3 ++ .../Spigot/Lib/plugins/T2CPluginManager.java | 30 +++++++++++++++---- .../t2code/lib/Spigot/system/T2CodeMain.java | 5 ---- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 1830d0c..77198cd 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 12.4 + 12.5 net.t2code diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/plugins/PluginCheck.java b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/PluginCheck.java index 7438042..29c5efc 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/plugins/PluginCheck.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/PluginCheck.java @@ -40,6 +40,9 @@ public class PluginCheck { public static Boolean cgui(){ return Bukkit.getPluginManager().getPlugin("CommandGUI") != null; } + public static Boolean functiongui(){ + return Bukkit.getPluginManager().getPlugin("T2C-CommandGUI") != null; + } public static Boolean plotSquaredGUI(){ return Bukkit.getPluginManager().getPlugin("PlotSquaredGUI") != null; } diff --git a/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java index f70ef77..0c00cb4 100644 --- a/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java +++ b/src/main/java/net/t2code/lib/Spigot/Lib/plugins/T2CPluginManager.java @@ -1,22 +1,42 @@ package net.t2code.lib.Spigot.Lib.plugins; +import net.t2code.lib.Spigot.system.T2CodeMain; import org.bukkit.Bukkit; +import org.bukkit.plugin.Plugin; import java.util.Objects; public class T2CPluginManager { public static void restart(String plugin) { - - Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onEnable(); - Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onDisable(); + if (Bukkit.getPluginManager().getPlugin(plugin) == null) return; + T2CodeMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin))); + T2CodeMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin))); } public static void enable(String plugin) { - Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onEnable(); + if (Bukkit.getPluginManager().getPlugin(plugin) == null) return; + T2CodeMain.getPlugin().getPluginLoader().enablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin))); } public static void disable(String plugin) { - Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin)).onDisable(); + if (Bukkit.getPluginManager().getPlugin(plugin) == null) return; + T2CodeMain.getPlugin().getPluginLoader().disablePlugin(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(plugin))); + } + + public static void restart(Plugin plugin) { + if (plugin == null) return; + T2CodeMain.getPlugin().getPluginLoader().disablePlugin(plugin); + T2CodeMain.getPlugin().getPluginLoader().enablePlugin(plugin); + } + + public static void enable(Plugin plugin) { + if (plugin == null) return; + T2CodeMain.getPlugin().getPluginLoader().enablePlugin(plugin); + } + + public static void disable(Plugin plugin) { + if (plugin == null) return; + T2CodeMain.getPlugin().getPluginLoader().disablePlugin(plugin); } } diff --git a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java index 3dfc3fc..a44d325 100644 --- a/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java +++ b/src/main/java/net/t2code/lib/Spigot/system/T2CodeMain.java @@ -110,11 +110,6 @@ public final class T2CodeMain extends JavaPlugin { send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected." + " Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!"); send.console(prefix + " §4 §e-------------------"); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } } try { -- 2.34.1