add T2CplatformDetector
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user