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 63195b1..780af59 100644 --- a/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java +++ b/src/main/java/net/t2code/t2codelib/SPIGOT/system/T2CodeLibMain.java @@ -21,6 +21,7 @@ import net.t2code.t2codelib.SPIGOT.system.config.config.ConfigCreate; import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig; import net.t2code.t2codelib.SPIGOT.system.config.languages.LanguagesCreate; import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; +import net.t2code.t2codelib.T2CplatformDetector; import net.t2code.t2codelib.Util; import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; @@ -41,6 +42,7 @@ public final class T2CodeLibMain extends JavaPlugin { @Getter private static Boolean mmIsLoad = true; private static Boolean load = false; + private static T2CplatformDetector.PlatformType plattform; @Override public void onEnable() { @@ -48,6 +50,7 @@ public final class T2CodeLibMain extends JavaPlugin { plugin = this; autor = plugin.getDescription().getAuthors(); version = plugin.getDescription().getVersion(); + plattform = T2CplatformDetector.detectPlatform(); try { adventure = BukkitAudiences.create(this); } catch (Exception e) { @@ -95,6 +98,7 @@ public final class T2CodeLibMain extends JavaPlugin { } T2Ctemplate.onLoadSeparateStroke(prefix); T2Csend.console(prefix + " §2Server run on:"); + T2Csend.console(prefix + " §3Platform: §6" + plattform.name()); T2Csend.console(prefix + " §3mcVersion: §6" + T2CmcVersion.getMcVersion()); T2Csend.console(prefix + " §3bukkitVersion: §6" + T2CmcVersion.getBukkitVersion()); T2Csend.console(prefix + " §3nms: §6" + T2CmcVersion.getNms()); diff --git a/src/main/java/net/t2code/t2codelib/T2CplatformDetector.java b/src/main/java/net/t2code/t2codelib/T2CplatformDetector.java new file mode 100644 index 0000000..54728c7 --- /dev/null +++ b/src/main/java/net/t2code/t2codelib/T2CplatformDetector.java @@ -0,0 +1,47 @@ +package net.t2code.t2codelib;// This class was created by JaTiTV. + +public class T2CplatformDetector { + + public static PlatformType detectPlatform; + + public enum PlatformType { + SPIGOT, + PAPER, + BUNGEECORD, + UNKNOWN + } + + public static PlatformType detectPlatform() { + // Check for Bukkit/Spigot/Paper + try { + Class.forName("org.bukkit.Bukkit"); + if (isPaper()) { + return PlatformType.PAPER; + } else { + return PlatformType.SPIGOT; + } + } catch (ClassNotFoundException e) { + // Not a Bukkit/Spigot/Paper server + } + + // Check for BungeeCord + try { + Class.forName("net.md_5.bungee.api.ProxyServer"); + return PlatformType.BUNGEECORD; + } catch (ClassNotFoundException e) { + // Not a BungeeCord server + } + + return PlatformType.UNKNOWN; + } + + private static boolean isPaper() { + // Paper has the PaperConfig class, which Spigot and Bukkit do not have + try { + Class.forName("com.destroystokyo.paper.PaperConfig"); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } +}