mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-27 12:35:12 +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;
|
package com.songoda.core.library.compatibility;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO
|
|
||||||
*/
|
|
||||||
public enum ServerProject {
|
public enum ServerProject {
|
||||||
|
|
||||||
CRAFTBUKKIT, SPIGOT, PAPER;
|
UNKNOWN, CRAFTBUKKIT, SPIGOT, PAPER, GLOWSTONE;
|
||||||
private final static String serverPackage = Bukkit.getServer().getClass().getPackage().getName();
|
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