13.4_SNAPSHOT-1

This commit is contained in:
JaTiTV 2022-11-14 18:45:54 +01:00
parent f70767b361
commit f9b0b512b9
18 changed files with 222 additions and 103 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>13.4_DEV-3</version> <version>13.4_SNAPSHOT-1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2CodeLib</name> <name>T2CodeLib</name>
@ -158,6 +158,12 @@
<version>4.1.2</version> <version>4.1.2</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.1.2</version>
<scope>compile</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>

View File

@ -0,0 +1,30 @@
package net.t2code.t2codelib.BUNGEE.api.messages;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
public class T2CBminiMessage {
private static final BungeeAudiences bungeeAudiences = T2CodeBMain.getAdventure();
public static void sendSenderMiniMessage(String msg, CommandSender sender) {
bungeeAudiences.sender(sender).sendMessage(replace(msg));
}
public static void sendConsoleMiniMessage(String msg) {
bungeeAudiences.console().sendMessage(replace(msg));
}
public static void sendPlayerMiniMessage(String msg, ProxiedPlayer player) {
bungeeAudiences.player(player).sendMessage(replace(msg));
}
protected static Component replace(String text) {
return MiniMessage.miniMessage().deserialize(T2Creplace.convertColorCode(text));
}
}

View File

@ -5,16 +5,21 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.Title; import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain;
import java.util.logging.Level; import java.util.logging.Level;
public class T2CBsend { public class T2CBsend {
public static void console(String msg) { public static void console(String msg) {
ProxyServer.getInstance().getConsole().sendMessage(msg); if (T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendConsoleMiniMessage(msg);
} else ProxyServer.getInstance().getConsole().sendMessage(msg);
} }
public static void player(ProxiedPlayer player, String msg) { public static void player(ProxiedPlayer player, String msg) {
player.sendMessage(msg); if (T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendPlayerMiniMessage(msg, player);
} else player.sendMessage(msg);
} }
public static void title(ProxiedPlayer player, Title msg) { public static void title(ProxiedPlayer player, Title msg) {
@ -22,7 +27,9 @@ public class T2CBsend {
} }
public static void sender(CommandSender sender, String msg) { public static void sender(CommandSender sender, String msg) {
sender.sendMessage(msg); if (T2CodeBMain.getMmIsLoad()) {
T2CBminiMessage.sendSenderMiniMessage(msg, sender);
} else sender.sendMessage(msg);
} }
public static void debug(Plugin plugin, String msg) { public static void debug(Plugin plugin, String msg) {
@ -31,15 +38,15 @@ public class T2CBsend {
public static void debug(Plugin plugin, String msg, Integer stage) { public static void debug(Plugin plugin, String msg, Integer stage) {
// if (!new File(Main.getPath(), "config.yml").exists()) return; // if (!new File(Main.getPath(), "config.yml").exists()) return;
if (stage == null) { // if (stage == null) {
//todo if (plugin.getConfig().getBoolean("Plugin.Debug")){ // if (plugin.getConfig().getBoolean("Plugin.Debug")) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg); // ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// } // }
return; // return;
} //}
// todo if (plugin.getConfig().getInt("Plugin.Debug") >= stage) { //if (plugin.getConfig().getInt("Plugin.Debug") >= stage) {
// ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg); // ProxyServer.getInstance().getConsole().sendMessage(plugin.getDescription().getName() + " §5DEBUG: §6" + msg);
// } //}
} }
public static void debugmsg(Plugin plugin, String msg) { public static void debugmsg(Plugin plugin, String msg) {

View File

@ -3,6 +3,7 @@ package net.t2code.t2codelib.BUNGEE.api.messages;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI; import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI;
import net.t2code.t2codelib.T2CupdateWebData;
public class T2CBtemplate { public class T2CBtemplate {
@ -39,14 +40,14 @@ public class T2CBtemplate {
} }
public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) { public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) {
String publicVersion = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData.getVersion(); T2CupdateWebData webData = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).webData;
String pluginVersion = plugin.getDescription().getVersion(); String pluginVersion = plugin.getDescription().getVersion();
T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4======="); T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4=======");
T2CBsend.sender(sender, prefix + " §2Autor: §6" + autor); T2CBsend.sender(sender, prefix + " §2Autor: §6" + autor);
if (publicVersion.equalsIgnoreCase(pluginVersion)) { if (webData.getVersion().equalsIgnoreCase(pluginVersion)) {
T2CBsend.sender(sender, prefix + " §2Version: §6" + pluginVersion); T2CBsend.sender(sender, prefix + " §2Version: §6" + pluginVersion);
} else { } else {
T2CBupdateAPI.sendUpdateMsg(prefix, spigot, discord, pluginVersion, publicVersion, sender); T2CBupdateAPI.sendUpdateMsg(prefix, discord, webData, plugin, sender);
} }
T2CBsend.sender(sender, prefix + " §2Spigot: §6" + spigot); T2CBsend.sender(sender, prefix + " §2Spigot: §6" + spigot);
T2CBsend.sender(sender, prefix + " §2Discord: §6" + discord); T2CBsend.sender(sender, prefix + " §2Discord: §6" + discord);

View File

@ -5,10 +5,14 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
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;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
@ -22,52 +26,63 @@ import java.util.function.Consumer;
public class T2CBupdateAPI { public class T2CBupdateAPI {
public static HashMap<String, T2CupdateObject> bungeePluginVersins = new HashMap<>(); public static HashMap<String, T2CupdateObject> bungeePluginVersins = new HashMap<>();
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version) { public static void sendUpdateMsg(String prefix, String discord, T2CupdateWebData webData, Plugin plugin, CommandSender sender) {
T2CBsend.console("§4=========== " + Prefix + " §4==========="); String publicVersion = webData.getVersion();
T2CBsend.console("§6A new version was found!"); String pluginVersion = plugin.getDescription().getVersion();
T2CBsend.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version); String value;
T2CBsend.console("§6You can download it here: §e" + Spigot); if (webData.isPreRelease()) {
T2CBsend.console("§6You can find more information on Discord: §e" + Discord); value = UpdateType.PRERELEASE.text;
T2CBsend.console("§4=========== " + Prefix + " §4==========="); 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) {
T2CBsend.console(text);
} else T2CBsend.sender(sender, text);
public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version, CommandSender sender) {
T2CBsend.sender(sender, "§4=========== " + Prefix + " §4===========");
T2CBsend.sender(sender, "§6A new version was found!");
T2CBsend.sender(sender, "§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
T2CBsend.sender(sender, "§6You can download it here: §e" + Spigot);
T2CBsend.sender(sender, "§6You can find more information on Discord: §e" + Discord);
T2CBsend.sender(sender, "§4=========== " + Prefix + " §4===========");
} }
private static Boolean noUpdate = true; private static Boolean noUpdate = true;
private static String pluginVersion; private static String pluginVersion;
public static void onUpdateCheckTimer(Plugin plugin, String Prefix, String Spigot, String Discord, Integer SpigotID, String url) { public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() { ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
public void run() { public void run() {
(new T2CBupdateAPI(plugin, SpigotID)).getVersion((update_version) -> { (new T2CBupdateAPI(plugin, spigotID)).getVersion((webData) -> {
pluginVersion = plugin.getDescription().getVersion(); pluginVersion = plugin.getDescription().getVersion();
T2CupdateObject update = new T2CupdateObject( T2CupdateObject update = new T2CupdateObject(
plugin.getDescription().getName(), plugin.getDescription().getName(),
plugin.getDescription().getVersion(), plugin.getDescription().getVersion(),
update_version, webData,
false, false,
!plugin.getDescription().getVersion().equals(update_version.getVersion()) !plugin.getDescription().getVersion().equals(webData.getVersion())
); );
bungeePluginVersins.put(plugin.getDescription().getName(), update); bungeePluginVersins.put(plugin.getDescription().getName(), update);
if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(update_version.getVersion())) { if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(webData.getVersion())) {
sendUpdateMsg(Prefix, Spigot, Discord, pluginVersion, update_version.getVersion()); sendUpdateMsg(prefix, discord, webData, plugin, null);
noUpdate = true; noUpdate = true;
} else { } else {
if (noUpdate) { if (noUpdate) {
T2CBsend.console(Prefix + " §2No update found."); T2CBsend.console(prefix + " §2No update found.");
noUpdate = false; noUpdate = false;
} }
} }
}, pluginVersion, SpigotID, url); }, pluginVersion, spigotID, url);
} }
}, 0, 20 * 60 * 60L, TimeUnit.SECONDS); }, 0, T2CBlibConfig.getUpdateTimer() * 60 * 20L, TimeUnit.SECONDS);
} }
private Plugin plugin; private Plugin plugin;

View File

@ -33,7 +33,7 @@ public class T2CBload {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, spigot, discord, spigotID,url); T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID,url);
//API //API
plugin.getProxy().registerChannel("t2c:bcmd"); plugin.getProxy().registerChannel("t2c:bcmd");
@ -48,7 +48,7 @@ public class T2CBload {
plugin.getProxy().registerChannel("t2c:aresp"); plugin.getProxy().registerChannel("t2c:aresp");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse()); plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse());
} }
if (T2CBlibConfig.getApiAutoResponse()) { if (T2CBlibConfig.getApiOpSecurity()) {
plugin.getProxy().registerChannel("t2c:t2c:opsec"); plugin.getProxy().registerChannel("t2c:t2c:opsec");
plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity()); plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity());
} }

View File

@ -1,5 +1,7 @@
package net.t2code.t2codelib.BUNGEE.system; package net.t2code.t2codelib.BUNGEE.system;
import lombok.NonNull;
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;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
@ -16,6 +18,16 @@ public class T2CodeBMain extends Plugin {
private static String orgVersion; private static String orgVersion;
private static String autor; private static String autor;
private static Boolean mmIsLoad = true;
private static BungeeAudiences adventure;
public static BungeeAudiences getAdventure() {
if(adventure == null) {
throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled");
}
return adventure;
}
@Override @Override
public void onEnable() { public void onEnable() {
@ -23,6 +35,11 @@ public class T2CodeBMain extends Plugin {
plugin = this; plugin = this;
orgVersion = plugin.getDescription().getVersion(); orgVersion = plugin.getDescription().getVersion();
autor = plugin.getDescription().getAuthor(); autor = plugin.getDescription().getAuthor();
try {
adventure = BungeeAudiences.create(this);
} catch (Exception e){
mmIsLoad = false;
}
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit()); T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
String[] fv = orgVersion.split("_"); String[] fv = orgVersion.split("_");
plugin.getDescription().setVersion(fv[0]); plugin.getDescription().setVersion(fv[0]);
@ -32,6 +49,12 @@ public class T2CodeBMain extends Plugin {
@Override @Override
public void onDisable() { public void onDisable() {
// Plugin shutdown logic // Plugin shutdown logic
if (mmIsLoad){
if(adventure != null) {
adventure.close();
adventure = null;
}
}
T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4============================="); T2CBsend.console(Util.getPrefix() + "§4============================= " + Util.getPrefix() + " §4=============================");
T2CBsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", "")); T2CBsend.console(Util.getPrefix() + " §2Autor: §6" + String.valueOf(plugin.getDescription().getAuthor()).replace("[", "").replace("]", ""));
T2CBsend.console(Util.getPrefix() + " §2Version: §6" + version); T2CBsend.console(Util.getPrefix() + " §2Version: §6" + version);
@ -40,4 +63,7 @@ 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

@ -21,6 +21,8 @@ public class T2CBlibConfig {
config.createNewFile(); config.createNewFile();
} }
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config); Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
T2CBconfig.set("UpdateCheck.TimerInMin", 60, configuration);
T2CBconfig.set("API.CommandGUI.Enable", false, configuration); T2CBconfig.set("API.CommandGUI.Enable", false, configuration);
T2CBconfig.set("API.AutoResponse.Enable", false, configuration); T2CBconfig.set("API.AutoResponse.Enable", false, configuration);
T2CBconfig.set("API.OPSecurity.Enable", false, configuration); T2CBconfig.set("API.OPSecurity.Enable", false, configuration);
@ -33,15 +35,22 @@ public class T2CBlibConfig {
File config = new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml"); File config = new File(T2CodeBMain.getPlugin().getDataFolder(), "config.yml");
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config); Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config);
updateTimer = configuration.getInt("UpdateCheck.TimerInMin");
apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable"); apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable");
apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable"); apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable");
apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable"); apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable");
} }
private static Integer updateTimer;
private static Boolean apiCommandGUIEnable; private static Boolean apiCommandGUIEnable;
private static Boolean apiAutoResponse; private static Boolean apiAutoResponse;
private static Boolean apiOpSecurity; private static Boolean apiOpSecurity;
public static Integer getUpdateTimer() {
return updateTimer;
}
public static Boolean getApiCommandGUIEnable() { public static Boolean getApiCommandGUIEnable() {
return apiCommandGUIEnable; return apiCommandGUIEnable;
} }

View File

@ -18,16 +18,16 @@ public class T2ChoverModule {
t2cmodule(msg, player); t2cmodule(msg, player);
return; return;
} }
T2CminiMessage.miniMessage(msg, player); T2CminiMessage.sendPlayerMiniMessage(msg, player);
} }
public static void moduleSender(String msg, CommandSender sender) { public static void moduleSender(String msg, CommandSender sender) {
T2CminiMessage.miniMessage(msg, sender); T2CminiMessage.sendSenderMiniMessage(msg, sender);
} }
public static void moduleConsole(String msg) { public static void moduleConsole(String msg) {
if (T2CodeLibMain.getNmIsLoad()) { if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendMiniMessage(msg); T2CminiMessage.sendConsoleMiniMessage(msg);
return; return;
} }
Bukkit.getConsoleSender().sendMessage(msg); Bukkit.getConsoleSender().sendMessage(msg);

View File

@ -10,15 +10,15 @@ import org.bukkit.entity.Player;
public class T2CminiMessage { public class T2CminiMessage {
private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure(); private static final BukkitAudiences bukkitAudiences = T2CodeLibMain.getPlugin().getAdventure();
public static void miniMessage(String msg, CommandSender sender) { public static void sendSenderMiniMessage(String msg, CommandSender sender) {
bukkitAudiences.sender(sender).sendMessage(replace(msg)); bukkitAudiences.sender(sender).sendMessage(replace(msg));
} }
public static void sendMiniMessage(String msg) { public static void sendConsoleMiniMessage(String msg) {
bukkitAudiences.console().sendMessage(replace(msg)); bukkitAudiences.console().sendMessage(replace(msg));
} }
public static void miniMessage(String msg, Player player) { public static void sendPlayerMiniMessage(String msg, Player player) {
bukkitAudiences.player(player).sendMessage(replace(msg)); bukkitAudiences.player(player).sendMessage(replace(msg));
} }

View File

@ -1,6 +1,7 @@
package net.t2code.t2codelib.SPIGOT.api.messages; 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 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;
@ -24,31 +25,33 @@ 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 + " <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 §2Autor: §6" + String.valueOf(autor).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);
if (isPremium != null) { if (isPremium != null) {
if (isPremium) { if (isPremium) {
T2Csend.console(prefix + " §4 §e| §6Premium: §2true"); T2Csend.console(prefix + " §4 §e §6Premium: §2true");
} else T2Csend.console(prefix + " §4 §e| §6Premium: §4false"); } else T2Csend.console(prefix + " §4 §e §6Premium: §4false");
if (isVerify != null) { if (isVerify != null) {
if (isVerify) { if (isVerify) {
T2Csend.console(prefix + " §4 §e| §6Verify: §2true"); T2Csend.console(prefix + " §4 §e §6Verify: §2true");
} else T2Csend.console(prefix + " §4 §e| §6Verify: §4false"); } else T2Csend.console(prefix + " §4 §e §6Verify: §4false");
} else T2Csend.console(prefix + " §4 §e| §6Verify: §4false"); } else T2Csend.console(prefix + " §4 §e §6Verify: §4false");
} }
T2Csend.console(prefix + " §4 §e-------------------"); T2Csend.console(prefix + " §4 §e╚══════════════════════════");
if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) { if (version.toLowerCase().contains("dev") || version.toLowerCase().contains("snapshot") || version.toLowerCase().contains("beta")) {
T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" + T2Csend.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! Some features may not be working as expected. Please report all" +
" bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!"); " bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
T2Csend.console(prefix + " §4 §e-------------------"); onLoadSeparateStroke(prefix);
try { if (!SelectLibConfig.getT2cTestDevelopment()){
Thread.sleep(5000); try {
} catch (InterruptedException e) { Thread.sleep(5000);
e.printStackTrace(); } catch (InterruptedException e) {
e.printStackTrace();
}
} }
} }

View File

@ -2,11 +2,10 @@ package net.t2code.t2codelib.SPIGOT.api.update;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.SPIGOT.system.UpdateType; import net.t2code.t2codelib.UpdateType;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject; import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData; import net.t2code.t2codelib.T2CupdateWebData;
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.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -94,16 +93,17 @@ public class T2CupdateAPI {
value = UpdateType.SNAPSHOT.text; value = UpdateType.SNAPSHOT.text;
} }
} else value = UpdateType.STABLE.text; } else value = UpdateType.STABLE.text;
String h = "§4=========== " + prefix + " §4==========="; String h = "<br><dark_red>╔══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String s1 = "§6A new [value] version was found!§r".replace("[value]", value); String s1 = "<br><dark_red>║</dark_red> <gold>A new [value] version was found!</gold>".replace("[value]", value);
String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + webData.getVersion(); String s2 = "<br><dark_red>║</dark_red> <gold>Your version: <red>" + pluginVersion + "</red> <gray>-</gray> Current version:</gold> <green>" + webData.getVersion() + "</green>";
String s3 = "§6You can download it here: §e" + webData.getUpdateUrl(); String s3 = "<br><dark_red>║</dark_red> <gold>You can download it here:</gold> <yellow>" + webData.getUpdateUrl() + "</yellow>";
String s4 = "§6You can find more information on Discord: §e" + discord; String s4 = "<br><dark_red>║</dark_red> <gold>You can find more information on Discord:</gold> <yellow>" + discord + "</yellow>";
String text = "<br>" + h + "<br>" + s1 + "<br>" + s2 + "<br>" + s3 + "<br>" + s4 + "<br>" + h; String f = "<br><dark_red>╚══════════════</dark_red>" + prefix + "<dark_red>══════════════</dark_red>";
String text = h + s1 + s2 + s3 + s4 + f;
T2Csend.console(text); T2Csend.console(text);
} }
public static String updateInfo(CommandSender sender, String[] args, Boolean player) { public static String updateInfo(String[] args, Boolean player) {
T2CupdateObject object; T2CupdateObject object;
try { try {
object = T2CupdateAPI.pluginVersions.get(args[1]); object = T2CupdateAPI.pluginVersions.get(args[1]);
@ -140,12 +140,11 @@ public class T2CupdateAPI {
String updateInfoString = "<br><dark_red>║</dark_red> <color:#308aff>[value]:</color>"; String updateInfoString = "<br><dark_red>║</dark_red> <color:#308aff>[value]:</color>";
String updateTitleString = "<br><dark_red>║</dark_red> <yellow>Title:</yellow> <color:#5eff89>" + updateTitle + "</color>"; String updateTitleString = "<br><dark_red>║</dark_red> <yellow>Title:</yellow> <color:#5eff89>" + updateTitle + "</color>";
String updateVersionString = "<br><dark_red>║</dark_red> <yellow>Version:</yellow> <color:#5eff89>" + updateVersion + "</color>"; String updateVersionString = "<br><dark_red>║</dark_red> <yellow>Version:</yellow> <color:#5eff89>" + updateVersion + "</color>";
String updateAtString = "<br><dark_red>║</dark_red> <yellow>Update at:</yellow> <color:#5eff89>" + updateAt + "</color>"; String updateAtString = "<br><dark_red>║</dark_red> <yellow>Published on:</yellow> <color:#5eff89>" + updateAt + "</color>";
String updateTypeString = "<br><dark_red>║</dark_red> <yellow>Update type:</yellow> <color:#5eff89>" + updateType + "</color>"; String updateTypeString = "<br><dark_red>║</dark_red> <yellow>Version type:</yellow> <color:#5eff89>" + updateType + "</color>";
String updateButton; String updateButton;
if (player) { if (player) {
// updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate +"'>Download</click></hover></color>";
updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate + "'>Download</click></hover></color> <dark_gray>|</dark_gray> <blue><hover:show_text:'" + updateDescription + "'>Update Description</hover></blue>"; updateButton = "<br><dark_red>║</dark_red> <color:#5eff89><hover:show_text:'<gold>" + updateUpdate + "</gold>'><click:open_url:'" + updateUpdate + "'>Download</click></hover></color> <dark_gray>|</dark_gray> <blue><hover:show_text:'" + updateDescription + "'>Update Description</hover></blue>";
} else updateButton = "<br><dark_red>║</dark_red> <color:#5eff89>Download:</color> <gold>" + updateUpdate + "</gold>"; } else updateButton = "<br><dark_red>║</dark_red> <color:#5eff89>Download:</color> <gold>" + updateUpdate + "</gold>";
@ -170,7 +169,6 @@ public class T2CupdateAPI {
return text; return text;
} }
public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) { public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -184,7 +182,7 @@ public class T2CupdateAPI {
false, !plugin.getDescription().getVersion().equals(update_version) false, !plugin.getDescription().getVersion().equals(update_version)
); );
pluginVersions.put(plugin.getName(), update); pluginVersions.put(plugin.getName(), update);
if (!pluginVersions.get(plugin.getName()).updateAvailable) { if (pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) { if (!update.load) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -222,7 +220,7 @@ public class T2CupdateAPI {
!plugin.getDescription().getVersion().equals(webData.getVersion()) !plugin.getDescription().getVersion().equals(webData.getVersion())
); );
pluginVersions.put(plugin.getName(), update); pluginVersions.put(plugin.getName(), update);
if (!pluginVersions.get(plugin.getName()).updateAvailable) { if (pluginVersions.get(plugin.getName()).updateAvailable) {
if (!update.load) { if (!update.load) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override

View File

@ -18,6 +18,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate;
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -32,7 +33,7 @@ public final class T2CodeLibMain extends JavaPlugin {
private static List<String> autor; private static List<String> autor;
private static String version; private static String version;
private static Boolean nmIsLoad = true; private static Boolean mmIsLoad = true;
private static Boolean load = false; private static Boolean load = false;
@Override @Override
@ -41,7 +42,11 @@ public final class T2CodeLibMain extends JavaPlugin {
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
adventure = BukkitAudiences.create(this); try {
adventure = BukkitAudiences.create(this);
} catch (Exception e) {
mmIsLoad = false;
}
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
String prefix = Util.getPrefix(); String prefix = Util.getPrefix();
@ -58,10 +63,12 @@ public final class T2CodeLibMain extends JavaPlugin {
T2Csend.warning(plugin, "The 1.20.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); T2Csend.warning(plugin, "The 1.20.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net");
T2Csend.console(prefix); T2Csend.console(prefix);
T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!");
try { if (!SelectLibConfig.getT2cTestDevelopment()) {
Thread.sleep(5000); try {
} catch (InterruptedException e) { Thread.sleep(5000);
e.printStackTrace(); } catch (InterruptedException e) {
e.printStackTrace();
}
} }
} }
T2Csend.console(prefix + " §3Server run on: §6" + T2CmcVersion.getMcVersion() + " / " + T2CmcVersion.getNms()); T2Csend.console(prefix + " §3Server run on: §6" + T2CmcVersion.getMcVersion() + " / " + T2CmcVersion.getNms());
@ -100,6 +107,7 @@ public final class T2CodeLibMain extends JavaPlugin {
ReportLogStorage.load(); ReportLogStorage.load();
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
checkIsBungee();
T2Ctemplate.onLoadFooter(prefix, long_); T2Ctemplate.onLoadFooter(prefix, long_);
load = true; load = true;
} }
@ -117,7 +125,7 @@ public final class T2CodeLibMain extends JavaPlugin {
Vault.vaultDisable(); Vault.vaultDisable();
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
if (nmIsLoad) { if (mmIsLoad) {
if (this.adventure != null) { if (this.adventure != null) {
this.adventure.close(); this.adventure.close();
this.adventure = null; this.adventure = null;
@ -167,7 +175,20 @@ public final class T2CodeLibMain extends JavaPlugin {
return adventure; return adventure;
} }
public static Boolean getNmIsLoad() { private static void checkIsBungee() {
return nmIsLoad; File config = new File("spigot.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
isBungee = yamlConfiguration.getBoolean("settings.bungeecord");
}
private static Boolean isBungee;
public static Boolean getIsBungee() {
return isBungee;
}
public static Boolean getMmIsLoad() {
return mmIsLoad;
} }
} }

View File

@ -52,6 +52,6 @@ public class Commands {
} }
public static void updateInfo(CommandSender sender, String[] args) { public static void updateInfo(CommandSender sender, String[] args) {
T2Csend.sender(sender, T2CupdateAPI.updateInfo(sender, args, sender instanceof Player)); T2Csend.sender(sender, T2CupdateAPI.updateInfo(args, sender instanceof Player));
} }
} }

View File

@ -17,10 +17,12 @@ 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;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
@ -45,13 +47,15 @@ public class CreateReportLog {
try { try {
pWriter = new PrintWriter(new FileWriter(file.getPath())); pWriter = new PrintWriter(new FileWriter(file.getPath()));
String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime()); String timeStamp = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy").format(Calendar.getInstance().getTime());
pWriter.println("Created on: " + timeStamp); pWriter.println("Created on: " + timeStamp + " - from: " + sender.getName());
pWriter.println(); pWriter.println();
pWriter.println("Server Bukkit version: " + T2CmcVersion.getBukkitVersion()); pWriter.println("Server Bukkit version: " + T2CmcVersion.getBukkitVersion());
pWriter.println("Server run on: " + T2CmcVersion.getMcVersion()); pWriter.println("Server run on: " + T2CmcVersion.getMcVersion());
pWriter.println("Server NMS: " + T2CmcVersion.getNms()); pWriter.println("Server NMS: " + T2CmcVersion.getNms());
pWriter.println();
pWriter.println("Online Mode: " + Bukkit.getOnlineMode()); pWriter.println("Online Mode: " + Bukkit.getOnlineMode());
pWriter.println("Bungee Mode: " + T2CodeLibMain.getIsBungee());
pWriter.println("Server Port: " + Bukkit.getServer().getPort());
pWriter.println();
pWriter.println("Worlds: " + Bukkit.getWorlds()); pWriter.println("Worlds: " + Bukkit.getWorlds());
pWriter.println("OP-Player:"); pWriter.println("OP-Player:");
for (OfflinePlayer player : Bukkit.getOperators()) { for (OfflinePlayer player : Bukkit.getOperators()) {
@ -92,7 +96,6 @@ public class CreateReportLog {
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV()); pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
pWriter.println(); pWriter.println();
} }
pWriter.println();
pWriter.println("OfflinePlayers: "); pWriter.println("OfflinePlayers: ");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) { for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
pWriter.println(" - " + player.getName() + " - " + player.getUniqueId()); pWriter.println(" - " + player.getName() + " - " + player.getUniqueId());
@ -102,7 +105,7 @@ public class CreateReportLog {
pWriter.println("Plugins: "); pWriter.println("Plugins: ");
for (Plugin pl : Bukkit.getPluginManager().getPlugins()) { for (Plugin pl : Bukkit.getPluginManager().getPlugins()) {
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: " pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: "
+ pl.getDescription().getAuthors()+" - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend() + pl.getDescription().getAuthors() + " - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend()
+ " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite()); + " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite());
} }
} catch (IOException ioe) { } catch (IOException ioe) {
@ -154,11 +157,11 @@ public class CreateReportLog {
"<gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>. Please enter the following key " + "<gold><hover:show_text:'<yellow>Download the debug file</yellow>'>here</hover></gold></click>. Please enter the following key " +
"in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" + "in the ticket: <gold><click:copy_to_clipboard:[key]><hover:show_text:'<yellow>Copy to clipboard</yellow>'>[key]</hover></click></gold></green>" +
"<br><dark_red>Do not share the download URL with anyone!</dark_red><br><click:run_command:'/t2code debug deleteReportLog [key]'>" + "<br><dark_red>Do not share the download URL with anyone!</dark_red><br><click:run_command:'/t2code debug deleteReportLog [key]'>" +
"<green>You can <b>delte </b>yor Debug-File by clicking me.</green></click>").replace("[key]",fileID).replace("[url]",downloadURL)); "<green>You can <b>delte </b>yor Debug-File by clicking me.</green></click>").replace("[key]", fileID).replace("[url]", downloadURL));
} }
T2Csend.console(Util.getPrefix() + (" §6A DebugLog zip has been created. You can download it here: [url].\n§6Please enter the following key in the ticket:" + T2Csend.console(Util.getPrefix() + (" §6A DebugLog zip has been created. You can download it here: [url].\n§6Please enter the following key in the ticket:" +
" §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog [key].") " §e[key].\n§4Do not share the download URL with anyone!\nYou can delte yor Debug-File with the following command: /t2code debug deleteReportLog [key].")
.replace("[key]",fileID).replace("[url]",downloadURL)); .replace("[key]", fileID).replace("[url]", downloadURL));
ReportLogStorage.add(fileID); ReportLogStorage.add(fileID);
} }
@ -231,11 +234,11 @@ public class CreateReportLog {
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
int response = con.getResponseCode(); int response = con.getResponseCode();
if(response == 200){ if (response == 200) {
ReportLogStorage.remove(arg); ReportLogStorage.remove(arg);
T2Csend.sender(sender,"<green>Deleted report: <yellow>" + arg); T2Csend.sender(sender, "<green>Deleted report: <yellow>" + arg);
}else { } else {
T2Csend.sender(sender,"<green>Error while deleting report: <yellow>" + arg); T2Csend.sender(sender, "<green>Error while deleting report: <yellow>" + arg);
} }
con.disconnect(); con.disconnect();
} }

View File

@ -8,7 +8,7 @@ import java.io.File;
public class SelectLibConfig { public class SelectLibConfig {
private static Boolean UpdateCheckOnJoin; private static Boolean UpdateCheckOnJoin;
private static Boolean t2cTestDevelopment; private static Boolean t2cTestDevelopment = false;
private static Integer UpdateCheckTimeInterval; private static Integer UpdateCheckTimeInterval;
private static Boolean Debug; private static Boolean Debug;
private static String language; private static String language;

View File

@ -1,4 +1,4 @@
package net.t2code.t2codelib.SPIGOT.system; package net.t2code.t2codelib;
public enum UpdateType { public enum UpdateType {
PRERELEASE("<light_purple>Pre-Release</light_purple>"), PRERELEASE("<light_purple>Pre-Release</light_purple>"),

View File

@ -35,7 +35,7 @@ public class Util {
public static List<String> getT2cPlugins() { public static List<String> getT2cPlugins() {
return Arrays.asList( return Arrays.asList(
//"T2CodeLib", "T2CodeLib",
"T2C-LuckyBox", "T2C-LuckyBox",
"WonderBagShop", "WonderBagShop",
"CommandGUI", "CommandGUI",