diff --git a/pom.xml b/pom.xml index 1b902b8..864dc44 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.t2code T2CodeLib - 13.0-DEVELOPMENT + 13.1 jar T2CodeLib @@ -86,8 +86,15 @@ BenCodez Repo https://nexus.bencodez.com/repository/maven-public/ + + + + sonatype-oss-snapshots1 + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + @@ -138,7 +145,7 @@ net.kyori adventure-platform-bukkit - 4.1.1 + 4.1.3-SNAPSHOT diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/messages/T2CBtemplate.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/messages/T2CBtemplate.java index 5293fad..a599df1 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/messages/T2CBtemplate.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/messages/T2CBtemplate.java @@ -1,6 +1,7 @@ package net.t2code.t2codelib.BUNGEE.api.messages; import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.plugin.Plugin; import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI; public class T2CBtemplate { @@ -37,7 +38,9 @@ public class T2CBtemplate { T2CBsend.console(prefix + "§4============================= " + prefix + " §4============================="); } - public static void sendInfo(CommandSender sender, String prefix, String spigot, String discord, String autor, String pluginVersion, String publicVersion) { + public static void sendInfo(CommandSender sender, Plugin plugin, String prefix, String spigot, String discord, String autor) { + String publicVersion = T2CBupdateAPI.bungeePluginVersins.get(plugin.getDescription().getName()).publicVersion; + String pluginVersion = plugin.getDescription().getVersion(); T2CBsend.sender(sender, prefix + "§4======= " + prefix + " §4======="); T2CBsend.sender(sender, prefix + " §2Autor: §6" + autor); if (publicVersion.equalsIgnoreCase(pluginVersion)) { diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/api/update/T2CBupdateAPI.java b/src/main/java/net/t2code/t2codelib/BUNGEE/api/update/T2CBupdateAPI.java index de481fc..fccb1d8 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/api/update/T2CBupdateAPI.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/api/update/T2CBupdateAPI.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; public class T2CBupdateAPI { - public static HashMap bungeePluginVersionen = new HashMap(); + public static HashMap bungeePluginVersins = new HashMap(); public static void sendUpdateMsg(String Prefix, String Spigot, String Discord, String foundVersion, String update_version) { T2CBsend.console("§4=========== " + Prefix + " §4==========="); @@ -44,7 +44,7 @@ public class T2CBupdateAPI { pluginVersion, update_version ); - bungeePluginVersionen.put(plugin.getDescription().getName(), update); + bungeePluginVersins.put(plugin.getDescription().getName(), update); if (!pluginVersion.replace("_Bungee", "").equalsIgnoreCase(update_version)) { sendUpdateMsg(Prefix, Spigot, Discord, pluginVersion, update_version); noUpdate = true; @@ -105,7 +105,7 @@ public class T2CBupdateAPI { pluginVersion, "§4No public version found!" ); - bungeePluginVersionen.put(plugin.getDescription().getName(), update); + bungeePluginVersins.put(plugin.getDescription().getName(), update); this.plugin.getLogger().severe(Prefix + "§4 Cannot look for updates: " + var10.getMessage()); } }); diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java index 96b34c2..d3c8a7e 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/T2CBload.java @@ -5,10 +5,15 @@ import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; import net.t2code.t2codelib.BUNGEE.api.update.T2CBupdateAPI; import net.t2code.t2codelib.BUNGEE.system.bstats.T2CBmetrics; import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig; -import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUIEvent; +import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.T2CplmsgBcmd; +import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse.T2CapiAutoResponse; +import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui.T2CapiCGUI; +import net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity.T2CapiOpSecurity; + +import java.io.IOException; public class T2CBload { - public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID,Integer bstatsID){ + public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID) { long long_ = System.currentTimeMillis(); T2CBsend.console(prefix + "§4============================= " + prefix + " §4============================="); T2CBsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", "")); @@ -17,14 +22,35 @@ public class T2CBload { T2CBsend.console(prefix + " §2Discord: §6" + discord); T2CBmetrics.Bstats(plugin, bstatsID); + try { + T2CBlibConfig.create(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + T2CBlibConfig.select(); + } catch (IOException e) { + throw new RuntimeException(e); + } T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, spigot, discord, spigotID); - //API - if (T2CBlibConfig.getApiCommandGUIEnable()){ - plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUIEvent()); - T2CapiCGUIEvent.sendToSpigotDeleteAll(); + plugin.getProxy().registerChannel("t2c:bcmd"); + plugin.getProxy().getPluginManager().registerListener(plugin, new T2CplmsgBcmd()); + + if (T2CBlibConfig.getApiCommandGUIEnable()) { + plugin.getProxy().registerChannel("t2c:cgui"); + plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiCGUI()); + T2CapiCGUI.sendToSpigotDeleteAll(); + } + if (T2CBlibConfig.getApiAutoResponse()) { + plugin.getProxy().registerChannel("t2c:aresp"); + plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiAutoResponse()); + } + if (T2CBlibConfig.getApiAutoResponse()) { + plugin.getProxy().registerChannel("t2c:t2c:opsec"); + plugin.getProxy().getPluginManager().registerListener(plugin, new T2CapiOpSecurity()); } diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java index 5b73d38..c5f2bbe 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/config/T2CBlibConfig.java @@ -4,6 +4,7 @@ import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.ConfigurationProvider; import net.md_5.bungee.config.YamlConfiguration; import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; +import net.t2code.t2codelib.BUNGEE.api.yaml.T2CBconfig; import net.t2code.t2codelib.BUNGEE.system.T2CodeBMain; import net.t2code.t2codelib.Util; @@ -20,15 +21,12 @@ public class T2CBlibConfig { config.createNewFile(); } Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config); - configuration.set("API.CommandGUI.Enable", false); - - - - + T2CBconfig.set("API.CommandGUI.Enable", false, configuration); + T2CBconfig.set("API.AutoResponse.Enable", false, configuration); + T2CBconfig.set("API.OPSecurity.Enable", false, configuration); ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, config); T2CBsend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms"); - } public static void select() throws IOException { @@ -36,13 +34,23 @@ public class T2CBlibConfig { Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(config); apiCommandGUIEnable = configuration.getBoolean("API.CommandGUI.Enable"); - + apiAutoResponse = configuration.getBoolean("API.AutoResponse.Enable"); + apiOpSecurity = configuration.getBoolean("API.OPSecurity.Enable"); } private static Boolean apiCommandGUIEnable; - + private static Boolean apiAutoResponse; + private static Boolean apiOpSecurity; public static Boolean getApiCommandGUIEnable() { return apiCommandGUIEnable; } + + public static Boolean getApiAutoResponse() { + return apiAutoResponse; + } + + public static Boolean getApiOpSecurity() { + return apiOpSecurity; + } } diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java new file mode 100644 index 0000000..d2bad03 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/T2CplmsgBcmd.java @@ -0,0 +1,37 @@ +package net.t2code.t2codelib.BUNGEE.system.pluginMessaging; + +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +public class T2CplmsgBcmd implements Listener { + @EventHandler + public void onPluginmessage(PluginMessageEvent event) { + if (event.getTag().equalsIgnoreCase("t2c:bcmd")) { + event.setCancelled(true); + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); + try { + String channel = stream.readUTF(); + String input = stream.readUTF(); + if (channel.equals("T2Code-Console")) { + ProxyServer.getInstance().getConsole().sendMessage("Command Console: "+ input); + ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input); + } else { + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel); + if (player != null) { + ProxyServer.getInstance().getConsole().sendMessage("Command " + player +": "+ input); + ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java new file mode 100644 index 0000000..50e46ec --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/autoResponse/T2CapiAutoResponse.java @@ -0,0 +1,48 @@ +package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.autoResponse; + +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; +import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; + +public class T2CapiAutoResponse implements Listener { + + @EventHandler + public void onPluginmessage(PluginMessageEvent event) { + if (event.getTag().equalsIgnoreCase("t2c:aresp")) { + DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); + event.setCancelled(true); + try { + String channel = stream.readUTF(); + String input = stream.readUTF(); + + switch (channel) { + case "ConC": + ProxyServer.getInstance().getConsole().sendMessage("Command Console: " + input); + ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input); + break; + case "ALLPMSG": + for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) { + T2CBsend.player(player, input); + } + break; + default: + ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel); + if (player != null) { + ProxyServer.getInstance().getConsole().sendMessage("Command " + player + ": " + input); + ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input); + } + break; + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUIEvent.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java similarity index 59% rename from src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUIEvent.java rename to src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java index a8534db..254bdf2 100644 --- a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUIEvent.java +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/commandgui/T2CapiCGUI.java @@ -1,7 +1,6 @@ package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.commandgui; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PostLoginEvent; @@ -11,31 +10,7 @@ import net.md_5.bungee.event.EventHandler; import java.io.*; import java.util.logging.Logger; -public class T2CapiCGUIEvent implements Listener { - - @EventHandler - public void onPluginmessage(net.md_5.bungee.api.event.PluginMessageEvent event) { - if (event.getTag().equalsIgnoreCase("t2c:cgui")) { - event.setCancelled(true); - DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData())); - try { - String channel = stream.readUTF(); - String input = stream.readUTF(); - if (channel.equals("cgui-Console")) { - ProxyServer.getInstance().getConsole().sendMessage("Command Console: " + input); - ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input); - } else { - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel); - if (player != null) { - ProxyServer.getInstance().getConsole().sendMessage("Command " + player + ": " + input); - ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } +public class T2CapiCGUI implements Listener { @EventHandler public void onJoin(PostLoginEvent e) { diff --git a/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java new file mode 100644 index 0000000..02f99d7 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/BUNGEE/system/pluginMessaging/opSecurity/T2CapiOpSecurity.java @@ -0,0 +1,48 @@ +package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity; + +import net.md_5.bungee.BungeeCord; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.plugin.Listener; +import net.md_5.bungee.event.EventHandler; +import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend; + +import java.io.*; +import java.util.logging.Logger; + +public class T2CapiOpSecurity implements Listener { + + @EventHandler + public void onPluginmessage(PluginMessageEvent event) { + if (event.getTag().equalsIgnoreCase("t2c:opsec")) { + event.setCancelled(true); + 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()); + } + BungeeCord.getInstance().getServers().values().stream().forEach((server) -> { + server.sendData("t2c:opsec", stream.toByteArray()); + }); + } +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java index 62f981f..347b50a 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/commands/T2Ccmd.java @@ -1,14 +1,25 @@ package net.t2code.t2codelib.SPIGOT.api.commands; +import net.t2code.t2codelib.SPIGOT.system.BCommandSenderReciver; import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class T2Ccmd { public static void console(String cmd) { - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd); + if (cmd.contains("!onBungee")){ + BCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true); + }else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd); } public static void player(Player player, String cmd) { - player.chat("/" + cmd); + if (cmd.contains("!asConsole")) { + if (cmd.contains("!onBungee")) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true); + } else console(cmd.replace("!asConsole", "")); + } else { + if (cmd.contains("!onBungee")) { + BCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false); + } else player.chat("/" + cmd); + } } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java index 318e7c7..81b40c1 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/eco/T2Ceco.java @@ -75,7 +75,6 @@ public class T2Ceco { public static boolean votePointsRemove(String prefix, Player player, Integer amount) { if (votePlugin(prefix, player)) { return VotingPluginMain.getPlugin().getVotingPluginUserManager().getVotingPluginUser(player).removePoints(amount); - } else return false; } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/items/T2CitemVersion.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/items/T2CitemVersion.java index 43808d3..795162b 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/items/T2CitemVersion.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/items/T2CitemVersion.java @@ -15,7 +15,7 @@ public class T2CitemVersion { private static ItemStack RED_WOOL; private static ItemStack RED_STAINED_GLASS_PANE; - public void scan() { + public static void scan() { if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) { Head = Material.valueOf("SKULL_ITEM"); YELLOW_WOOL = new ItemStack(Material.valueOf("WOOL"), 1, (short) 4); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java index 7bfeec2..97ad915 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2CminiMessage.java @@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.api.messages; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java index 4fb7be1..5f9084f 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/messages/T2Ctemplate.java @@ -18,12 +18,12 @@ public class T2Ctemplate { public static Long onLoadHeader(String prefix, List autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) { Long long_ = System.currentTimeMillis(); - T2Csend.console("[prefix] _______ ___ _____ "); - T2Csend.console("[prefix] |__ __|__ \\ / ____|"); - T2Csend.console("[prefix] | | ) | | "); - T2Csend.console("[prefix] | | / /| | "); - T2Csend.console("[prefix] | | / /_| |____ "); - T2Csend.console("[prefix] |_| |____|\\_____|"); + T2Csend.console(prefix + " _______ ___ _____ "); + T2Csend.console(prefix + " |__ __|__ \\ / ____|"); + T2Csend.console(prefix + " | | ) | | "); + T2Csend.console(prefix + " | | / /| | "); + T2Csend.console(prefix + " | | / /_| |____ "); + T2Csend.console(prefix + " |_| |____|\\_____|"); T2Csend.console(prefix + " §4 §e------------------"); T2Csend.console(prefix + " §4 §e| §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", "")); T2Csend.console(prefix + " §4 §e| §2Version: §6" + version); @@ -100,17 +100,17 @@ public class T2Ctemplate { String stLink = player ? stLinkPlayer : stLinkConsole; String pr = premiumVerified != null ? "
| Premium verified: [pr]".replace("[pr]", premiumVerified ? "YES" : "NO") : ""; - String stMSG = text != null ? "
| " + text + "
" : ""; - T2Csend.sender(sender, "_____________________" + String stMSG = text == null || text.equals("") ? "" : "
| " + text + "
"; + T2Csend.sender(sender, "---------------------" + "
" + stPlugin + stMSG - + "
" + stVersion + + stVersion + "
" + stAutor + "
" + stNVersion + "
" + stStable + "
" + stLink + pr - + "
_____________________"); + + "
---------------------"); } public static void sendInfo(CommandSender sender, Plugin plugin, int spigotID, String discord, String text) { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/plugins/T2CpluginCheck.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/plugins/T2CpluginCheck.java index 1ce7861..58cdef1 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/plugins/T2CpluginCheck.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/plugins/T2CpluginCheck.java @@ -55,6 +55,9 @@ public class T2CpluginCheck { public static Boolean opSec(){ return Bukkit.getPluginManager().getPlugin("OPSecurity") != null; } + public static Boolean T2COPSecurity(){ + return Bukkit.getPluginManager().getPlugin("T2C-OPSecurity") != null; + } public static Boolean papiTest(){ return Bukkit.getPluginManager().getPlugin("PaPiTest") != null; } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateAPI.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateAPI.java index 08be958..afb48d6 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateAPI.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateAPI.java @@ -70,28 +70,28 @@ public class T2CupdateAPI { public static void sendUpdateMsg(String prefix, Integer spigot, String discord, Plugin plugin) { String publicVersion = pluginVersions.get(plugin.getName()).publicVersion; String pluginVersion = plugin.getDescription().getVersion(); - T2Csend.console("§4=========== " + prefix + " §4==========="); + String h = "§4=========== " + prefix + " §4==========="; + String s1 = ""; + String s2 = "§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion; + String s3 = "§6You can download it here: §ehttps://www.spigotmc.org/resources/" + spigot; + String s4 = "§6You can find more information on Discord: §e" + discord; if (publicVersion.toLowerCase().contains("dev") || publicVersion.toLowerCase().contains("beta") || publicVersion.toLowerCase().contains("snapshot")) { if (publicVersion.toLowerCase().contains("dev")) { - T2Csend.console("§6A new §4DEV§6 version was found!"); + s1 = "§6A new §4DEV§6 version was found!§r"; } if (publicVersion.toLowerCase().contains("beta")) { - T2Csend.console("§6A new §2BETA§6 version was found!"); + s1 = "§6A new §2BETA§6 version was found!§r"; } if (publicVersion.toLowerCase().contains("snapshot")) { - T2Csend.console("§6A new §eSNAPSHOT§6 version was found!"); + s1 = "§6A new §eSNAPSHOT§6 version was found!§r"; } } else { - T2Csend.console("§6A new version was found!"); + s1 = "§6A new version was found!§r"; } - T2Csend.console("§6Your version: §c" + pluginVersion + " §7- §6Current version: §a" + publicVersion); - T2Csend.console("§6You can download it here: §ehttps://www.spigotmc.org/resources/" + spigot); - T2Csend.console("§6You can find more information on Discord: §e" + discord); - T2Csend.console("§4=========== " + prefix + " §4==========="); + String text = "
" + h + "
" + s1 + "
" + s2 + "
" + s3 + "
" + s4 + "
" + h; + T2Csend.console(text); } - private static Boolean load = false; - public static void onUpdateCheck(Plugin plugin, String prefix, int spigotID, String discord) { new BukkitRunnable() { @Override @@ -100,21 +100,25 @@ public class T2CupdateAPI { T2CupdateObject update = new T2CupdateObject( plugin.getName(), plugin.getDescription().getVersion(), - update_version + update_version, + false ); pluginVersions.put(plugin.getName(), update); if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) { - if (!load) { + if (!update.load) { new BukkitRunnable() { @Override public void run() { - load = true; + update.load = true; sendUpdateMsg(prefix, spigotID, discord, plugin); } }.runTaskLaterAsynchronously(plugin, 600L); } else sendUpdateMsg(prefix, spigotID, discord, plugin); } else { - T2Csend.console(prefix + " §2No update found."); + if (!update.load){ + T2Csend.console(prefix + " §2No update found."); + update.load = true; + } } }, prefix, plugin.getDescription().getVersion()); } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateChecker.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateChecker.java index 7183967..4cf9c7c 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateChecker.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateChecker.java @@ -53,10 +53,16 @@ public class T2CupdateChecker { } inputStream.close(); } catch (IOException var10) { + Boolean load = false; + if (T2CupdateAPI.pluginVersions.containsKey(plugin.getName())){ + load = T2CupdateAPI.pluginVersions.get(plugin.getName()).load; + } + T2CupdateObject update = new T2CupdateObject( plugin.getName(), pluginVersion, - null + null, + load ); T2CupdateAPI.pluginVersions.put(plugin.getName(), update); this.plugin.getLogger().severe("§4 Cannot look for updates: " + var10.getMessage()); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateObject.java b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateObject.java index b2bc938..48ddcc0 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateObject.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/api/update/T2CupdateObject.java @@ -1,16 +1,20 @@ package net.t2code.t2codelib.SPIGOT.api.update; + public class T2CupdateObject { public String pluginName; public String pluginVersion; public String publicVersion; + public Boolean load; public T2CupdateObject(String pluginName, String pluginVersion, - String publicVersion ) { + String publicVersion , + Boolean load) { this.pluginName = pluginName; this.pluginVersion = pluginVersion; this.publicVersion = publicVersion; + this.load=load; } } diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/BCommandSenderReciver.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/BCommandSenderReciver.java new file mode 100644 index 0000000..97ab8c4 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/BCommandSenderReciver.java @@ -0,0 +1,41 @@ +package net.t2code.t2codelib.SPIGOT.system; + +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class BCommandSenderReciver { + + public static void sendToBungee(CommandSender sender, String information, Boolean console) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + DataOutputStream output = new DataOutputStream(stream); + try { + if (console) { + output.writeUTF("T2Code-Console"); + } else { + if (sender instanceof Player) { + output.writeUTF(sender.getName()); + } else { + output.writeUTF("T2Code-Console"); + } + } + output.writeUTF(information); + } catch (IOException e) { + e.printStackTrace(); + } + if (sender instanceof Player) { + Player player = (Player) sender; + player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray()); + }else { + for(Player player : Bukkit.getOnlinePlayers()){ + player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray()); + return; + } + } + } + +} diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/CreateReportLog.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/CreateReportLog.java index 6dee9c9..a1a91da 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/CreateReportLog.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/CreateReportLog.java @@ -104,7 +104,7 @@ public class CreateReportLog { addFileToZip("", "logs/latest.log", zip, false); - for (String pl : Util.getT2cPlugins()){ + for (String pl : Util.getT2cPlugins()) { pluginToDebug(pl, zip); } zip.closeEntry(); diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java index da48d35..73e0900 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.system; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; +import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; @@ -38,14 +39,7 @@ public final class T2CodeLibMain extends JavaPlugin { plugin = this; autor = plugin.getDescription().getAuthors(); version = plugin.getDescription().getVersion(); - // try { - this.adventure = BukkitAudiences.create(this); - // nmIsLoad = true; - // } catch (Exception ex) { - // ex.printStackTrace(); - // nmIsLoad = false; - // } - + this.adventure = BukkitAudiences.create(this); long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); String prefix = Util.getPrefix(); @@ -56,10 +50,10 @@ public final class T2CodeLibMain extends JavaPlugin { } T2CmcVersion.onCheck(); - if (T2CmcVersion.isMc1_19()) { + if (T2CmcVersion.isMc1_20()) { T2Csend.console(prefix + " §4!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(prefix); - T2Csend.warning(plugin, "The 1.19.* is a very fresh / new version. If there are any bugs in our plugins, please report them to us via our Discord: http://dc.t2code.net"); + 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 + " §4!!!!!!!!!!!!!!!!!!!!"); try { @@ -91,12 +85,16 @@ public final class T2CodeLibMain extends JavaPlugin { plugin.getCommand("t2code").setExecutor(new CmdExecuter()); ConfigCreate.configCreate(); + T2CitemVersion.scan(); LanguagesCreate.langCreate(); SelectLibConfig.onSelect(); SelectLibMsg.onSelect(); T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getSpigotID(), Util.getDiscord()); Metrics.Bstats(plugin, Util.getBstatsID()); + if (SelectLibConfig.getBungee()){ + Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd"); + } Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin); T2Ctemplate.onLoadFooter(prefix, long_); @@ -113,15 +111,14 @@ public final class T2CodeLibMain extends JavaPlugin { } } + Vault.vaultDisable(); + T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); if (nmIsLoad) { if (this.adventure != null) { this.adventure.close(); this.adventure = null; } } - - Vault.vaultDisable(); - T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); } public static File getPath() { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java index 8b232dc..6cb30b2 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/ConfigCreate.java @@ -27,7 +27,6 @@ public class ConfigCreate { T2Cconfig.set("Plugin.language", "english", yamlConfiguration); T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration); - T2Cconfig.set("BungeeCord.ThisServer", "server", yamlConfiguration); T2Cconfig.set("Player.Inventories.CloseByServerStop", true, yamlConfiguration); try { diff --git a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java index 370e11c..f1bb07b 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/config/config/SelectLibConfig.java @@ -12,6 +12,7 @@ public class SelectLibConfig { private static Integer UpdateCheckTimeInterval; private static Boolean Debug; private static String language; + private static Boolean bungee; private static Boolean InventoriesCloseByServerStop; public static void onSelect() { @@ -23,6 +24,7 @@ public class SelectLibConfig { UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval"); Debug = yamlConfiguration.getBoolean("Plugin.Debug"); language = yamlConfiguration.getString("Plugin.language"); + bungee = yamlConfiguration.getBoolean("BungeeCord.Enable"); InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop"); } @@ -46,6 +48,10 @@ public class SelectLibConfig { return language; } + public static Boolean getBungee() { + return bungee; + } + public static Boolean getInventoriesCloseByServerStop() { return InventoriesCloseByServerStop; } diff --git a/src/main/java/net/t2code/t2codelib/Util.java b/src/main/java/net/t2code/t2codelib/Util.java index ba56dce..ea6ab55 100644 --- a/src/main/java/net/t2code/t2codelib/Util.java +++ b/src/main/java/net/t2code/t2codelib/Util.java @@ -6,7 +6,7 @@ import java.util.List; public class Util { public static String getInfoText() { - return "DEVELOPMENT VERSION!"; + return ""; } public static String getPrefix() { @@ -31,12 +31,13 @@ public class Util { public static List getT2cPlugins() { return Arrays.asList( + "T2CodeLib", "T2C-LuckyBox", "WonderBagShop", "CommandGUI", + "T2C-OPSecurity", "OPSecurity", "PaPiTest", - "PlotSquaredGUI", "T2C-Alias", "T2C-AutoResponse", "LoreEditor",