add T2CplatformDetector
This commit is contained in:
parent
b8c65cb537
commit
2ac9c890f6
@ -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());
|
||||
|
47
src/main/java/net/t2code/t2codelib/T2CplatformDetector.java
Normal file
47
src/main/java/net/t2code/t2codelib/T2CplatformDetector.java
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user