Skip to content

Commit 4767a10

Browse files
Do less work at static than before.
1 parent 545a779 commit 4767a10

File tree

1 file changed

+4
-36
lines changed

1 file changed

+4
-36
lines changed

src/main/java/me/flame/menus/util/VersionHelper.java

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import java.util.regex.Pattern;
1010
import java.util.regex.Matcher;
1111

12-
public class VersionHelper {
13-
private static final String NMS_VERSION = getNmsVersion();
12+
// changed
1413

14+
public class VersionHelper {
1515
// Unbreakable change
1616
private static final int V1_11 = 1110;
1717
// Material and components on items change
@@ -25,14 +25,6 @@ public class VersionHelper {
2525

2626
private static final int CURRENT_VERSION = getCurrentVersion();
2727

28-
private static final boolean IS_PAPER = checkPaper();
29-
30-
/**
31-
* Checks if the version supports Components or not
32-
* Spigot always false
33-
*/
34-
public static final boolean IS_COMPONENT_LEGACY = CURRENT_VERSION < V1_16_5 || !IS_PAPER;
35-
3628
/**
3729
* Checks if the version is lower than 1.13 due to the item changes
3830
*/
@@ -59,21 +51,6 @@ public class VersionHelper {
5951
*/
6052
public static final boolean IS_CUSTOM_MODEL_DATA = CURRENT_VERSION >= V1_14;
6153

62-
/**
63-
* Check if the server has access to the Paper API
64-
* Taken from <a href="https://github.com/PaperMC/PaperLib">PaperLib</a>
65-
*
66-
* @return True if on Paper server (or forks), false anything else
67-
*/
68-
private static boolean checkPaper() {
69-
try {
70-
Class.forName("com.destroystokyo.paper.PaperConfig");
71-
return true;
72-
} catch (ClassNotFoundException ignored) {
73-
return false;
74-
}
75-
}
76-
7754
/**
7855
* Gets the current server version
7956
*
@@ -86,19 +63,10 @@ private static int getCurrentVersion() {
8663
if (matcher.find()) {
8764
String version = matcher.group(1).replace(".", "");
8865
String patch = matcher.group(2);
89-
patch = patch == null ? "0" : patch.replace(".", "");;
90-
return Integer.parseInt(version + patch);
66+
patch = patch == null ? "0" : patch.replace(".", "");
67+
return Integer.parseInt(version + patch, 10);
9168
}
9269

9370
throw new RuntimeException("Could not retrieve server version!");
9471
}
95-
96-
private static String getNmsVersion() {
97-
final String version = Bukkit.getServer().getClass().getPackage().getName();
98-
return version.substring(version.lastIndexOf('.') + 1);
99-
}
100-
101-
public static Class<?> craftClass(@NotNull final String name) throws ClassNotFoundException {
102-
return Class.forName("org.bukkit.craftbukkit." + NMS_VERSION + "." + name);
103-
}
10472
}

0 commit comments

Comments
 (0)