feat: use java 8 and spigot api
SADLY
This commit is contained in:
3 files changed
+33
-17
No files matched your search
+8
-2
@@ -7,16 +7,22 @@ group = "at.helpch.placeholderapi.expansion"
|
||||
version = "2.7.2"
|
||||
|
||||
repositories {
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
mavenCentral()
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("me.clip:placeholderapi:2.11.3")
|
||||
}
|
||||
|
||||
tasks {
|
||||
java {
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName.set("PAPI-Expansion-Server-${project.version}.jar")
|
||||
}
|
||||
|
||||
@@ -4,19 +4,22 @@ import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public final class ServerUtil {
|
||||
|
||||
private static final Map<String, String> variants = new TreeMap<>();
|
||||
private static final String variant;
|
||||
private static final String build;
|
||||
|
||||
// TPS stuff
|
||||
private static final Object craftServer;
|
||||
private static final Field tpsField;
|
||||
private static boolean hasTpsMethod; // Paper and its forks have Bukkit#getTps
|
||||
private static Method getTpsMethod; // Paper and its forks have Bukkit#getTPS
|
||||
// ----
|
||||
|
||||
private static final String variant;
|
||||
private static final String build;
|
||||
|
||||
static {
|
||||
variants.put("net.pl3x.purpur.PurpurConfig", "Purpur");
|
||||
@@ -78,8 +81,7 @@ public final class ServerUtil {
|
||||
|
||||
private static Field getTpsHandler() {
|
||||
try {
|
||||
Bukkit.class.getMethod("getTPS");
|
||||
hasTpsMethod = true;
|
||||
getTpsMethod = Bukkit.class.getMethod("getTPS");
|
||||
return null;
|
||||
} catch (NoSuchMethodException ignored) { }
|
||||
|
||||
@@ -138,8 +140,12 @@ public final class ServerUtil {
|
||||
}
|
||||
|
||||
public static double[] getTps() {
|
||||
if (hasTpsMethod) {
|
||||
return Bukkit.getTPS();
|
||||
if (getTpsMethod != null) {
|
||||
try {
|
||||
return (double[]) getTpsMethod.invoke(null);
|
||||
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||
return new double[]{0, 0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
if (craftServer == null || tpsField == null) {
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.google.common.primitives.Ints;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -39,11 +41,10 @@ public final class VersionHelper {
|
||||
|
||||
private static final int V1_17 = 1_17_0;
|
||||
|
||||
private static final boolean IS_PAPER = checkPaper();
|
||||
public static final String MINECRAFT_VERSION = getMinecraftVersion();
|
||||
private static final int CURRENT_VERSION = getCurrentVersion();
|
||||
|
||||
private static final boolean IS_PAPER = checkPaper();
|
||||
|
||||
public static final boolean IS_1_17_OR_HIGHER = CURRENT_VERSION >= V1_17;
|
||||
|
||||
/**
|
||||
@@ -92,13 +93,16 @@ public final class VersionHelper {
|
||||
}
|
||||
|
||||
private static String getMinecraftVersion() {
|
||||
try {
|
||||
// Paper method from 2020 - returns the version like 1.20.1
|
||||
return Bukkit.getMinecraftVersion();
|
||||
} catch (NoSuchMethodError ignored) {
|
||||
// The version is formatted as 1.20.1-R0.1-SNAPSHOT
|
||||
return Bukkit.getBukkitVersion().split("-")[0];
|
||||
if (IS_PAPER) {
|
||||
try {
|
||||
// Paper method from 2020 - returns the version like 1.20.1
|
||||
final Method method = Bukkit.class.getDeclaredMethod("getMinecraftVersion");
|
||||
return (String) method.invoke(Bukkit.getServer());
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
|
||||
}
|
||||
|
||||
// The version is formatted as 1.20.1-R0.1-SNAPSHOT
|
||||
return Bukkit.getBukkitVersion().split("-")[0];
|
||||
}
|
||||
|
||||
public static String getNmsVersion() {
|
||||
|
||||
Reference in new issue
Block a user