Merge remote-tracking branch 'origin/Testing' into Testing

This commit is contained in:
Brianna 2019-08-23 14:30:56 -04:00
commit 7d04ff4c96

View File

@ -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);
}
}