mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
Merge remote-tracking branch 'origin/Testing' into Testing
This commit is contained in:
commit
7d04ff4c96
@ -1,13 +1,47 @@
|
||||
package com.songoda.core.library.compatibility;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public enum ServerProject {
|
||||
|
||||
CRAFTBUKKIT, SPIGOT, PAPER;
|
||||
private final static String serverPackage = Bukkit.getServer().getClass().getPackage().getName();
|
||||
|
||||
|
||||
UNKNOWN, CRAFTBUKKIT, SPIGOT, PAPER, GLOWSTONE;
|
||||
private static ServerProject serverProject = checkProject();
|
||||
|
||||
private static ServerProject checkProject() {
|
||||
String serverPath = Bukkit.getServer().getClass().getName();
|
||||
if (serverPath.contains("glowstone")) {
|
||||
return GLOWSTONE;
|
||||
}
|
||||
// paper used to be called "paperclip"
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paperclip.Paperclip");
|
||||
return PAPER;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
}
|
||||
try {
|
||||
Class.forName("com.destroystokyo.paper.PaperConfig");
|
||||
return PAPER;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
}
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
return SPIGOT;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
}
|
||||
return serverPath.contains("craftbukkit") ? CRAFTBUKKIT : UNKNOWN;
|
||||
}
|
||||
|
||||
public static ServerProject getServerVersion() {
|
||||
return serverProject;
|
||||
}
|
||||
|
||||
public static boolean isServer(ServerProject version) {
|
||||
return serverProject == version;
|
||||
}
|
||||
|
||||
public static boolean isServer(ServerVersion... versions) {
|
||||
return ArrayUtils.contains(versions, serverProject);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user