48 lines
1.2 KiB
Java
48 lines
1.2 KiB
Java
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;
|
|
}
|
|
}
|
|
}
|