Compare commits

...

2 Commits

Author SHA1 Message Date
17d3aed11f velocity 10% 2024-06-17 01:50:30 +02:00
a01b4b4330 input dev-01 2024-06-15 21:13:20 +02:00
46 changed files with 1565 additions and 66 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding"> <component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component> </component>

View File

@ -56,5 +56,10 @@
<option name="name" value="BenCodez Repo" /> <option name="name" value="BenCodez Repo" />
<option name="url" value="https://nexus.bencodez.com/repository/maven-public/" /> <option name="url" value="https://nexus.bencodez.com/repository/maven-public/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="papermc" />
<option name="name" value="papermc" />
<option name="url" value="https://repo.papermc.io/repository/maven-public/" />
</remote-repository>
</component> </component>
</project> </project>

View File

@ -5,6 +5,9 @@
<item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" /> <item index="0" class="java.lang.String" itemvalue="net.md_5.bungee.event.EventHandler" />
<item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" /> <item index="1" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
</list> </list>
<writeAnnotations>
<writeAnnotation name="lombok.Getter" />
</writeAnnotations>
</component> </component>
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager"> <component name="MavenProjectsManager">

19
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>16.7</version> <version>16.7_dev-19</version>
<!--version>VERSION_snapshot-0</version--> <!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version--> <!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version--> <!--version>VERSION_dev-0</version-->
@ -15,7 +15,7 @@
<name>T2CodeLib</name> <name>T2CodeLib</name>
<properties> <properties>
<java.version>1.8</java.version> <java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
@ -63,6 +63,10 @@
</build> </build>
<repositories> <repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<!-- Spigot --> <!-- Spigot -->
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -146,6 +150,14 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Velocity -->
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- repo.t2code / T2Code --> <!-- repo.t2code / T2Code -->
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
@ -202,7 +214,7 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.24</version> <version>1.18.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -227,6 +239,7 @@
<version>20230227</version> <version>20230227</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -6,7 +6,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
public class T2CBtab { public class T2CBtab {

View File

@ -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.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; 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.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.junit.Ignore;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;

View File

@ -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.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -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.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

View File

@ -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.ProxyServer;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;

View File

@ -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.bstats.T2CBmetrics;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig; import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers; import net.t2code.t2codelib.BUNGEE.api.bungeePlayers.T2CBbungeePlayers;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.T2CplmsgBcmd; import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.T2CplmsgBcmd;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse.T2CapiAutoResponse; import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.autoResponse.T2CapiAutoResponse;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUI; import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.commandgui.T2CapiCGUI;
import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSecurity; import net.t2code.t2codelib.BUNGEE.api.pluginMessaging.opSecurity.T2CapiOpSecurity;
import java.io.IOException; import java.io.IOException;
public class T2CBload { 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(); long long_ = System.currentTimeMillis();
T2CBsend.console(prefix + "§4============================= " + prefix + " §4============================="); 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 + " §2Version: §6" + version);
T2CBsend.console(prefix + " §2Spigot: §6" + spigot); T2CBsend.console(prefix + " §2Spigot: §6" + spigot);
T2CBsend.console(prefix + " §2Discord: §6" + discord); T2CBsend.console(prefix + " §2Discord: §6" + discord);

View File

@ -1,5 +1,6 @@
package net.t2code.t2codelib.BUNGEE.system; package net.t2code.t2codelib.BUNGEE.system;
import lombok.Getter;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences; import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
@ -8,16 +9,12 @@ import net.t2code.t2codelib.Util;
public class T2CodeBMain extends Plugin { public class T2CodeBMain extends Plugin {
@Getter
private static Plugin plugin; private static Plugin plugin;
public static Plugin getPlugin() {
return plugin;
}
private static String version; private static String version;
private static String orgVersion;
private static String autor;
@Getter
private static Boolean mmIsLoad = true; private static Boolean mmIsLoad = true;
private static BungeeAudiences adventure; private static BungeeAudiences adventure;
@ -33,8 +30,8 @@ public class T2CodeBMain extends Plugin {
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
plugin = this; plugin = this;
orgVersion = plugin.getDescription().getVersion(); String orgVersion = plugin.getDescription().getVersion();
autor = plugin.getDescription().getAuthor(); String author = plugin.getDescription().getAuthor();
try { try {
adventure = BungeeAudiences.create(this); adventure = BungeeAudiences.create(this);
T2CBsend.info(this,"Adventure load!"); T2CBsend.info(this,"Adventure load!");
@ -42,7 +39,7 @@ public class T2CodeBMain extends Plugin {
T2CBsend.error(this,"Adventure can not be load!"); T2CBsend.error(this,"Adventure can not be load!");
mmIsLoad = false; 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(); version = plugin.getDescription().getVersion();
} }
@ -64,7 +61,4 @@ public class T2CodeBMain extends Plugin {
T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled."); T2CBsend.console(Util.getPrefix() + " §4Plugin successfully disabled.");
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
} }
public static Boolean getMmIsLoad() {
return mmIsLoad;
}
} }

View File

@ -1,14 +1,11 @@
package net.t2code.t2codelib.SPIGOT.api.commands; 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.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.rmi.MarshalledObject;
import java.util.Map; import java.util.Map;
public class T2Ccmd { public class T2Ccmd {

View File

@ -1,7 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.messages; package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug; import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

View File

@ -3,23 +3,23 @@ package net.t2code.t2codelib.SPIGOT.api.messages;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
public class T2Ctemplate { public class T2Ctemplate {
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) { public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord) {
return onLoadHeader(prefix, autor, version, spigot, discord, null, null); return onLoadHeader(prefix, author, version, spigot, discord, null, null);
} }
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) { public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord, Boolean isPremium) {
return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null); return onLoadHeader(prefix, author, version, spigot, discord, isPremium, null);
} }
public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) { public static Long onLoadHeader(String prefix, List<String> author, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
Long long_ = System.currentTimeMillis(); Long long_ = System.currentTimeMillis();
T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>"); T2Csend.console(prefix + " <dark_red> _______ </dark_red><gray>___ </gray><dark_red>_____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>"); T2Csend.console(prefix + " <dark_red> |__ __|</dark_red><gray>__ \\ </gray><dark_red>/ ____|</dark_red>");
@ -28,7 +28,7 @@ public class T2Ctemplate {
T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>"); T2Csend.console(prefix + " <dark_red> | | </dark_red><gray>/ /_</gray><dark_red>| |____ </dark_red>");
T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>"); T2Csend.console(prefix + " <dark_red> |_| </dark_red><gray>|____|</gray><dark_red>\\_____|</dark_red>");
T2Csend.console(prefix + " §4 §e╔══════════════════════════"); 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║ §2Version: §6" + version);
T2Csend.console(prefix + " §4 §e║ §2Spigot: §6" + spigot); T2Csend.console(prefix + " §4 §e║ §2Spigot: §6" + spigot);
T2Csend.console(prefix + " §4 §e║ §2Discord: §6" + discord); T2Csend.console(prefix + " §4 §e║ §2Discord: §6" + discord);
@ -81,7 +81,7 @@ public class T2Ctemplate {
/** /**
* @param prefix * @param prefix
* @param autor * @param author
* @param spigot * @param spigot
* @param discord * @param discord
* @deprecated reason this method is deprecated <br/> * @deprecated reason this method is deprecated <br/>
@ -94,7 +94,7 @@ public class T2Ctemplate {
* </pre></blockquote> * </pre></blockquote>
*/ */
@Deprecated @Deprecated
public static void onDisable(String prefix, List<String> autor, String version, String spigot, String discord) { public static void onDisable(String prefix, List<String> author, String version, String spigot, String discord) {
T2Csend.console(prefix + " §2Version: §6" + version); T2Csend.console(prefix + " §2Version: §6" + version);
T2Csend.console(prefix + " §4Plugin successfully disabled."); T2Csend.console(prefix + " §4Plugin successfully disabled.");
} }
@ -102,7 +102,7 @@ public class T2Ctemplate {
public static void onDisable(String prefix, Plugin plugin) { public static void onDisable(String prefix, Plugin plugin) {
T2Csend.console(prefix + " §4 §e╔══════════════════════════"); T2Csend.console(prefix + " §4 §e╔══════════════════════════");
T2Csend.console(prefix + " §4 §e║ §2Version: §6" + plugin.getDescription().getVersion()); 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║ §4Plugin successfully disabled.");
T2Csend.console(prefix + " §4 §e╚══════════════════════════"); T2Csend.console(prefix + " §4 §e╚══════════════════════════");
} }
@ -130,27 +130,21 @@ public class T2Ctemplate {
boolean player = sender instanceof Player; boolean player = sender instanceof Player;
String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName()); String stPlugin = "<dark_red>║</dark_red> <yellow>Plugin:</yellow> <gold>[pl]</gold>".replace("[pl]", plugin.getName());
String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion); String stVersion = "<dark_red>║</dark_red> <yellow>Version:</yellow> <gold>[ver]</gold>".replace("[ver]", pluginVersion);
String stAutor = "<dark_red>║</dark_red> <yellow>Autor(s):</yellow> <gold>[autor]</gold>".replace("[autor]", plugin.getDescription().getAuthors().toString()); String stAuthor = "<dark_red>║</dark_red> <yellow>Author(s):</yellow> <gold>[author]</gold>".replace("[author]", plugin.getDescription().getAuthors().toString());
String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ? String stUpdate = "<dark_red>║</dark_red> <yellow>New version available:</yellow> [up]".replace("[up]", webData != null ? update ?
"<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>"); "<dark_green>YES</dark_green>" : "<red>no</red>" : "<b><dark_red>It could not be checked for updates!</dark_red></b>");
stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : ""; stNVersion = update ? "<br><dark_red>║</dark_red> <yellow>Newest Version:</yellow> <gold>[nver]</gold>".replace("[nver]",player ? "<hover:show_text:'<yellow>Click for the update information</yellow>'><click:run_command:'/t2code updateinfo "+plugin.getName()+"'>"+publicVersion+"</click></hover>":publicVersion) : "";
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> " String stLink = getString(spigotID, discord, player);
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
.replace("[dlink]", discord);
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
String stLink = player ? stLinkPlayer : stLinkConsole;
String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]", String pr = premiumVerified != null ? "<br><dark_red>║</dark_red> <yellow>Premium verified:</yellow> [pr]".replace("[pr]",
premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : ""; premiumVerified ? "<dark_green>YES</dark_green>" : "<red>NO</red>") : "";
String stMSG = text == null || text.equals("") ? "" : "<br><dark_red>║</dark_red> " + text; String stMSG = text == null || text.isEmpty() ? "" : "<br><dark_red>║</dark_red> " + text;
T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>" T2Csend.sender(sender, "<br><dark_red>╔════════════════════════════════</dark_red>"
+ "<br>" + stPlugin + "<br>" + stPlugin
+ "<br>" + stVersion + "<br>" + stVersion
+ stMSG + stMSG
+ "<br>" + stAutor + "<br>" + stAuthor
+ "<br>" + stUpdate + "<br>" + stUpdate
+ stNVersion + stNVersion
+ "<br>" + stLink + "<br>" + stLink
@ -158,6 +152,17 @@ public class T2Ctemplate {
+ "<br><dark_red>╚════════════════════════════════</dark_red>"); + "<br><dark_red>╚════════════════════════════════</dark_red>");
} }
private static @NotNull String getString(int spigotID, String discord, boolean player) {
String stLinkPlayer = "<dark_red>║</dark_red> <yellow><hover:show_text:'<green>Go to the Spigot page</green>'><click:open_url:'[slink]'>Spigot</click></hover></yellow> "
.replace("[slink]", "https://www.spigotmc.org/resources/" + spigotID)
+ "<dark_red>-</dark_red> <dark_purple><hover:show_text:'<green>Go to the T2Code Support Discord</green>'><click:open_url:'[dlink]'>Discord</click></hover></dark_purple>"
.replace("[dlink]", discord);
String stLinkConsole = "<dark_red>║</dark_red> <yellow>Spigot:</yellow> <gold>https://www.spigotmc.org/resources/" + spigotID + "</gold>"
+ "<br><dark_red>║</dark_red> <yellow>Discord:</yellow> <gold>" + discord + "</gold>";
String stLink = player ? stLinkPlayer : stLinkConsole;
return stLink;
}
public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) { public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) {
sendInfo(sender, plugin, spigotID, discord, null, text); sendInfo(sender, plugin, spigotID, discord, null, text);
} }

View File

@ -1,7 +1,5 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion; 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; import org.bukkit.Bukkit;

View File

@ -1,8 +1,6 @@
package net.t2code.t2codelib.SPIGOT.api.minecraftVersion; package net.t2code.t2codelib.SPIGOT.api.minecraftVersion;
import lombok.Getter; import lombok.Getter;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
public class T2CnmsVersions { public class T2CnmsVersions {

View File

@ -15,7 +15,6 @@ import java.io.*;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.function.Consumer; import java.util.function.Consumer;

View File

@ -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.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; 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.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver; import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.T2CupdateObject;

View File

@ -10,9 +10,7 @@ import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException; import java.io.IOException;
public class Commands { public class Commands {

View File

@ -17,7 +17,6 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

View File

@ -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.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;

View File

@ -0,0 +1,28 @@
package net.t2code.t2codelib;
import java.util.Optional;
public class T2CVupdateObject {
public Optional<String> pluginName;
public Optional<String> pluginVersion;
public T2CupdateWebData webData;
public Boolean load;
public Boolean updateAvailable;
public Boolean updateCheckOnJoin;
public T2CVupdateObject(Optional<String> pluginName,
Optional<String> 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;
}
}

View File

@ -1,6 +1,8 @@
package net.t2code.t2codelib; package net.t2code.t2codelib;
import java.util.Optional;
public class T2CupdateObject { public class T2CupdateObject {
public String pluginName; public String pluginName;

View File

@ -5,10 +5,10 @@ import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
public class Util { public class Util {
@Getter @Getter
private static final UUID serverUUID = UUID.randomUUID(); private static final UUID serverUUID = UUID.randomUUID();

View File

@ -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> 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);
// }
}

View File

@ -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);
}
}

View File

@ -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<String> 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<String> 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<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> 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<String> matches, CommandSender sender, int arg, String[] args, HashMap<String, String> permMap) {
// tab(matches, sender, arg, args, permMap, null, null);
// }
//
// public static void tab(List<String> matches, CommandSender sender, int argEquals, String equalsValue, int arg, String[] args, HashMap<String, String> 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<String> tab(CommandSender sender, int arg, String[] args, String perm, String command) {
// List<String> 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;
// }
}

View File

@ -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=======");
}
}

View File

@ -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<String> replace(String prefix, List<String> Text) {
List<String> 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<String> 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;
}
}

View File

@ -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<PluginContainer> plugin, String msg) {
debug(plugin, msg, null);
}
public static void debug(Optional<PluginContainer> 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);
}
}

View File

@ -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());
}
}

View File

@ -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();
}
}
}

View File

@ -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);
}
}
}

View File

@ -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());
}
}
}

View File

@ -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();
}
}
}

View File

@ -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<Optional<String>, T2CVupdateObject> bungeePluginVersins = new HashMap<>();
public static ProxyServer server = T2CodeVMain.server;
public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Optional<PluginContainer> 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 = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
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<PluginContainer> 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);
}
}

View File

@ -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<PluginContainer> plugin;
private int resourceId;
public static ProxyServer server = T2CodeVMain.server;
public static Logger logger = T2CodeVMain.logger;
public T2CVupdateCheckerGit(Optional<PluginContainer> plugin, int resourceId) {
this.plugin = plugin;
this.resourceId = resourceId;
}
public void getVersion(Consumer<T2CupdateWebData> 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", "<br>").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());
}
}
}

View File

@ -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<String> selectList(String path) {
List<String> 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<String> selectList(String prefix, String path) {
List<String> 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<String> value, String path) {
configNode.getNode((Object[]) path.split("\\.")).setValue(value);
}
}

View File

@ -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<PluginContainer> 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=============================");
}
}

View File

@ -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> 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());
}
}

View File

@ -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 <a href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
* <p>Not to be confused with Velocity's {@link PluginDescription#getId()} method!
* @return A Metrics instance that can be used to register custom charts.
* <p>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"));
}
}

View File

@ -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;
//
}

View File

@ -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.");
}
}

View File

@ -1,5 +1,18 @@
name: T2CodeLib name: T2CodeLib
version: ${project.version} version: ${project.version}
main: net.t2code.t2codelib.BUNGEE.system.T2CodeBMain main: net.t2code.t2codelib.bungee.system.T2CodeBMain
author: JaTiTV, Jkobs author: JaTiTV, Jkobs
description: Library from T2Code Plugins description: Library from T2Code Plugins
_______ ___ _____ _ _
|__ __|__ \ / ____| | | | |
| | ) | | ___ __| | ___ _ __ ___| |_
| | / /| | / _ \ / _` |/ _ \ | '_ \ / _ \ __|
| | / /_| |___| (_) | (_| | __/_| | | | __/ |_
|_| |____|\_____\___/ \__,_|\___(_)_| |_|\___|\__|

View File

@ -1,6 +1,6 @@
name: T2CodeLib name: T2CodeLib
version: '${project.version}' version: '${project.version}'
main: net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain main: net.t2code.t2codelib.spigot.system.T2CodeLibMain
api-version: 1.13 api-version: 1.13
prefix: T2CodeLib prefix: T2CodeLib
authors: [ JaTiTV ] authors: [ JaTiTV ]

View File

@ -0,0 +1 @@
{"id":"t2codelib","name":"T2CodeLib","version":"${project.version}","authors":["JaTiTV"],"dependencies":[],"main":"net.t2code.t2codelib.VELOCITY.system.T2CodeVMain"}