This commit is contained in:
JaTiTV 2024-07-01 19:50:19 +02:00
parent d5a82e6005
commit 7c3ffc80c3
12 changed files with 186 additions and 36 deletions

View File

@ -27,8 +27,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>11</source> <source>9</source>
<target>11</target> <target>9</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -238,7 +238,7 @@
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20230227</version> <version>20231013</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -26,6 +26,7 @@ public class T2ChoverModule {
} }
public static void moduleConsole(String msg) { public static void moduleConsole(String msg) {
Bukkit.getConsoleSender().sendMessage(msg); //todo
if (T2CodeLibMain.getMmIsLoad()) { if (T2CodeLibMain.getMmIsLoad()) {
T2CminiMessage.sendConsoleMiniMessage(msg); T2CminiMessage.sendConsoleMiniMessage(msg);
return; return;

View File

@ -14,15 +14,15 @@ import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
public class T2Ctemplate { public class T2Ctemplate {
public static @NotNull Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) { public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord) {
return onLoadHeader(prefix, autor, version, spigot, discord, null, null); return onLoadHeader(prefix, autor, version, spigot, discord, null, null);
} }
public static @NotNull Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) { public static Long onLoadHeader(String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium) {
return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null); return onLoadHeader(prefix, autor, version, spigot, discord, isPremium, null);
} }
public static Long onLoadHeader(@NotNull String prefix, @NotNull List<String> autor, @NotNull String version, @NotNull String spigot, @NotNull String discord, Boolean isPremium, Boolean isVerify) { public static Long onLoadHeader( String prefix, List<String> autor, String version, String spigot, String discord, Boolean isPremium, Boolean isVerify) {
Long long_ = System.currentTimeMillis(); Long long_ = System.currentTimeMillis();
/** /**

View File

@ -2,10 +2,12 @@ package net.t2code.t2codelib.SPIGOT.system;
import lombok.Getter; import lombok.Getter;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers; import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayers;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion; import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
@ -43,23 +45,25 @@ public final class T2CodeLibMain extends JavaPlugin {
@Getter @Getter
private static Boolean mmIsLoad = true; private static Boolean mmIsLoad = true;
private static Boolean load = false; private static Boolean load = false;
@Getter
private static T2CplatformDetector.PlatformType plattform; private static T2CplatformDetector.PlatformType plattform;
public static Logger logger; // public static Logger logger;
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
logger = getLogger(); // logger = getLogger();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
plattform = T2CplatformDetector.detectPlatform();
try { try {
adventure = BukkitAudiences.create(this); adventure = BukkitAudiences.create(this);
} catch (Exception e) { } catch (Exception e) {
mmIsLoad = false; mmIsLoad = false;
} }
plattform = T2CplatformDetector.detectPlatform();
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), null, null); long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), null, null);
checkIsBungee(); checkIsBungee();

View File

@ -4,6 +4,8 @@ import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.Title; import net.kyori.adventure.title.Title;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -65,6 +67,11 @@ public class T2CVsend {
logger.warn(msg); logger.warn(msg);
} }
public static void debug(Logger logger, String msg) {
if (!(boolean)T2CVlibConfig.VALUES.debug.getValue()) return;
logger.warn(msg);
}
public static void info(Logger logger, String msg) { public static void info(Logger logger, String msg) {
logger.info(msg); logger.info(msg);
} }

View File

@ -6,7 +6,6 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer; import com.velocitypowered.api.proxy.ProxyServer;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
@ -14,14 +13,15 @@ import net.t2code.t2codelib.VELOCITY.api.commands.T2CVcmd;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain; import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger; import org.slf4j.Logger;
public class T2CplmsgBcmd { public class T2CVplmsgCmd {
private static final ProxyServer server = T2CodeVMain.getServer(); private final ProxyServer server;
private static final Logger logger = T2CodeVMain.getLogger(); private final Logger logger;
@Subscribe public T2CVplmsgCmd(ProxyServer server, Logger logger) {
public void onProxyInitialization(ProxyInitializeEvent event) { this.server = server;
this.logger = logger;
server.getChannelRegistrar().register(T2CodeVMain.bcmd); server.getChannelRegistrar().register(T2CodeVMain.bcmd);
} }

View File

@ -15,9 +15,15 @@ import java.io.ByteArrayInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
public class T2CapiAutoResponse { public class T2CVapiAutoResponse {
private static final ProxyServer server = T2CodeVMain.getServer(); private final ProxyServer server;
private static final Logger logger = T2CodeVMain.getLogger(); private final Logger logger;
public T2CVapiAutoResponse(ProxyServer server, Logger logger) {
this.server = server;
this.logger = logger;
server.getChannelRegistrar().register(T2CodeVMain.aresp);
}
@Subscribe @Subscribe
public void onPluginmessage(PluginMessageEvent event) { public void onPluginmessage(PluginMessageEvent event) {

View File

@ -17,8 +17,14 @@ import java.io.IOException;
public class T2CVapiCGUI { public class T2CVapiCGUI {
private static final ProxyServer server = T2CodeVMain.getServer(); private static ProxyServer server;
private static final Logger logger = T2CodeVMain.getLogger(); private static Logger logger;
public T2CVapiCGUI(ProxyServer server, Logger logger) {
T2CVapiCGUI.server = server;
T2CVapiCGUI.logger = logger;
server.getChannelRegistrar().register(T2CodeVMain.cguiopl);
}
@Subscribe @Subscribe

View File

@ -11,9 +11,15 @@ import org.slf4j.Logger;
import java.io.*; import java.io.*;
public class T2CapiOpSecurity { public class T2CVapiOpSecurity {
private static final ProxyServer server = T2CodeVMain.getServer(); private static ProxyServer server ;
private static final Logger logger = T2CodeVMain.getLogger(); private static Logger logger ;
public T2CVapiOpSecurity(ProxyServer server, Logger logger) {
T2CVapiOpSecurity.server = server;
T2CVapiOpSecurity.logger = logger;
server.getChannelRegistrar().register(T2CodeVMain.opsec);
}
@Subscribe @Subscribe
public void onPluginmessage(PluginMessageEvent event) { public void onPluginmessage(PluginMessageEvent event) {

View File

@ -0,0 +1,111 @@
// This class was created by JaTiTV.
package net.t2code.t2codelib.VELOCITY.api.proxyPlayers;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.connection.PostLoginEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.t2code.t2codelib.SPIGOT.api.bungeePlayers.T2CbungeePlayersEnum;
import net.t2code.t2codelib.VELOCITY.api.messages.T2CVsend;
import net.t2code.t2codelib.VELOCITY.system.T2CodeVMain;
import org.slf4j.Logger;
import java.io.*;
public class T2CVPlayers {
public static ProxyServer server = T2CodeVMain.getServer();
public static Logger logger = T2CodeVMain.getLogger();
@Subscribe
public void onJoin(PostLoginEvent e) {
sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.JOIN, "");
}
@Subscribe
public void onDisconnect(DisconnectEvent e) {
sendToSpigotPlayer(e.getPlayer().getUsername(), T2CbungeePlayersEnum.QUIT, "");
}
public void sendToSpigotPlayer(String name, T2CbungeePlayersEnum value, String uuid) {
switch (value) {
case JOIN:
case QUIT:
sendToSpigotPlayerExecute(name, value, uuid);
break;
case GIVEALL:
StringBuilder input = new StringBuilder();
for (Player player : server.getAllPlayers()) {
input.append(player.getUsername()).append(";");
}
sendToSpigotPlayerExecute(input.toString(), T2CbungeePlayersEnum.GIVEALL, uuid);
break;
}
}
private void sendToSpigotPlayerExecute(String name, T2CbungeePlayersEnum value, String uuid) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(value.name());
output.writeUTF(name);
output.writeUTF(uuid);
} catch (IOException e) {
logger.error (e.getMessage());
}
T2CVsend.debug(logger, "PluginMessage received channel: t2c:bonlp");
T2CVsend.debug(logger, "PluginMessage received subChannel: " + value.name());
T2CVsend.debug(logger, "PluginMessage received input: " + name);
T2CVsend.debug(logger, "PluginMessage received input2/uuid: " + uuid);
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.bonlp, data);
}
}
public static void sendToSpigotDeleteAll() {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
output.writeUTF(T2CbungeePlayersEnum.CLEAR.name());
output.writeUTF("");
output.writeUTF("");
} catch (IOException e) {
logger.error(e.getMessage());
}
byte[] data = stream.toByteArray();
for (RegisteredServer server : server.getAllServers()) {
server.sendPluginMessage(T2CodeVMain.bonlp, data);
}
}
@Subscribe
public void onPluginMessage(PluginMessageEvent event) {
if (event.getIdentifier() != T2CodeVMain.bonlp) {
return;
}
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
try {
T2CbungeePlayersEnum subChannel = T2CbungeePlayersEnum.valueOf(stream.readUTF());
String input = stream.readUTF();
T2CVsend.debug(logger, "PluginMessage received channel: " + T2CodeVMain.bonlp);
T2CVsend.debug(logger, "PluginMessage received subChannel: " + subChannel.name());
T2CVsend.debug(logger, "PluginMessage received input/uuid: " + input);
sendToSpigotPlayer("", subChannel, input);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -12,6 +12,11 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
import lombok.Getter; import lombok.Getter;
import net.t2code.t2codelib.Util; import net.t2code.t2codelib.Util;
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.T2CVplmsgCmd;
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.autoResponse.T2CVapiAutoResponse;
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.commandgui.T2CVapiCGUI;
import net.t2code.t2codelib.VELOCITY.api.pluginMessaging.opSecurity.T2CVapiOpSecurity;
import net.t2code.t2codelib.VELOCITY.api.proxyPlayers.T2CVPlayers;
import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI; import net.t2code.t2codelib.VELOCITY.api.update.T2CVupdateAPI;
import net.t2code.t2codelib.VELOCITY.system.bstats.Metrics; import net.t2code.t2codelib.VELOCITY.system.bstats.Metrics;
import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig; import net.t2code.t2codelib.VELOCITY.system.config.T2CVlibConfig;
@ -70,7 +75,7 @@ public class T2CodeVMain {
logger.info("║ Discord: {}", Util.getDiscord()); logger.info("║ Discord: {}", Util.getDiscord());
try { try {
T2CVlibConfig.set(dataDirectory,logger); T2CVlibConfig.set(dataDirectory, logger);
} catch (IOException ex) { } catch (IOException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
@ -79,23 +84,25 @@ public class T2CodeVMain {
// server.getEventManager().register(this, new T2CVpluginMessagingCmd(server, logger)); // server.getEventManager().register(this, new T2CVpluginMessagingCmd(server, logger));
//API //API
server.getChannelRegistrar().register(T2CodeVMain.bcmd);
server.getEventManager().register(this, new T2CVplmsgCmd(server, logger));
server.getChannelRegistrar().register(T2CodeVMain.bonlp); server.getChannelRegistrar().register(T2CodeVMain.bonlp);
T2CVPlayers.sendToSpigotDeleteAll(); T2CVPlayers.sendToSpigotDeleteAll();
// if (T2CVlibConfig.getApiCommandGUIEnable()) { if ((boolean) T2CVlibConfig.VALUES.apiCommandGUIEnable.getValue()) {
server.getChannelRegistrar().register(T2CodeVMain.cguiopl); server.getEventManager().register(this, new T2CVapiCGUI(server, logger));
T2CVapiCGUI.sendToSpigotDeleteAll(); T2CVapiCGUI.sendToSpigotDeleteAll();
// } }
// if (T2CVlibConfig.getApiAutoResponse()) { if ((boolean) T2CVlibConfig.VALUES.apiAutoResponse.getValue()) {
server.getChannelRegistrar().register(T2CodeVMain.aresp); server.getEventManager().register(this, new T2CVapiAutoResponse(server, logger));
// } }
// if (T2CVlibConfig.getApiOpSecurity()) { if ((boolean) T2CVlibConfig.VALUES.apiOpSecurity.getValue()) {
server.getChannelRegistrar().register(T2CodeVMain.opsec); server.getEventManager().register(this, new T2CVapiOpSecurity(server, logger));
//} }
Metrics.bStats(this, Util.getBstatsID(), metricsFactory); Metrics.bStats(this, Util.getBstatsID(), metricsFactory);

View File

@ -20,6 +20,8 @@ public class T2CVlibConfig {
updateTimer("updateCheck.timerInMin", 60, "In this option you can set the time interval in minutes in which updates should be checked."), updateTimer("updateCheck.timerInMin", 60, "In this option you can set the time interval in minutes in which updates should be checked."),
seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, "In this option you can set whether you want to receive and display beta and snapshot versions in the update check."), seePreReleaseUpdates("updateCheck.seePreReleaseUpdates", true, "In this option you can set whether you want to receive and display beta and snapshot versions in the update check."),
debug("plugin.debug.debugModus", false, "The debug mode sends more detailed debug information to the console."),
apiCommandGUIEnable("api.commandGUI.enable", false, "With this option you activate the api interface for the T2C-CommandGUI plugin."), apiCommandGUIEnable("api.commandGUI.enable", false, "With this option you activate the api interface for the T2C-CommandGUI plugin."),
apiAutoResponse("api.autoResponse.enable", false, "With this option you activate the api interface for the T2C-AutoResponse plugin."), apiAutoResponse("api.autoResponse.enable", false, "With this option you activate the api interface for the T2C-AutoResponse plugin."),
apiOpSecurity("api.opSecurity.enable", false, "With this option you activate the api interface for the T2C-OPSecurity plugin."), apiOpSecurity("api.opSecurity.enable", false, "With this option you activate the api interface for the T2C-OPSecurity plugin."),