final 13.0 & 13.1
13.1: add by Commands "!asConsole" & "!onBungee"
This commit is contained in:
@@ -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)) {
|
||||
|
@@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class T2CBupdateAPI {
|
||||
public static HashMap<String, T2CBupdateObject> bungeePluginVersionen = new HashMap<String, T2CBupdateObject>();
|
||||
public static HashMap<String, T2CBupdateObject> bungeePluginVersins = new HashMap<String, T2CBupdateObject>();
|
||||
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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) {
|
@@ -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());
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user