Changes:
Commands:
- The command '/t2code serverid' has been added to display the server ID assigned by the T2CodeLib.
- The command '/t2code bcmd <command>' was added to execute a bungee command from a spigot plugin

DebugLog:
- The number of offline players is now displayed in T2CoderLog.txt
- The offline players as well as the plugins in the T2CoderLog.txt are now listed in alphabetical order

- Smaller code changes
This commit is contained in:
JaTiTV 2023-06-19 21:17:49 +02:00
parent b2ebce50ed
commit 034bf241e5
10 changed files with 71 additions and 24 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.1</version>
<version>15.2</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->

View File

@ -5,7 +5,6 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.api.messages.T2CBsend;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import net.t2code.t2codelib.UpdateType;

View File

@ -34,7 +34,7 @@ public class T2CBload {
throw new RuntimeException(e);
}
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID,url);
T2CBupdateAPI.onUpdateCheckTimer(plugin, prefix, discord, spigotID, url);
//API
plugin.getProxy().registerChannel("t2c:bcmd");

View File

@ -43,8 +43,6 @@ public class T2CodeBMain extends Plugin {
mmIsLoad = false;
}
T2CBload.onLoad(plugin, Util.getPrefix(), autor, orgVersion, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID(),Util.getGit());
String[] fv = orgVersion.split("_");
plugin.getDescription().setVersion(fv[0]);
version = plugin.getDescription().getVersion();
}

View File

@ -5,6 +5,7 @@ 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.Util;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
@ -19,13 +20,14 @@ public class T2CplmsgBcmd implements Listener {
try {
String channel = stream.readUTF();
String input = stream.readUTF();
String serverID = stream.readUTF();
if (channel.equals("T2Code-Console")) {
ProxyServer.getInstance().getConsole().sendMessage("Command Console: "+ input);
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command Console: §r"+ 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().getConsole().sendMessage(Util.getPrefix()+" [§6"+serverID+"§r] §cT2C BCMD Command §r" + player +": "+ input);
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
}
}

View File

@ -1,5 +1,7 @@
package net.t2code.t2codelib.SPIGOT.system;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -7,6 +9,7 @@ import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Arrays;
public class T2CbungeeCommandSenderReciver {
@ -24,18 +27,22 @@ public class T2CbungeeCommandSenderReciver {
}
}
output.writeUTF(information);
output.writeUTF(String.valueOf(Util.getServerUUID()));
} 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;
}
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
} else {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendPluginMessage(T2CodeLibMain.getPlugin(), "t2c:bcmd", stream.toByteArray());
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage received T2CbungeeCommandSenderReciver: t2c:bcmd - " + Arrays.toString(stream.toByteArray()) + " Player: " + player.getName());
return;
}
//todo
}
}
}

View File

@ -111,6 +111,7 @@ public final class T2CodeLibMain extends JavaPlugin {
Metrics.Bstats(plugin, Util.getBstatsID());
if (SelectLibConfig.getBungee()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:bcmd");
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bonlp");
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:bonlp")) {

View File

@ -1,8 +1,11 @@
package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.Util;
@ -38,18 +41,31 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
Commands.info(sender);
return false;
case "updateinfo":
Commands.updateInfo(sender,args);
Commands.updateInfo(sender, args);
return false;
case "reloadconfig":
SelectLibConfig.onSelect();
T2Csend.sender(sender, Util.getPrefix() + " §2Config successfully reloaded");
return false;
case "debug":
Commands.debug(sender,args);
Commands.debug(sender, args);
return false;
case "test":
T2Csend.sender(sender, T2CbungeePlayers.getBungeePlayers().toString());
return false;
case "serverid":
T2Csend.sender(sender, ("[prefix] <red>T2C ServerID:</red> <gold><hover:show_text:'<yellow>copy</yellow>'>" +
"<click:copy_to_clipboard:[id]>[id]</click></hover></gold>").replace("[prefix]", Util.getPrefix()).replace("[id]", String.valueOf(Util.getServerUUID())));
return false;
case "bcmd":
String cmd = "";
for (String s : args) {
cmd = cmd + s + " ";
}
cmd = cmd.replace("bcmd ", "");
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd, true);
T2Cdebug.debug(T2CodeLibMain.getPlugin(), "PluginMessage BCMD: " + cmd);
return false;
default:
T2Csend.sender(sender, "§4Use: §7/t2code debug createReportLog");
@ -61,6 +77,8 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("debug", "t2code.admin");
put("info", "t2code.admin");
put("serverid", "t2code.admin");
put("bcmd", "t2code.admin");
put("reloadconfig", "t2code.admin");
put("updateinfo", "t2code.admin");
}};
@ -81,17 +99,23 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 2 && args[0].equalsIgnoreCase("debug")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug"))) {
if (passend("createReportLog",args[1])) list.add("createReportLog");
if (passend("deleteReportLog",args[1])) list.add("deleteReportLog");
if (passend("createReportLog", args[1])) list.add("createReportLog");
if (passend("deleteReportLog", args[1])) list.add("deleteReportLog");
}
}
return list;
}
if (args.length == 2 && args[0].equalsIgnoreCase("bcmd")) {
if (sender.hasPermission("t2code.admin")) {
list.add("<command>");
}
return list;
}
if (args.length == 2 && args[0].equalsIgnoreCase("updateinfo")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("updateinfo"))) {
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()){
if (passend(pl.getValue().pluginName,args[1])) list.add(pl.getValue().pluginName);
for (Map.Entry<String, T2CupdateObject> pl : T2CupdateAPI.pluginVersions.entrySet()) {
if (passend(pl.getValue().pluginName, args[1])) list.add(pl.getValue().pluginName);
}
}
}
@ -99,11 +123,11 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
}
if (args.length == 3 && args[0].equalsIgnoreCase("debug")&& args[1].equalsIgnoreCase("deleteReportLog")) {
if (args.length == 3 && args[0].equalsIgnoreCase("debug") && args[1].equalsIgnoreCase("deleteReportLog")) {
if (sender.hasPermission("t2code.admin")) {
if (hasPermission(p, arg1.get("debug"))) {
for (String st : ReportLogStorage.list){
if (passend(st,args[2])) list.add(st);
for (String st : ReportLogStorage.list) {
if (passend(st, args[2])) list.add(st);
}
}
}

View File

@ -3,6 +3,7 @@ package net.t2code.t2codelib.SPIGOT.system.cmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import net.t2code.t2codelib.Util;
import org.bukkit.Bukkit;

View File

@ -29,7 +29,10 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@ -101,18 +104,30 @@ public class CreateReportLog {
pWriter.println("T2C-LuckyBox isV: " + LuckyBoxAPI.isV());
pWriter.println();
}
pWriter.println("OfflinePlayers amount: " + Bukkit.getOfflinePlayers().length);
pWriter.println("OfflinePlayers: ");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
ArrayList<OfflinePlayer> players = new ArrayList<>();
Collections.addAll(players, Bukkit.getOfflinePlayers());
players.sort(Comparator.comparing(OfflinePlayer::getName));
for (OfflinePlayer player : players) {
pWriter.println(" - " + player.getName() + " - " + player.getUniqueId());
}
pWriter.println();
pWriter.println("Plugins amount: " + Bukkit.getPluginManager().getPlugins().length);
pWriter.println("Plugins: ");
for (Plugin pl : Bukkit.getPluginManager().getPlugins()) {
ArrayList<Plugin> plugins = new ArrayList<>();
Collections.addAll(plugins, Bukkit.getPluginManager().getPlugins());
plugins.sort(Comparator.comparing(Plugin::getName));
for (Plugin pl : plugins) {
pWriter.println(" - " + pl.getName() + " - " + pl.getDescription().getVersion() + " - Enabled: " + pl.isEnabled() + " - Autors: "
+ pl.getDescription().getAuthors() + " - SoftDepend: " + pl.getDescription().getSoftDepend() + " - Depend: " + pl.getDescription().getDepend()
+ " LoadBefore: " + pl.getDescription().getLoadBefore() + " - Website: " + pl.getDescription().getWebsite());
}
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {