From 17d3aed11fb230b496e48c6b2a92d13326f62480 Mon Sep 17 00:00:00 2001 From: JaTiTV Date: Mon, 17 Jun 2024 01:50:30 +0200 Subject: [PATCH] velocity 10% --- .idea/encodings.xml | 1 + .idea/misc.xml | 3 + pom.xml | 22 +-- .../BUNGEE/api/commands/T2CBtab.java | 1 - .../pluginMessaging/T2CplmsgBcmd.java | 3 +- .../autoResponse/T2CapiAutoResponse.java | 2 +- .../commandgui/T2CapiCGUI.java | 2 +- .../opSecurity/T2CapiOpSecurity.java | 2 +- .../t2codelib/BUNGEE/system/T2CBload.java | 12 +- .../t2codelib/BUNGEE/system/T2CodeBMain.java | 18 +-- .../t2codelib/SPIGOT/api/commands/T2Ccmd.java | 3 - .../SPIGOT/api/messages/T2Csend.java | 1 - .../SPIGOT/api/messages/T2Ctemplate.java | 45 +++--- .../api/minecraftVersion/T2CmcVersion.java | 2 - .../api/minecraftVersion/T2CnmsVersions.java | 2 - .../api/update/T2CupdateCheckerGit.java | 1 - .../SPIGOT/system/cmd/CmdExecuter.java | 2 - .../t2codelib/SPIGOT/system/cmd/Commands.java | 2 - .../SPIGOT/system/cmd/CreateReportLog.java | 1 - .../SPIGOT/system/cmd/Development.java | 1 - .../t2code/t2codelib/T2CVupdateObject.java | 28 ++++ .../net/t2code/t2codelib/T2CupdateObject.java | 2 + src/main/java/net/t2code/t2codelib/Util.java | 2 +- .../t2codelib/VELOCITY/VelocityMain.java | 101 +++++++++++++ .../VELOCITY/api/commands/T2CVcmd.java | 30 ++++ .../VELOCITY/api/commands/T2CVtab.java | 88 ++++++++++++ .../VELOCITY/api/messages/T2CBtemplate.java | 58 ++++++++ .../VELOCITY/api/messages/T2CVreplace.java | 34 +++++ .../VELOCITY/api/messages/T2CVsend.java | 67 +++++++++ .../api/pluginMessaging/T2CplmsgBcmd.java | 55 +++++++ .../autoResponse/T2CapiAutoResponse.java | 55 +++++++ .../commandgui/T2CVapiCGUI.java | 68 +++++++++ .../opSecurity/T2CapiOpSecurity.java | 50 +++++++ .../api/proxyPlayers/T2CVPlayers.java | 107 ++++++++++++++ .../VELOCITY/api/update/T2CVupdateAPI.java | 79 +++++++++++ .../api/update/T2CVupdateCheckerGit.java | 102 +++++++++++++ .../VELOCITY/api/yaml/T2CVconfig.java | 86 +++++++++++ .../t2codelib/VELOCITY/system/T2CVload.java | 65 +++++++++ .../VELOCITY/system/T2CodeVMain.java | 81 +++++++++++ .../VELOCITY/system/bstats/T2CVmetrics.java | 134 ++++++++++++++++++ .../VELOCITY/system/config/T2CVlibConfig.java | 60 ++++++++ .../system/config/VelocityConfig.java | 131 +++++++++++++++++ .../t2codelib/Velocity/VelocityMain.java | 118 --------------- src/main/resources/bungee.yml | 17 ++- src/main/resources/plugin.yml | 2 +- src/main/resources/velocity-plugin.json | 1 + 46 files changed, 1555 insertions(+), 192 deletions(-) rename src/main/java/net/t2code/t2codelib/BUNGEE/{system => api}/pluginMessaging/T2CplmsgBcmd.java (95%) rename src/main/java/net/t2code/t2codelib/BUNGEE/{system => api}/pluginMessaging/autoResponse/T2CapiAutoResponse.java (96%) rename src/main/java/net/t2code/t2codelib/BUNGEE/{system => api}/pluginMessaging/commandgui/T2CapiCGUI.java (96%) rename src/main/java/net/t2code/t2codelib/BUNGEE/{system => api}/pluginMessaging/opSecurity/T2CapiOpSecurity.java (95%) create mode 100644 src/main/java/net/t2code/t2codelib/T2CVupdateObject.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/VelocityMain.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVcmd.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVtab.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CBtemplate.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVreplace.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVsend.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CplmsgBcmd.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/commandgui/T2CVapiCGUI.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CVPlayers.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateAPI.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateCheckerGit.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/api/yaml/T2CVconfig.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CVload.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CodeVMain.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/system/bstats/T2CVmetrics.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java create mode 100644 src/main/java/net/t2code/t2codelib/VELOCITY/system/config/VelocityConfig.java delete mode 100644 src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java create mode 100644 src/main/resources/velocity-plugin.json diff --git a/.idea/encodings.xml b/.idea/encodings.xml index aa00ffa..486580c 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,6 +1,7 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index 63ea76a..eb70eb9 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,6 +5,9 @@ + + + diff --git a/pom.xml b/pom.xml index 2746252..86a6734 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 16.7_dev-01 + 16.7_dev-19 @@ -15,7 +15,7 @@ T2CodeLib - 1.8 + 11 UTF-8 @@ -118,14 +118,6 @@ - - - com.velocitypowered - velocity-api - 3.2.0-SNAPSHOT - provided - - org.spigotmc @@ -158,6 +150,14 @@ provided + + + com.velocitypowered + velocity-api + 3.2.0-SNAPSHOT + provided + + net.t2code @@ -214,7 +214,7 @@ org.projectlombok lombok - 1.18.24 + 1.18.30 provided diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/commands/T2CBtab.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/commands/T2CBtab.java index 593620e..7631c78 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/commands/T2CBtab.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/commands/T2CBtab.java @@ -6,7 +6,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; public class T2CBtab { diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CplmsgBcmd.java similarity index 95% rename from src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java rename to src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CplmsgBcmd.java index 2b7970e..436f60c 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/T2CplmsgBcmd.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.BUNGEE.system.pluginMessaging; +package net.t2code.t2codelib.BUNGEE.api.pluginMessaging; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -6,7 +6,6 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.event.EventHandler; import net.t2code.t2codelib.Util; -import org.junit.Ignore; import java.io.ByteArrayInputStream; import java.io.DataInputStream; diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java similarity index 96% rename from src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java rename to src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java index 50e46ec..277e957 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse; +package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/commandgui/T2CapiCGUI.java similarity index 96% rename from src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java rename to src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/commandgui/T2CapiCGUI.java index 5ac9829..11fb70d 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/commandgui/T2CapiCGUI.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui; +package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java similarity index 95% rename from src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java rename to src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java index c30b657..034c37c 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java @@ -1,4 +1,4 @@ -package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity; +package net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.event.PluginMessageEvent; diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java index 4aef1a1..14d5012 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java @@ -6,18 +6,18 @@ import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI; import net.t2code.t2codelib.BUNGEE.system.bstats.T2CBmetrics; import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig; import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers; -import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.T2CplmsgBcmd; -import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse.T2CapiAutoResponse; -import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUI; -import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSecurity; +import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.T2CplmsgBcmd; +import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse.T2CapiAutoResponse; +import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui.T2CapiCGUI; +import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity.T2CapiOpSecurity; import java.io.IOException; public class T2CBload { - public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) { + public static void onLoad(Plugin plugin, String prefix, String author, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) { long long_ = System.currentTimeMillis(); T2CBsend.console(prefix + "§4============================= " + prefix + " §4============================="); - T2CBsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", "")); + T2CBsend.console(prefix + " §2Author: §6" + String.valueOf(author).replace("[", "").replace("]", "")); T2CBsend.console(prefix + " §2Version: §6" + version); T2CBsend.console(prefix + " §2Spigot: §6" + spigot); T2CBsend.console(prefix + " §2Discord: §6" + discord); diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CodeBMain.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CodeBMain.java index 18386da..72fe0d7 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CodeBMain.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CodeBMain.java @@ -1,5 +1,6 @@ package net.t2code.t2codelib.BUNGEE.system; +import lombok.Getter; import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.md_5.bungee.api.plugin.Plugin; import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; @@ -8,16 +9,12 @@ import net.t2code.t2codelib.Util; public class T2CodeBMain extends Plugin { + @Getter private static Plugin plugin; - public static Plugin getPlugin() { - return plugin; - } - private static String version; - private static String orgVersion; - private static String autor; + @Getter private static Boolean mmIsLoad = true; private static BungeeAudiences adventure; @@ -33,8 +30,8 @@ public class T2CodeBMain extends Plugin { public void onEnable() { // Plugin startup logic plugin = this; - orgVersion = plugin.getDescription().getVersion(); - autor = plugin.getDescription().getAuthor(); + String orgVersion = plugin.getDescription().getVersion(); + String author = plugin.getDescription().getAuthor(); try { adventure = BungeeAudiences.create(this); T2CBsend.info(this,"Adventure load!"); @@ -42,7 +39,7 @@ public class T2CodeBMain extends Plugin { T2CBsend.error(this,"Adventure can not be load!"); mmIsLoad = false; } - T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit()); + T2CBload.onLoad(plugin, Util.getPrefix(), author, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit()); version = plugin.getDescription().getVersion(); } @@ -64,7 +61,4 @@ public class T2CodeBMain extends Plugin { T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled."); T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); } - public static Boolean getMmIsLoad() { - return mmIsLoad; - } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java index 2680673..6a75f07 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java @@ -1,14 +1,11 @@ package net.t2code.t2codelib.SPIGOT.api.commands; -import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; -import java.rmi.MarshalledObject; import java.util.Map; public class T2Ccmd { 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 8fb8196..cf9fd01 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 @@ -1,7 +1,6 @@ package net.t2code.t2codelib.SPIGOT.api.messages; import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java index e561437..a2fc7a8 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java @@ -3,23 +3,23 @@ package net.t2code.t2codelib.SPIGOT.api.messages; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; import net.t2code.t2codelib.T2CupdateWebData; -import net.t2code.t2codelib.UpdateType; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; import java.util.List; public class T2Ctemplate { - public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord) { - return onLoadHeader(prefix, autor, version, spigot, discord, null, null); + public static Long onLoadHeader(String prefix, List author, String version, String spigot, String discord) { + return onLoadHeader(prefix, author, version, spigot, discord, null, null); } - public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord, Boolean isPremium) { - return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null); + public static Long onLoadHeader(String prefix, List author, String version, String spigot, String discord, Boolean isPremium) { + return onLoadHeader(prefix, author, version, spigot, discord, isPremium, null); } - public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) { + public static Long onLoadHeader(String prefix, List author, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) { Long long_ = System.currentTimeMillis(); T2Csend.console(prefix + " _______ ___ _____ "); T2Csend.console(prefix + " |__ __|__ \\ / ____|"); @@ -28,7 +28,7 @@ public class T2Ctemplate { T2Csend.console(prefix + " | | / /_| |____ "); T2Csend.console(prefix + " |_| |____|\\_____|"); T2Csend.console(prefix + " §4 §e╔══════════════════════════"); - T2Csend.console(prefix + " §4 §e║ §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", "")); + T2Csend.console(prefix + " §4 §e║ §2Author: §6" + String.valueOf(author).replace("[", "").replace("]", "")); T2Csend.console(prefix + " §4 §e║ §2Version: §6" + version); T2Csend.console(prefix + " §4 §e║ §2Spigot: §6" + spigot); T2Csend.console(prefix + " §4 §e║ §2Discord: §6" + discord); @@ -81,7 +81,7 @@ public class T2Ctemplate { /** * @param prefix - * @param autor + * @param author * @param spigot * @param discord * @deprecated reason this method is deprecated
@@ -94,7 +94,7 @@ public class T2Ctemplate { * */ @Deprecated - public static void onDisable(String prefix, List autor, String version, String spigot, String discord) { + public static void onDisable(String prefix, List author, String version, String spigot, String discord) { T2Csend.console(prefix + " §2Version: §6" + version); T2Csend.console(prefix + " §4Plugin successfully disabled."); } @@ -102,7 +102,7 @@ public class T2Ctemplate { public static void onDisable(String prefix, Plugin plugin) { T2Csend.console(prefix + " §4 §e╔══════════════════════════"); T2Csend.console(prefix + " §4 §e║ §2Version: §6" + plugin.getDescription().getVersion()); - T2Csend.console(prefix + " §4 §e║ §2Autors: §6" + plugin.getDescription().getAuthors()); + T2Csend.console(prefix + " §4 §e║ §2Authors: §6" + plugin.getDescription().getAuthors()); T2Csend.console(prefix + " §4 §e║ §4Plugin successfully disabled."); T2Csend.console(prefix + " §4 §e╚══════════════════════════"); } @@ -130,27 +130,21 @@ public class T2Ctemplate { boolean player = sender instanceof Player; String stPlugin = " Plugin: [pl]".replace("[pl]", plugin.getName()); String stVersion = " Version: [ver]".replace("[ver]", pluginVersion); - String stAutor = " Autor(s): [autor]".replace("[autor]", plugin.getDescription().getAuthors().toString()); + String stAuthor = " Author(s): [author]".replace("[author]", plugin.getDescription().getAuthors().toString()); String stUpdate = " New version available: [up]".replace("[up]", webData != null ? update ? "YES" : "no" : "It could not be checked for updates!"); stNVersion = update ? "
Newest Version: [nver]".replace("[nver]",player ? "Click for the update information'>"+publicVersion+"":publicVersion) : ""; - String stLinkPlayer = " Go to the Spigot page'>Spigot " - .replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID) - + "- Go to the T2Code Support Discord'>Discord" - .replace("[dlink]", discord); - String stLinkConsole = " Spigot: https://www.spigotmc.org/resources/" + spigotID + "" - + "
Discord: " + discord + ""; - String stLink = player ? stLinkPlayer : stLinkConsole; + String stLink = getString(spigotID, discord, player); String pr = premiumVerified != null ? "
Premium verified: [pr]".replace("[pr]", premiumVerified ? "YES" : "NO") : ""; - String stMSG = text == null || text.equals("") ? "" : "
" + text; + String stMSG = text == null || text.isEmpty() ? "" : "
" + text; T2Csend.sender(sender, "
╔════════════════════════════════" + "
" + stPlugin + "
" + stVersion + stMSG - + "
" + stAutor + + "
" + stAuthor + "
" + stUpdate + stNVersion + "
" + stLink @@ -158,6 +152,17 @@ public class T2Ctemplate { + "
╚════════════════════════════════"); } + private static @NotNull String getString(int spigotID, String discord, boolean player) { + String stLinkPlayer = " Go to the Spigot page'>Spigot " + .replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID) + + "- Go to the T2Code Support Discord'>Discord" + .replace("[dlink]", discord); + String stLinkConsole = " Spigot: https://www.spigotmc.org/resources/" + spigotID + "" + + "
Discord: " + discord + ""; + String stLink = player ? stLinkPlayer : stLinkConsole; + return stLink; + } + public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) { sendInfo(sender, plugin, spigotID, discord, null, text); } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java index 7d49a5f..fcc473f 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CmcVersion.java @@ -1,7 +1,5 @@ package net.t2code.t2codelib.SPIGOT.api.minecraftVersion; -import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; -import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import org.bukkit.Bukkit; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsVersions.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsVersions.java index 0bb0133..3cfd397 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsVersions.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/minecraftVersion/T2CnmsVersions.java @@ -1,8 +1,6 @@ package net.t2code.t2codelib.SPIGOT.api.minecraftVersion; import lombok.Getter; -import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; -import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; public class T2CnmsVersions { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateCheckerGit.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateCheckerGit.java index 9c908e1..320a20e 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateCheckerGit.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateCheckerGit.java @@ -15,7 +15,6 @@ import java.io.*; import java.net.URL; import java.net.URLConnection; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; import java.util.function.Consumer; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java index 3a5a02f..0840db4 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CmdExecuter.java @@ -2,9 +2,7 @@ package net.t2code.t2codelib.SPIGOT.system.cmd; import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; -import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; -import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers; import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.T2CupdateObject; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java index 5421480..0001212 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Commands.java @@ -10,9 +10,7 @@ import net.t2code.t2codelib.Util; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import java.io.File; import java.io.IOException; public class Commands { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java index 44c4d05..d681a38 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/CreateReportLog.java @@ -17,7 +17,6 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.util.EntityUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.Server; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; 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 index 33bfa9a..28b5fb9 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Development.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/cmd/Development.java @@ -5,7 +5,6 @@ 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; diff --git a/src/main/java/net/t2code/t2codelib/T2CVupdateObject.java b/src/main/java/net/t2code/t2codelib/T2CVupdateObject.java new file mode 100644 index 0000000..ddc5157 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/T2CVupdateObject.java @@ -0,0 +1,28 @@ +package net.t2code.t2codelib; + + +import java.util.Optional; + +public class T2CVupdateObject { + + public Optional pluginName; + public Optional pluginVersion; + public T2CupdateWebData webData; + public Boolean load; + public Boolean updateAvailable; + public Boolean updateCheckOnJoin; + + public T2CVupdateObject(Optional pluginName, + Optional pluginVersion, + T2CupdateWebData webData, + Boolean load, + Boolean updateAvailable, + Boolean updateCheckOnJoin) { + this.pluginName = pluginName; + this.pluginVersion = pluginVersion; + this.webData = webData; + this.load = load; + this.updateAvailable = updateAvailable; + this.updateCheckOnJoin = updateCheckOnJoin; + } +} diff --git a/src/main/java/net/t2code/t2codelib/T2CupdateObject.java b/src/main/java/net/t2code/t2codelib/T2CupdateObject.java index d70e3b4..03e9583 100644 --- a/src/main/java/net/t2code/t2codelib/T2CupdateObject.java +++ b/src/main/java/net/t2code/t2codelib/T2CupdateObject.java @@ -1,6 +1,8 @@ package net.t2code.t2codelib; +import java.util.Optional; + public class T2CupdateObject { public String pluginName; diff --git a/src/main/java/net/t2code/t2codelib/Util.java b/src/main/java/net/t2code/t2codelib/Util.java index a802956..6ff20b9 100644 --- a/src/main/java/net/t2code/t2codelib/Util.java +++ b/src/main/java/net/t2code/t2codelib/Util.java @@ -5,10 +5,10 @@ import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.UUID; public class Util { - @Getter private static final UUID serverUUID = UUID.randomUUID(); diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/VelocityMain.java b/src/main/java/net/t2code/t2codelib/VELOCITY/VelocityMain.java new file mode 100644 index 0000000..7e62a4c --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/VelocityMain.java @@ -0,0 +1,101 @@ +package net.t2code.t2codelib.VELOCITY; + + +//@Plugin(id = "t2codelib", name = "T2CodeLib", version = "16.7_dev-01", authors = {"JaTiTV"}) +public class VelocityMain { +// +// String prefix = "[T2CodeLib]"; +// +// protected final ProxyServer server; +// protected final Logger logger; +// public static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from("t2c:bcmd"); +// // public static final MinecraftChannelIdentifier IDENTIFIER2 = MinecraftChannelIdentifier.from("booster:activate"); +// +// @Inject +// public VelocityMain(ProxyServer server, Logger logger) { +// long long_ = System.currentTimeMillis(); +// this.server = server; +// this.logger = logger; +// +// logger.info("============================= {} =============================", prefix); +// logger.info("Autor: JaTiTV"); +// logger.info("Version: 16.7_dev-01"); +// logger.info("Plugin loaded successfully. - {}ms", System.currentTimeMillis() - long_); +// logger.info("============================= {} =============================", prefix); +// +// } +// +// +// @Subscribe +// public void onProxyInitialization(ProxyInitializeEvent event) { +// server.getChannelRegistrar().register(IDENTIFIER); +// // server.getChannelRegistrar().register(IDENTIFIER2); +// } +// +// @Subscribe +// public void onPluginMessageFromPlayer(PluginMessageEvent event) { +// if (event.getIdentifier() != IDENTIFIER) { +// return; +// } +// ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData()); +// String channel = stream.readUTF(); +// String input = stream.readUTF(); +// String serverID; +// try { +// serverID = stream.readUTF(); +// } catch (Exception i) { +// serverID = "not Found"; +// } +// +// if (channel.equals("T2Code-Console")) { +// logger.info("{} [{}] T2C BCMD Command Console: {}", prefix, serverID, input); +// dispatchCommand(input); +// } else { +// Player player = server.getPlayer(channel).orElse(null); +// if (player != null) { +// logger.info("{} [{}] T2C BCMD Command {}: {}", prefix, serverID, player, input); +// executeCommand(player, input); +// } +// } +// event.setResult(PluginMessageEvent.ForwardResult.handled()); +// } +// +//// public void sendToSpigot(String sender, String boostertype, String step, String starter, String starttime, String starteruuid) { +//// ByteArrayOutputStream stream = new ByteArrayOutputStream(); +//// DataOutputStream output = new DataOutputStream(stream); +//// try { +//// output.writeUTF(boostertype); +//// output.writeUTF(step); +//// output.writeUTF(starter); +//// output.writeUTF(starttime); +//// output.writeUTF(starteruuid); +//// } catch (IOException e) { +//// java.util.logging.Logger.getLogger(e.getMessage()); +//// } +//// Optional player = server.getPlayer(sender); +//// if (!player.isPresent()) { +//// return; +//// } +//// server.getAllServers().forEach((server) -> { +//// if (server != player.get().getCurrentServer().get().getServer()) { +//// server.sendPluginMessage(IDENTIFIER2, stream.toByteArray()); +//// } +//// }); +//// } +// +// public void dispatchCommand(String input) { +// // Get the console command source +// ConsoleCommandSource console = server.getConsoleCommandSource(); +// +// // Dispatch the command +// server.getCommandManager().executeAsync(console, input).join(); +// } +// +// public void executeCommand(Player player, String input) { +// CommandManager commandManager = server.getCommandManager(); +// +// // Dispatch the command +// commandManager.executeImmediatelyAsync(player, input); +// } + +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVcmd.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVcmd.java new file mode 100644 index 0000000..c8fe63a --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVcmd.java @@ -0,0 +1,30 @@ +package net.t2code.t2codelib.VELOCITY.api.commands; + +import com.velocitypowered.api.command.CommandManager; +import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.proxy.ConsoleCommandSource; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.slf4j.Logger; + +public class T2CVcmd { + + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + public static void Console(String cmd) { + // Get the console command source + ConsoleCommandSource console = server.getConsoleCommandSource(); + + // Dispatch the command + server.getCommandManager().executeAsync(console, cmd).join(); + } + + public static void Player(CommandSource player, String cmd) { + CommandManager commandManager = server.getCommandManager(); + + // Dispatch the command + commandManager.executeImmediatelyAsync(player, cmd); + } + +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVtab.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVtab.java new file mode 100644 index 0000000..9efea18 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/commands/T2CVtab.java @@ -0,0 +1,88 @@ +package net.t2code.t2codelib.VELOCITY.api.commands; +// +//import net.md_5.bungee.api.CommandSender; +//import net.md_5.bungee.api.ProxyServer; +//import net.md_5.bungee.api.connection.ProxiedPlayer; +// +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +// +public class T2CVtab { +// +// +// public static void tab(List matches, CommandSender sender, int arg, String[] args, String perm, Boolean onlinePlayer) { +// if (args.length != arg + 1) return; +// for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) { +// if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) { +// matches.add(player1.getName()); +// } +// } +// } +// +// public static void tab(List matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, String perm, Boolean onlinePlayer) { +// if (args.length != arg + 1) return; +// if (!args[argEquals].toLowerCase().equals(equalsValue)) return; +// for (ProxiedPlayer player1 : ProxyServer.getInstance().getPlayers()) { +// if (passend(player1.getName(), args[arg]) && hasPermission(sender, perm)) { +// matches.add(player1.getName()); +// } +// } +// } +// +// public static void tab(List matches, CommandSender sender, int arg, String[] args, HashMap permMap, Boolean onlinePlayer, String permForPlayer) { +// if (args.length != arg + 1) return; +// for (String command : permMap.keySet()) { +// if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) { +// matches.add(command); +// } else if (onlinePlayer != null && permForPlayer != null) { +// tab(matches, sender, arg, args, permForPlayer, onlinePlayer); +// } +// } +// } +// +// public static void tab(List matches, CommandSender sender, int arg, String[] args, HashMap permMap) { +// tab(matches, sender, arg, args, permMap, null, null); +// } +// +// public static void tab(List matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, HashMap permMap) { +// if (args.length != arg + 1) return; +// if (!args[argEquals].toLowerCase().equals(equalsValue)) return; +// for (String command : permMap.keySet()) { +// if (hasPermission(sender, permMap.get(command)) && passend(command, args[arg])) { +// matches.add(command); +// } +// } +// } +// +// public static List tab(CommandSender sender, int arg, String[] args, String perm, String command) { +// List matches = new ArrayList<>(); +// if (hasPermission(sender, perm) && passend(command, args[arg])) { +// matches.add(command); +// } +// return matches; +// } +// +// 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; +// } else { +// if (arg.toUpperCase().charAt(i) != command.toUpperCase().charAt(i)) { +// return false; +// } +// } +// } +// return true; +// } +// +// public static boolean hasPermission(CommandSender sender, String permission) { +// String[] Permissions = permission.split(";"); +// for (String perm : Permissions) { +// if (sender.hasPermission(perm)) { +// return true; +// } +// } +// return false; +// } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CBtemplate.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CBtemplate.java new file mode 100644 index 0000000..ee8a736 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CBtemplate.java @@ -0,0 +1,58 @@ +package net.t2code.t2codelib.VELOCITY.api.messages; + +import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.plugin.PluginContainer; +import net.t2code.t2codelib.T2CupdateWebData; +import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI; + +import java.util.Optional; + +public class T2CBtemplate { + + + public static Long onLoadHeader(String prefix, String autor, String version, String spigot, String discord) { + Long long_ = Long.valueOf(System.currentTimeMillis()); + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", "")); + T2CVsend.console(prefix + " §2Version: §6" + version); + T2CVsend.console(prefix + " §2Spigot: §6" + spigot); + T2CVsend.console(prefix + " §2Discord: §6" + discord); + T2CVsend.console(prefix + " §8-------------------------------"); + return long_; + } + + public static void onLoadSeparateStroke(String prefix) { + T2CVsend.console(prefix + " §8-------------------------------"); + } + + public static void onLoadFooter(String prefix, Long long_) { + T2CVsend.console(prefix + " §8-------------------------------"); + T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms"); + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + } + + public static void onDisable(String prefix, String autor, String version, String spigot, String discord) { + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + T2CVsend.console(prefix + " §2Autor: §6" + autor.replace("[", "").replace("]", "")); + T2CVsend.console(prefix + " §2Version: §6" + version); + T2CVsend.console(prefix + " §2Spigot: §6" + spigot); + T2CVsend.console(prefix + " §2Discord: §6" + discord); + T2CVsend.console(prefix + " §4Plugin successfully disabled."); + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + } + + public static void sendInfo(CommandSource sender, PluginContainer plugin, String prefix, String spigot, String discord, String autor) { + T2CupdateWebData webData = T2CVupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData; + String pluginVersion = String.valueOf(plugin.getDescription().getVersion()); + T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4======="); + T2CVsend.sender(sender, prefix + " §2Autor: §6" + autor); + if (webData.getVersion().equalsIgnoreCase(pluginVersion)) { + T2CVsend.sender(sender, prefix + " §2Version: §6" + pluginVersion); + } else { + T2CVupdateAPI.sendUpdateMsg(prefix, discord, webData, Optional.of(plugin), sender); + } + T2CVsend.sender(sender, prefix + " §2Spigot: §6" + spigot); + T2CVsend.sender(sender, prefix + " §2Discord: §6" + discord); + T2CVsend.sender(sender, prefix + "§4======= " + prefix + " §4======="); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVreplace.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVreplace.java new file mode 100644 index 0000000..a08c156 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVreplace.java @@ -0,0 +1,34 @@ +package net.t2code.t2codelib.VELOCITY.api.messages; + +import java.util.ArrayList; +import java.util.List; + +public class T2CVreplace { + + public static String replace(String prefix, String Text) { + return Text.replace("[prefix]", prefix).replace("&", "§").replace("[ue]", "ü") + .replace("[UE]", "Ü").replace("[oe]", "ö").replace("[OE]", "Ö") + .replace("[ae]", "ä").replace("[AE]", "Ä"); + } + + public static List replace(String prefix, List Text) { + List output = new ArrayList<>(); + for (String input : Text) { + output.add(input.replace("[prefix]", prefix).replace("&", "§") + .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") + .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä")); + } + return output; + } + + 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("&", "§") + .replace("[ue]", "ü").replace("[UE]", "Ü").replace("[oe]", "ö") + .replace("[OE]", "Ö").replace("[ae]", "ä").replace("[AE]", "Ä") + .replace("[price]", String.valueOf(price))); + } + return rp; + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVsend.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVsend.java new file mode 100644 index 0000000..2cbd7de --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/messages/T2CVsend.java @@ -0,0 +1,67 @@ +package net.t2code.t2codelib.VELOCITY.api.messages; + +import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.title.Title; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.slf4j.Logger; + +import java.util.Optional; + + +public class T2CVsend { + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + public static void console(String msg) { + logger.info(msg); + } + + public static void player(Player player, String msg) { + player.sendMessage(Component.text(msg)); + } + + public static void title(Player player, Title msg) { + player.showTitle(msg); + } + + public static void sender(CommandSource sender, String msg) { + sender.sendMessage(Component.text( msg)); + } + + public static void debug(Optional plugin, String msg) { + debug(plugin, msg, null); + } + + public static void debug(Optional plugin, String msg, Integer stage) { + // if (!new File(Main.getPath(), "config.yml").exists()) return; + // if (stage == null) { + // if (plugin.getConfig().getBoolean("Plugin.Debug")) { + // ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg); + // } + // return; + //} + //if (plugin.getConfig().getInt("Plugin.Debug") >= stage) { + // ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg); + //} + } + + public static void debugmsg(PluginContainer plugin, String msg) { + logger.info("{} §5DEBUG-MSG: §6{}", plugin.getDescription().getName(), msg); + } + + public static void info(PluginContainer plugin, String msg) { + logger.info("{} {}", plugin.getDescription().getName(), msg); + } + + public static void warning(PluginContainer plugin, String msg) { + logger.warn("{} {}", plugin.getDescription().getName(), msg); + } + + public static void error(PluginContainer plugin, String msg) { + logger.error("{} {}", plugin.getDescription().getName(), msg); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CplmsgBcmd.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CplmsgBcmd.java new file mode 100644 index 0000000..058393a --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/T2CplmsgBcmd.java @@ -0,0 +1,55 @@ +package net.t2code.t2codelib.VELOCITY.api.pluginMessaging; + + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.PluginMessageEvent; +import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.slf4j.Logger; + +public class T2CplmsgBcmd { + + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + + @Subscribe + public void onProxyInitialization(ProxyInitializeEvent event) { + server.getChannelRegistrar().register(T2CodeVMain.bcmd); + // server.getChannelRegistrar().register(IDENTIFIER2); + } + + @Subscribe + public void onPluginMessageFromPlayer(PluginMessageEvent event) { + if (event.getIdentifier() != T2CodeVMain.bcmd) { + return; + } + ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData()); + String channel = stream.readUTF(); + String input = stream.readUTF(); + String serverID; + try { + serverID = stream.readUTF(); + } catch (Exception i) { + serverID = "not Found"; + } + + if (channel.equals("T2Code-Console")) { + logger.info("{} [{}] T2C BCMD Command Console: {}", T2CodeVMain.prefix, serverID, input); + T2CVcmd.Console(input); + } else { + Player player = server.getPlayer(channel).orElse(null); + if (player != null) { + logger.info("{} [{}] T2C BCMD Command {}: {}", T2CodeVMain.prefix, serverID, player, input); + T2CVcmd.Player(player, input); + } + } + event.setResult(PluginMessageEvent.ForwardResult.handled()); + } + +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java new file mode 100644 index 0000000..0db4a91 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/autoResponse/T2CapiAutoResponse.java @@ -0,0 +1,55 @@ +package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse; + + +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.PluginMessageEvent; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd; +import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.slf4j.Logger; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +public class T2CapiAutoResponse { + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + @Subscribe + public void onPluginmessage(PluginMessageEvent event) { + if (event.getIdentifier() != T2CodeVMain.aresp) { + return; + } + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); + + try { + String channel = stream.readUTF(); + String input = stream.readUTF(); + + switch (channel) { + case "ConC": + logger.info("Command Console: {}", input); + T2CVcmd.Console(input); + break; + case "ALLPMSG": + for (Player player : server.getAllPlayers()) { + T2CVsend.player(player, input); + } + break; + default: + Player player = server.getPlayer(channel).orElse(null); + if (player != null) { + logger.info("Command Console: {}", input); + T2CVcmd.Player(player, input); + } + break; + } + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/commandgui/T2CVapiCGUI.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/commandgui/T2CVapiCGUI.java new file mode 100644 index 0000000..f17bdba --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/commandgui/T2CVapiCGUI.java @@ -0,0 +1,68 @@ +package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui; + + +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.DisconnectEvent; +import com.velocitypowered.api.event.connection.PostLoginEvent; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.slf4j.Logger; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class T2CVapiCGUI { + + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + + @Subscribe + public void onJoin(PostLoginEvent event) { + Player player = event.getPlayer(); + sendToSpigotPlayer(player.getUsername(), true); + } + + @Subscribe + public void onDisconnect(DisconnectEvent event) { + Player player = event.getPlayer(); + sendToSpigotPlayer(player.getUsername(), false); + } + + public void sendToSpigotPlayer(String name, Boolean join) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + if (join) { + output.writeUTF("join"); + } else { + output.writeUTF("left"); + } + output.writeUTF(name); + } catch (IOException e) { + logger.warn(e.getMessage()); + } + byte[] data = stream.toByteArray(); + for (RegisteredServer server : server.getAllServers()) { + server.sendPluginMessage(T2CodeVMain.cguiopl, data); + } + } + + public static void sendToSpigotDeleteAll() { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + output.writeUTF("clear"); + output.writeUTF(""); + } catch (IOException e) { + logger.warn(e.getMessage()); + } + byte[] data = stream.toByteArray(); + for (RegisteredServer server : server.getAllServers()) { + server.sendPluginMessage(T2CodeVMain.cguiopl, data); + } + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java new file mode 100644 index 0000000..4b99841 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/pluginMessaging/opSecurity/T2CapiOpSecurity.java @@ -0,0 +1,50 @@ +package net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity; + + +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.PluginMessageEvent; +import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; + +import java.io.*; +import java.util.logging.Logger; + +public class T2CapiOpSecurity { + public static ProxyServer server = T2CodeVMain.server; + + @Subscribe + public void onPluginmessage(PluginMessageEvent event) { + if (event.getIdentifier() != T2CodeVMain.opsec) { + return; + } + + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); + try { + String channel = stream.readUTF(); + String mode = stream.readUTF(); + String information = stream.readUTF(); + if (channel.equals("T2Cconsole")) { + sendToSpigotPlayer(channel,mode,information); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } + + private static void sendToSpigotPlayer(String channel,String mode,String information) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + output.writeUTF(channel); + output.writeUTF(mode); + output.writeUTF(information); + } catch (IOException e) { + Logger.getLogger(e.getMessage()); + } + for (RegisteredServer server : server.getAllServers()) { + server.sendPluginMessage(T2CodeVMain.opsec, stream.toByteArray()); + } + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CVPlayers.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CVPlayers.java new file mode 100644 index 0000000..b34fa84 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/proxyPlayers/T2CVPlayers.java @@ -0,0 +1,107 @@ +package net.t2code.t2codelib.VELOCITY.api.proxyPlayers; + + +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.connection.DisconnectEvent; +import com.velocitypowered.api.event.connection.PluginMessageEvent; +import com.velocitypowered.api.event.connection.PostLoginEvent; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum; +import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; + +import java.io.*; +import java.util.logging.Logger; + +public class T2CVPlayers { + + public static ProxyServer server = T2CodeVMain.server; + public static org.slf4j.Logger logger = T2CodeVMain.logger; + + @Subscribe + public void onJoin(PostLoginEvent e) { + sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.JOIN, ""); + } + + @Subscribe + public void onDisconnect(DisconnectEvent e) { + sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.QUIT, ""); + } + + public void sendToSpigotPlayer(String name, T2CbungeePlayersEnum value, String uuid) { + switch (value) { + case JOIN: + case QUIT: + sendToSpigotPlayerExecute(name, value, uuid); + break; + case GIVEALL: + StringBuilder input = new StringBuilder(); + for (Player player : server.getAllPlayers()) { + input.append(player.getUsername()).append(";"); + } + sendToSpigotPlayerExecute(input.toString(), T2CbungeePlayersEnum.GIVEALL, uuid); + break; + } + } + + private void sendToSpigotPlayerExecute(String name, T2CbungeePlayersEnum value, String uuid) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + output.writeUTF(value.name()); + output.writeUTF(name); + output.writeUTF(uuid); + } catch (IOException e) { + Logger.getLogger(e.getMessage()); + } + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: t2c:bonlp"); + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + value.name()); + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input: " + name); + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input2/uuid: " + uuid); + byte[] data = stream.toByteArray(); + for (RegisteredServer server : server.getAllServers()) { + server.sendPluginMessage(T2CodeVMain.bonlp, data); + } + + } + + public static void sendToSpigotDeleteAll() { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + output.writeUTF(T2CbungeePlayersEnum.CLEAR.name()); + output.writeUTF(""); + output.writeUTF(""); + } catch (IOException e) { + Logger.getLogger(e.getMessage()); + } + byte[] data = stream.toByteArray(); + for (RegisteredServer server : server.getAllServers()) { + server.sendPluginMessage(T2CodeVMain.bonlp, data); + } + } + + @Subscribe + public void onPluginMessage(PluginMessageEvent event) { + if (event.getIdentifier() != T2CodeVMain.bonlp) { + return; + } + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); + + try { + T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF()); + String input = stream.readUTF(); + + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received channel: " + T2CodeVMain.bonlp); + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received subChannel: " + subChannel.name()); + T2CVsend.debug(T2CodeVMain.pluginContainer, "PluginMessage received input/uuid: " + input); + + sendToSpigotPlayer("", subChannel, input); + } catch (IOException e) { + e.printStackTrace(); + } + + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateAPI.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateAPI.java new file mode 100644 index 0000000..3b1bb0a --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateAPI.java @@ -0,0 +1,79 @@ +package net.t2code.t2codelib.VELOCITY.api.update; + +import com.velocitypowered.api.command.CommandSource; + +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.T2CVupdateObject; +import net.t2code.t2codelib.T2CupdateWebData; +import net.t2code.t2codelib.UpdateType; +import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; + +import java.util.HashMap; +import java.util.Optional; + +public class T2CVupdateAPI { + public static HashMap, T2CVupdateObject> bungeePluginVersins = new HashMap<>(); + public static ProxyServer server = T2CodeVMain.server; + + + public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Optional plugin, CommandSource sender) { + String publicVersion = webData.getVersion(); + String pluginVersion = String.valueOf(plugin.get().getDescription().getVersion()); + String value; + if (webData.isPreRelease()) { + value = UpdateType.PRERELEASE.text; + if (publicVersion.toLowerCase().contains("dev")) { + value = UpdateType.DEVELOPMENT.text; + } + if (publicVersion.toLowerCase().contains("beta")) { + value = UpdateType.BETA.text; + } + if (publicVersion.toLowerCase().contains("snapshot")) { + value = UpdateType.SNAPSHOT.text; + } + } else value = UpdateType.STABLE.text; + String h = "
╔══════════════" + prefix + "══════════════"; + String s1 = "
A new [value] version was found!".replace("[value]", value); + String s2 = "
Your version: " + pluginVersion + " - Current version: " + webData.getVersion() + ""; + String s3 = "
You can download it here: " + webData.getUpdateUrl() + ""; + String s4 = "
You can find more information on Discord: " + discord + ""; + String f = "
╚══════════════" + prefix + "══════════════"; + String text = h + s1 + s2 + s3 + s4 + f; + if (sender == null) { + T2CVsend.console(text); + } else T2CVsend.sender(sender, text); + + } + + private static Boolean noUpdate = true; + private static String pluginVersion; + + + public static void checkForUpdates(Optional plugin, String prefix, String discord, Integer spigotID, String url) { + + // if (T2CVlibConfig.getUpdateCheckFullDisable()) return; + (new T2CVupdateCheckerGit(plugin, spigotID)).getVersion((webData) -> { + pluginVersion = T2CodeVMain.version; + T2CVupdateObject update = new T2CVupdateObject( + plugin.get().getDescription().getName(), + plugin.get().getDescription().getVersion(), + webData, + false, + !plugin.get().getDescription().getVersion().equals(webData.getVersion()), + true + ); + bungeePluginVersins.put(plugin.get().getDescription().getName(), update); + if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(webData.getVersion())) { + sendUpdateMsg(prefix, discord, webData, plugin, null); + noUpdate = true; + } else { + if (noUpdate) { + T2CVsend.console(prefix + " §2No update found."); + noUpdate = false; + } + } + }, pluginVersion, spigotID, url); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateCheckerGit.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateCheckerGit.java new file mode 100644 index 0000000..1275fa2 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/update/T2CVupdateCheckerGit.java @@ -0,0 +1,102 @@ +package net.t2code.t2codelib.VELOCITY.api.update; + +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.T2CVupdateObject; +import net.t2code.t2codelib.T2CupdateWebData; +import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Optional; +import java.util.function.Consumer; + +public class T2CVupdateCheckerGit { + private Optional plugin; + private int resourceId; + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + public T2CVupdateCheckerGit(Optional plugin, int resourceId) { + this.plugin = plugin; + this.resourceId = resourceId; + } + + public void getVersion(Consumer consumer, String pluginVersion, Integer spigotID, String gitKey) { + // if (T2CVlibConfig.getUpdateCheckFullDisable()) return; + String RepoURL = "https://git.t2code.net/api/v1/repos/" + gitKey + "/releases?limit=1"; + // if (!T2CVlibConfig.getSeePreReleaseUpdates()) { + RepoURL = RepoURL + "&pre-release=false"; + // } + String finalRepoURL = RepoURL; + try { + URL url = new URL(finalRepoURL); + URLConnection yc = url.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + yc.getInputStream())); + String inputLine; + String data = ""; + while ((inputLine = in.readLine()) != null) + data = inputLine; + in.close(); + data = data.substring(1, data.length() - 1); + if (data.isEmpty()) { + consumer.accept(null); + return; + } + JSONObject obj = new JSONObject(data); + String updateTitle = obj.getString("name"); + String version = obj.getString("tag_name"); + String updateDescription = obj.getString("body").replace("\n", "
").replace("\r", "").replace("'", "''"); + String updateUrl = obj.getString("html_url"); + boolean preRelease = obj.getBoolean("prerelease"); + + String date = obj.getString("published_at"); + SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a"); + Date parsedDate = inputFormat.parse(date); + String publishedAt = outputFormat.format(parsedDate); + + JSONArray downloadArray = obj.getJSONArray("assets"); + String gitURL = updateUrl; + String downloadURL; + if (downloadArray.isEmpty()) { + downloadURL = "https://www.spigotmc.org/resources/" + spigotID; + } else { + downloadURL = downloadArray.getJSONObject(0).getString("browser_download_url"); + } + + if (!preRelease) { + downloadURL = "https://www.spigotmc.org/resources/" + spigotID; + updateUrl = "https://www.spigotmc.org/resources/" + spigotID; + } + + T2CupdateWebData webData = new T2CupdateWebData(updateTitle, version, updateDescription, updateUrl, publishedAt, downloadURL, gitURL, preRelease); + consumer.accept(webData); + } catch (Exception var10) { + Boolean load = false; + if (T2CVupdateAPI.bungeePluginVersins.containsKey(plugin.get().getDescription().getName())) { + load = T2CVupdateAPI.bungeePluginVersins.get(plugin.get().getDescription().getName()).load; + } + T2CVupdateObject update = new T2CVupdateObject( + plugin.get().getDescription().getName(), + Optional.ofNullable(pluginVersion), + null, + load, + false, + true + ); + T2CVupdateAPI.bungeePluginVersins.put(plugin.get().getDescription().getName(), update); + logger.info("§4 Cannot look for updates: {}", var10.getMessage()); + } + + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/api/yaml/T2CVconfig.java b/src/main/java/net/t2code/t2codelib/VELOCITY/api/yaml/T2CVconfig.java new file mode 100644 index 0000000..940c114 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/api/yaml/T2CVconfig.java @@ -0,0 +1,86 @@ +package net.t2code.t2codelib.VELOCITY.api.yaml; + +import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.plugin.PluginContainer; +import ninja.leaping.configurate.ConfigurationNode; +import ninja.leaping.configurate.commented.CommentedConfigurationNode; +import ninja.leaping.configurate.yaml.YAMLConfigurationLoader; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.slf4j.Logger; + + +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +public class T2CVconfig { + private final Path configPath; + private final @NonNull YAMLConfigurationLoader loader; + private CommentedConfigurationNode configNode; + + public T2CVconfig(Path configPath, ProxyServer proxy, PluginContainer pluginContainer, Logger logger) { + this.configPath = configPath; + loader = YAMLConfigurationLoader.builder().setPath(configPath).build(); + try { + this.configNode = (CommentedConfigurationNode) loader.load(); + } catch (IOException e) { + logger.error("Error loading configuration file {}", configPath.getFileName(), e); + } + } + + public void saveConfig() { + try { + loader.save(configNode); + } catch (IOException e) { + throw new RuntimeException("Error saving configuration file " + configPath.getFileName(), e); + } + } + + public void set(String path, Object value) { + configNode.getNode((Object[]) path.split("\\.")).setValue(value); + } + + public String select(String path) { + return configNode.getNode((Object[]) path.split("\\.")).getString(); + } + + public int selectInt(String path) { + return configNode.getNode((Object[]) path.split("\\.")).getInt(); + } + + public boolean selectBoolean(String path) { + return configNode.getNode((Object[]) path.split("\\.")).getBoolean(); + } + + public double selectDouble(String path) { + return configNode.getNode((Object[]) path.split("\\.")).getDouble(); + } + + public List selectList(String path) { + List list = new ArrayList<>(); + ConfigurationNode node = configNode.getNode((Object[]) path.split("\\.")); + if (node.hasListChildren()) { + for (ConfigurationNode child : node.getChildrenList()) { + list.add(child.getString("")); + } + } + return list; + } + + public List selectList(String prefix, String path) { + List output = new ArrayList<>(); + ConfigurationNode node = configNode.getNode((Object[]) path.split("\\.")); + if (node.hasListChildren()) { + for (ConfigurationNode child : node.getChildrenList()) { + output.add(prefix + child.getString()); + } + } + return output; + } + + + public void setList(List value, String path) { + configNode.getNode((Object[]) path.split("\\.")).setValue(value); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CVload.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CVload.java new file mode 100644 index 0000000..f1f3c27 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CVload.java @@ -0,0 +1,65 @@ +package net.t2code.t2codelib.VELOCITY.system; + + +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.proxy.ProxyServer; +import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers; +import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; +import net.t2code.t2codelib.VELOCITY.system.config.VelocityConfig; +import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CVapiCGUI; +import org.slf4j.Logger; + +import java.util.Optional; + +public class T2CVload { + public static ProxyServer server = T2CodeVMain.server; + public static Logger logger = T2CodeVMain.logger; + + + + public static void onLoad(Optional plugin, String prefix, String version, String spigot, String discord, Integer spigotID, Integer bstatsID, String url) { + long long_ = System.currentTimeMillis(); + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + // T2CVsend.console(prefix + " §2Autor: §6" + String.valueOf(plugin.get().getDescription().getAuthors()).replace("[", "").replace("]", "")); + T2CVsend.console(prefix + " §2Version: §6" + version); + T2CVsend.console(prefix + " §2Spigot: §6" + spigot); + T2CVsend.console(prefix + " §2Discord: §6" + discord); + + + + //T2CVlibConfig.create(); + VelocityConfig.main(); + // try { + // T2CVlibConfig.select(); + // } catch (IOException e) { + // throw new RuntimeException(e); + // } + + + + + + //API + server.getChannelRegistrar().register(T2CodeVMain.bcmd); + + server.getChannelRegistrar().register(T2CodeVMain.bonlp); + T2CVPlayers.sendToSpigotDeleteAll(); + + // if (T2CVlibConfig.getApiCommandGUIEnable()) { + server.getChannelRegistrar().register(T2CodeVMain.cguiopl); + T2CVapiCGUI.sendToSpigotDeleteAll(); + // } + + // if (T2CVlibConfig.getApiAutoResponse()) { + server.getChannelRegistrar().register(T2CodeVMain.aresp); + // } + + // if (T2CVlibConfig.getApiOpSecurity()) { + server.getChannelRegistrar().register(T2CodeVMain.opsec); + //} + + + T2CVsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); + T2CVsend.console(prefix + "§4============================= " + prefix + " §4============================="); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CodeVMain.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CodeVMain.java new file mode 100644 index 0000000..4ef0695 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/T2CodeVMain.java @@ -0,0 +1,81 @@ +package net.t2code.t2codelib.VELOCITY.system; + +import com.google.inject.Inject; +import com.velocitypowered.api.event.Subscribe; +import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; +import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.proxy.ProxyServer; +import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; +import com.velocitypowered.api.scheduler.Scheduler; +import net.t2code.t2codelib.Util; +import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers; +import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend; +import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI; +import org.slf4j.Logger; + +import java.io.IOException; +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +public class T2CodeVMain { + + + public static Optional pluginContainer; + + + + public static final String prefix = "[T2CodeLib]"; + public static ProxyServer server; + public static Logger logger; + public static final MinecraftChannelIdentifier bcmd = MinecraftChannelIdentifier.from("t2c:bcmd"); + public static final MinecraftChannelIdentifier bonlp = MinecraftChannelIdentifier.from("t2c:bonlp"); + public static final MinecraftChannelIdentifier cguiopl = MinecraftChannelIdentifier.from("t2c:cguiopl"); + public static final MinecraftChannelIdentifier aresp = MinecraftChannelIdentifier.from("t2c:aresp"); + public static final MinecraftChannelIdentifier opsec = MinecraftChannelIdentifier.from("t2c:opsec"); + + + @Inject + public T2CodeVMain(ProxyServer server, Logger logger) throws IOException { + // Plugin startup logic + T2CodeVMain.server = server; + T2CodeVMain.logger = logger; + pluginContainer = server.getPluginManager().getPlugin("t2codelib"); + + // orgVersion = plugin.getDescription().getVersion(); + // autor = plugin.getDescription().getAuthor(); + + int pluginId = Util.getBstatsID(); + // T2CVmetrics metrics = metricsFactory.make(this, pluginId); + + + } + + @Subscribe + public void onProxyShutdown(ProxyShutdownEvent event) { + // Plugin shutdown logic + T2CVPlayers.sendToSpigotDeleteAll(); + + T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); + T2CVsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(pluginContainer.get().getDescription().getAuthors()).replace("[", "").replace("]", "")); + + T2CVsend.console(Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot()); + T2CVsend.console(Util.getPrefix() + " §2Discord: §6" + Util.getDiscord()); + T2CVsend.console(Util.getPrefix() + " §4Plugin successfully disabled."); + T2CVsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); + } + + + @Subscribe + public void onProxyInitialize(ProxyInitializeEvent event) { + // Schedule the task to check for updates every 60 minutes + Scheduler scheduler = server.getScheduler(); + + scheduler.buildTask(this, this:: checkForUpdates) + .repeat(60, TimeUnit.MINUTES) + .schedule(); + } + private void checkForUpdates() { + T2CVupdateAPI.checkForUpdates(pluginContainer, prefix, Util.getDiscord(), Util.getSpigotID(), Util.getGit()); + } +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/bstats/T2CVmetrics.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/bstats/T2CVmetrics.java new file mode 100644 index 0000000..39b7e93 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/bstats/T2CVmetrics.java @@ -0,0 +1,134 @@ +package net.t2code.t2codelib.VELOCITY.system.bstats; + +import com.google.inject.Inject; +import com.velocitypowered.api.plugin.PluginContainer; +import com.velocitypowered.api.plugin.PluginDescription; +import com.velocitypowered.api.plugin.annotation.DataDirectory; +import com.velocitypowered.api.proxy.ProxyServer; +import org.bstats.MetricsBase; +import org.bstats.charts.CustomChart; +import org.bstats.config.MetricsConfig; +import org.bstats.json.JsonObjectBuilder; +import org.slf4j.Logger; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; + +public class T2CVmetrics { + + /** + * A factory to create new Metrics classes. + */ + public static class Factory { + + private final ProxyServer server; + private final Logger logger; + private final Path dataDirectory; + + // The constructor is not meant to be called by the user. + // The instance is created using Dependency Injection + @Inject + private Factory(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) { + this.server = server; + this.logger = logger; + this.dataDirectory = dataDirectory; + } + + /** + * Creates a new Metrics class. + * + * @param plugin The plugin instance. + * @param serviceId The id of the service. + * It can be found at What is my plugin id? + *

Not to be confused with Velocity's {@link PluginDescription#getId()} method! + * @return A Metrics instance that can be used to register custom charts. + *

The return value can be ignored, when you do not want to register custom charts. + */ + public T2CVmetrics make(Object plugin, int serviceId) { + return new T2CVmetrics(plugin, server, logger, dataDirectory, serviceId); + } + } + + private final PluginContainer pluginContainer; + private final ProxyServer server; + private MetricsBase metricsBase; + + private T2CVmetrics(Object plugin, ProxyServer server, Logger logger, Path dataDirectory, int serviceId) { + pluginContainer = server.getPluginManager().fromInstance(plugin) + .orElseThrow(() -> new IllegalArgumentException("The provided instance is not a plugin")); + this.server = server; + + File configFile = dataDirectory.getParent().resolve("bStats").resolve("config.txt").toFile(); + MetricsConfig config; + try { + config = new MetricsConfig(configFile, true); + } catch (IOException e) { + logger.error("Failed to create bStats config", e); + return; + } + + metricsBase = new MetricsBase( + "velocity", + config.getServerUUID(), + serviceId, + config.isEnabled(), + this::appendPlatformData, + this::appendServiceData, + task -> server.getScheduler().buildTask(plugin, task).schedule(), + () -> true, + logger::warn, + logger::info, + config.isLogErrorsEnabled(), + config.isLogSentDataEnabled(), + config.isLogResponseStatusTextEnabled() + ); + + if (!config.didExistBefore()) { + // Send an info message when the bStats config file gets created for the first time + logger.info("Velocity and some of its plugins collect metrics and send them to bStats (https://bStats.org)."); + logger.info("bStats collects some basic information for plugin authors, like how many people use"); + logger.info("their plugin and their total player count. It's recommend to keep bStats enabled, but"); + logger.info("if you're not comfortable with this, you can opt-out by editing the config.txt file in"); + logger.info("the '/plugins/bStats/' folder and setting enabled to false."); + } + } + + /** + * Shuts down the underlying scheduler service. + */ + public void shutdown() { + metricsBase.shutdown(); + } + + /** + * Adds a custom chart. + * + * @param chart The chart to add. + */ + public void addCustomChart(CustomChart chart) { + if (metricsBase != null) { + metricsBase.addCustomChart(chart); + } + } + + private void appendPlatformData(JsonObjectBuilder builder) { + builder.appendField("playerAmount", server.getPlayerCount()); + builder.appendField("managedServers", server.getAllServers().size()); + builder.appendField("onlineMode", server.getConfiguration().isOnlineMode() ? 1 : 0); + builder.appendField("velocityVersionVersion", server.getVersion().getVersion()); + builder.appendField("velocityVersionName", server.getVersion().getName()); + builder.appendField("velocityVersionVendor", server.getVersion().getVendor()); + + builder.appendField("javaVersion", System.getProperty("java.version")); + builder.appendField("osName", System.getProperty("os.name")); + builder.appendField("osArch", System.getProperty("os.arch")); + builder.appendField("osVersion", System.getProperty("os.version")); + builder.appendField("coreCount", Runtime.getRuntime().availableProcessors()); + } + + private void appendServiceData(JsonObjectBuilder builder) { + builder.appendField("pluginVersion", pluginContainer.getDescription().getVersion().orElse("unknown")); + } + +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java new file mode 100644 index 0000000..422f9cc --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/T2CVlibConfig.java @@ -0,0 +1,60 @@ +package net.t2code.t2codelib.VELOCITY.system.config; + +public class T2CVlibConfig { + +// public static void create() throws IOException { +// long startTime = System.currentTimeMillis(); +// Path configFile = Paths.get("config.yml"); +// +// if (!T2CodeVMain.getPlugin().getDataFolder().exists()) { +// T2CodeVMain.getPlugin().getDataFolder().mkdir(); +// } +// +// if (!configFile.exists()) { +// configFile.createNewFile(); +// } +// +// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); +// +// configuration.set("UpdateCheck.TimerInMin", 60); +// configuration.set("UpdateCheck.SeePreReleaseUpdates", true); +// configuration.set("Plugin.UpdateCheck.AllPlugins.FullDisable", false); +// +// configuration.set("API.CommandGUI.Enable", false); +// configuration.set("API.AutoResponse.Enable", false); +// configuration.set("API.OPSecurity.Enable", false); +// +// ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, configFile); +// +// long elapsedTime = System.currentTimeMillis() - startTime; +// T2CVsend.console(Util.getPrefix() + " §2config.yml was successfully created / updated. §7- §e" + elapsedTime + "ms"); +// } +// +// public static void select() throws IOException { +// File configFile = new File(T2CodeVMain.getPlugin().getDataFolder(), "config.yml"); +// Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile); +// +// updateTimer = configuration.getInt("UpdateCheck.TimerInMin"); +// seePreReleaseUpdates = configuration.getBoolean("UpdateCheck.SeePreReleaseUpdates"); +// updateCheckFullDisable = configuration.getBoolean("Plugin.UpdateCheck.AllPlugins.FullDisable"); +// +// apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable"); +// apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable"); +// apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable"); +// } +// +// +// @Getter +// private static Integer updateTimer; +// @Getter +// private static Boolean seePreReleaseUpdates; +// @Getter +// private static Boolean updateCheckFullDisable; +// @Getter +// private static Boolean apiCommandGUIEnable; +// @Getter +// private static Boolean apiAutoResponse; +// @Getter +// private static Boolean apiOpSecurity; +// +} diff --git a/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/VelocityConfig.java b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/VelocityConfig.java new file mode 100644 index 0000000..c9efeaa --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/VELOCITY/system/config/VelocityConfig.java @@ -0,0 +1,131 @@ +package net.t2code.t2codelib.VELOCITY.system.config; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class VelocityConfig { + + private static final String CONFIG_FILE = "plugin_config.yml"; + + private String pluginName; + private int maxConnections; + private boolean isEnabled; + private boolean debugMode; + private int timeoutSeconds; + + public VelocityConfig(String pluginName, int maxConnections, boolean isEnabled, boolean debugMode, int timeoutSeconds) { + this.pluginName = pluginName; + this.maxConnections = maxConnections; + this.isEnabled = isEnabled; + this.debugMode = debugMode; + this.timeoutSeconds = timeoutSeconds; + } + + public static VelocityConfig loadConfig() { + Path configFile = Paths.get(CONFIG_FILE); + if (!Files.exists(configFile)) { + // Default configuration if file doesn't exist + return new VelocityConfig("MyPlugin", 100, true, false, 30); + } + + try { + // Read configuration from file + String content = Files.readString(configFile); + String[] lines = content.split("\\r?\\n"); + + // Parse the configuration + String pluginName = lines[0].split(":")[1].trim(); + int maxConnections = Integer.parseInt(lines[1].split(":")[1].trim()); + boolean isEnabled = Boolean.parseBoolean(lines[2].split(":")[1].trim()); + boolean debugMode = Boolean.parseBoolean(lines[3].split(":")[1].trim()); + int timeoutSeconds = Integer.parseInt(lines[4].split(":")[1].trim()); + + return new VelocityConfig(pluginName, maxConnections, isEnabled, debugMode, timeoutSeconds); + } catch (IOException | ArrayIndexOutOfBoundsException | NumberFormatException e) { + e.printStackTrace(); + // Handle exception: default configuration or logging + return new VelocityConfig("MyPlugin", 100, true, false, 30); + } + } + + public void saveConfig() { + Path configFile = Paths.get(CONFIG_FILE); + try { + // Write configuration to file + String configContent = "pluginName: " + pluginName + "\n" + + "maxConnections: " + maxConnections + "\n" + + "isEnabled: " + isEnabled + "\n" + + "debugMode: " + debugMode + "\n" + + "timeoutSeconds: " + timeoutSeconds + "\n"; + Files.writeString(configFile, configContent); + + } catch (IOException e) { + e.printStackTrace(); + // Handle exception: logging or alerting + } + } + + // Getters and setters + public String getPluginName() { + return pluginName; + } + + public void setPluginName(String pluginName) { + this.pluginName = pluginName; + } + + public int getMaxConnections() { + return maxConnections; + } + + public void setMaxConnections(int maxConnections) { + this.maxConnections = maxConnections; + } + + public boolean isEnabled() { + return isEnabled; + } + + public void setEnabled(boolean enabled) { + isEnabled = enabled; + } + + public boolean isDebugMode() { + return debugMode; + } + + public void setDebugMode(boolean debugMode) { + this.debugMode = debugMode; + } + + public int getTimeoutSeconds() { + return timeoutSeconds; + } + + public void setTimeoutSeconds(int timeoutSeconds) { + this.timeoutSeconds = timeoutSeconds; + } + + public static void main() { + // Example usage: + VelocityConfig config = VelocityConfig.loadConfig(); + System.out.println("Loaded Configuration:"); + System.out.println("Plugin Name: " + config.getPluginName()); + System.out.println("Max Connections: " + config.getMaxConnections()); + System.out.println("Is Enabled: " + config.isEnabled()); + System.out.println("Debug Mode: " + config.isDebugMode()); + System.out.println("Timeout Seconds: " + config.getTimeoutSeconds()); + + // Modify configuration + config.setMaxConnections(150); + config.setEnabled(false); + config.setDebugMode(true); + config.setTimeoutSeconds(60); + + // Save configuration + config.saveConfig(); + System.out.println("Configuration saved."); + } +} diff --git a/src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java b/src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java deleted file mode 100644 index 043219f..0000000 --- a/src/main/java/net/t2code/t2codelib/Velocity/VelocityMain.java +++ /dev/null @@ -1,118 +0,0 @@ -package net.t2code.t2codelib.Velocity; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteStreams; -import com.google.inject.Inject; -import com.velocitypowered.api.command.CommandManager; -import com.velocitypowered.api.command.CommandSource; -import com.velocitypowered.api.event.Subscribe; -import com.velocitypowered.api.event.connection.PluginMessageEvent; -import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; -import com.velocitypowered.api.plugin.Plugin; -import com.velocitypowered.api.proxy.ConsoleCommandSource; -import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.api.proxy.ProxyServer; -import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier; -import net.t2code.t2codelib.Util; -import org.slf4j.Logger; - - - -@Plugin(id = "t2codelib", name = "T2CodeLib", version = "16.7_dev-01", authors = {"JaTiTV"}) -public class VelocityMain { - - String prefix = "[T2CodeLib]"; - - protected final ProxyServer server; - protected final Logger logger; - public static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from("t2c:bcmd"); - // public static final MinecraftChannelIdentifier IDENTIFIER2 = MinecraftChannelIdentifier.from("booster:activate"); - - @Inject - public VelocityMain(ProxyServer server, Logger logger) { - long long_ = System.currentTimeMillis(); - this.server = server; - this.logger = logger; - - logger.info("============================= {} =============================", prefix); - logger.info("Autor: JaTiTV"); - logger.info("Version: 16.7_dev-01"); - logger.info("Plugin loaded successfully. - {}ms", System.currentTimeMillis() - long_); - logger.info("============================= {} =============================", prefix); - - } - - - @Subscribe - public void onProxyInitialization(ProxyInitializeEvent event) { - server.getChannelRegistrar().register(IDENTIFIER); - // server.getChannelRegistrar().register(IDENTIFIER2); - } - - @Subscribe - public void onPluginMessageFromPlayer(PluginMessageEvent event) { - if (event.getIdentifier() != IDENTIFIER) { - return; - } - ByteArrayDataInput stream = ByteStreams.newDataInput(event.getData()); - String channel = stream.readUTF(); - String input = stream.readUTF(); - String serverID; - try { - serverID = stream.readUTF(); - } catch (Exception i) { - serverID = "not Found"; - } - - if (channel.equals("T2Code-Console")) { - logger.info("{} [{}] T2C BCMD Command Console: {}", prefix, serverID, input); - dispatchCommand(input); - } else { - Player player = server.getPlayer(channel).orElse(null); - if (player != null) { - logger.info("{} [{}] T2C BCMD Command {}: {}", prefix, serverID, player, input); - executeCommand(player, input); - } - } - event.setResult(PluginMessageEvent.ForwardResult.handled()); - } - -// public void sendToSpigot(String sender, String boostertype, String step, String starter, String starttime, String starteruuid) { -// ByteArrayOutputStream stream = new ByteArrayOutputStream(); -// DataOutputStream output = new DataOutputStream(stream); -// try { -// output.writeUTF(boostertype); -// output.writeUTF(step); -// output.writeUTF(starter); -// output.writeUTF(starttime); -// output.writeUTF(starteruuid); -// } catch (IOException e) { -// java.util.logging.Logger.getLogger(e.getMessage()); -// } -// Optional player = server.getPlayer(sender); -// if (!player.isPresent()) { -// return; -// } -// server.getAllServers().forEach((server) -> { -// if (server != player.get().getCurrentServer().get().getServer()) { -// server.sendPluginMessage(IDENTIFIER2, stream.toByteArray()); -// } -// }); -// } - - public void dispatchCommand(String input) { - // Get the console command source - ConsoleCommandSource console = server.getConsoleCommandSource(); - - // Dispatch the command - server.getCommandManager().executeAsync(console, input).join(); - } - - public void executeCommand(Player player, String input) { - CommandManager commandManager = server.getCommandManager(); - - // Dispatch the command - commandManager.executeImmediatelyAsync(player, input); - } - -} diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml index 52e5668..5fcd19e 100644 --- a/src/main/resources/bungee.yml +++ b/src/main/resources/bungee.yml @@ -1,5 +1,18 @@ name: T2CodeLib version: ${project.version} -main: net.t2code.t2codelib.BUNGEE.system.T2CodeBMain +main: net.t2code.t2codelib.bungee.system.T2CodeBMain author: JaTiTV, Jkobs -description: Library from T2Code Plugins \ No newline at end of file +description: Library from T2Code Plugins + + + + + + _______ ___ _____ _ _ + |__ __|__ \ / ____| | | | | + | | ) | | ___ __| | ___ _ __ ___| |_ + | | / /| | / _ \ / _` |/ _ \ | '_ \ / _ \ __| + | | / /_| |___| (_) | (_| | __/_| | | | __/ |_ + |_| |____|\_____\___/ \__,_|\___(_)_| |_|\___|\__| + + diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 75a1fb7..68b2254 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: T2CodeLib version: '${project.version}' -main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain +main: net.t2code.t2codelib.spigot.system.T2CodeLibMain api-version: 1.13 prefix: T2CodeLib authors: [ JaTiTV ] diff --git a/src/main/resources/velocity-plugin.json b/src/main/resources/velocity-plugin.json new file mode 100644 index 0000000..04b68d0 --- /dev/null +++ b/src/main/resources/velocity-plugin.json @@ -0,0 +1 @@ +{"id":"t2codelib","name":"T2CodeLib","version":"${project.version}","authors":["JaTiTV"],"dependencies":[],"main":"net.t2code.t2codelib.VELOCITY.system.T2CodeVMain"} \ No newline at end of file