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 7249ae2..6937306 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -13,6 +13,7 @@ import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.system.bstats.Metrics; import net.t2code.t2codelib.SPIGOT.system.cmd.CmdExecuter; +import net.t2code.t2codelib.SPIGOT.system.cmd.Development; import net.t2code.t2codelib.SPIGOT.system.cmd.ReportLogStorage; import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; @@ -96,7 +97,7 @@ public final class T2CodeLibMain extends JavaPlugin { T2Csend.console(prefix + " §3PlaceholderAPI: §6connected" + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); } - T2Csend.console(prefix + " §3Kyori MiniMessage Support: "+ (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + T2Csend.console(prefix + " §3Kyori MiniMessage Support: " + (getMmIsLoad() ? "§2load" : "§4not load") + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); plugin.getCommand("t2code").setExecutor(new CmdExecuter()); @@ -123,7 +124,7 @@ public final class T2CodeLibMain extends JavaPlugin { ReportLogStorage.load(); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); - + Bukkit.getServer().getPluginManager().registerEvents(new Development(), plugin); T2Ctemplate.onLoadFooter(prefix, long_); load = true; } @@ -140,7 +141,7 @@ public final class T2CodeLibMain extends JavaPlugin { } Vault.vaultDisable(); - T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); + T2Ctemplate.onDisable(Util.getPrefix(), this); if (mmIsLoad) { if (this.adventure != null) { this.adventure.close(); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Development.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Development.java new file mode 100644 index 0000000..33bfa9a --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Development.java @@ -0,0 +1,71 @@ +package net.t2code.t2codelib.SPIGOT.system.cmd; + +import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; +import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; +import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; +import net.t2code.t2codelib.Util; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.plugin.Plugin; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +import static net.t2code.t2codelib.SPIGOT.api.dev.T2CdevelopmentTool.removeLastChar; + +public class Development implements Listener { + @EventHandler + public void onChat(AsyncPlayerChatEvent e) { + String[] args = e.getMessage().split(" "); + if (args.length == 0) { + return; + } + if (!args[0].equals("_t2code_")) { + return; + } + if (!SelectLibConfig.getDeveloperTool()) { + T2Csend.player(e.getPlayer(), Util.getPrefix() + " The Development Tool is disabled."); + } + e.setCancelled(true); + t2cPls(e.getPlayer()); + } + + protected static void t2cPls(Player player) { + String msg = "T2Code Development
" + + T2CmcVersion.getMcVersion() + "
(" + Bukkit.getPluginManager().getPlugins().length + ") "; + ArrayList plugins = new ArrayList<>(); + Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins()); + plugins.sort(Comparator.comparing(Plugin::getName)); + for (Plugin plugin : plugins) { + String plName = plugin.getDescription().getName(); + String hover = "" + plugin.getDescription().getName() + "
" + + "Version: " + plugin.getDescription().getVersion() + "
" + + "APIVersion: " + plugin.getDescription().getAPIVersion() + "
" + + "Authors: " + plugin.getDescription().getAuthors() + "
" + + "SoftDepend: " + plugin.getDescription().getSoftDepend() + "
" + + "Depend: " + plugin.getDescription().getDepend() + "
" + + "LoadBefore: " + plugin.getDescription().getLoadBefore() + "
" + + "Website: " + plugin.getDescription().getWebsite() + ""; + String plSt = "" + plugin.getName() + ""; + + if (plugin.getDescription().getWebsite() != null && !plugin.getDescription().getWebsite().equalsIgnoreCase("null")) { + plSt = "" + plSt + ""; + } + if (plugin.isEnabled()) { + if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) { + msg = msg + "" + plSt + ", "; + } else msg = msg + "" + plSt + ", "; + } else if (plName.contains("T2C-") || Util.getT2cPlugins().contains(plName)) { + msg = msg + "" + plSt + ", "; + } else msg = msg + "" + plSt + ", "; + } + T2Csend.player(player, removeLastChar(msg, 2)); + } + + +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java index 37f677a..448ed4d 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java @@ -28,6 +28,7 @@ public class ConfigCreate { T2Cconfig.set("Plugin.UpdateCheck.SeePreReleaseUpdates", true, yamlConfiguration); T2Cconfig.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false, yamlConfiguration); T2Cconfig.set("Plugin.language", "english", yamlConfiguration); + T2Cconfig.set("Plugin.Not recommended to disable.developerTool", true, yamlConfiguration); T2Cconfig.set("BungeeCord.Enable", T2CodeLibMain.getIsBungee(), yamlConfiguration); T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java index 6b2c641..3cc7bb0 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java @@ -23,6 +23,8 @@ public class SelectLibConfig { @Getter private static String language; @Getter + private static Boolean developerTool; + @Getter private static Boolean bungee; @Getter private static Boolean inventoriesCloseByServerStop; @@ -41,6 +43,7 @@ public class SelectLibConfig { updateCheckFullDisable = yamlConfiguration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable"); debug = yamlConfiguration.getBoolean("Plugin.Debug"); language = yamlConfiguration.getString("Plugin.language"); + developerTool = yamlConfiguration.getBoolean("Plugin.Not recommended to disable.developerTool"); bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); inventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); }