9
9
import java .util .regex .Pattern ;
10
10
import java .util .regex .Matcher ;
11
11
12
- public class VersionHelper {
13
- private static final String NMS_VERSION = getNmsVersion ();
12
+ // changed
14
13
14
+ public class VersionHelper {
15
15
// Unbreakable change
16
16
private static final int V1_11 = 1110 ;
17
17
// Material and components on items change
@@ -25,14 +25,6 @@ public class VersionHelper {
25
25
26
26
private static final int CURRENT_VERSION = getCurrentVersion ();
27
27
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
-
36
28
/**
37
29
* Checks if the version is lower than 1.13 due to the item changes
38
30
*/
@@ -59,21 +51,6 @@ public class VersionHelper {
59
51
*/
60
52
public static final boolean IS_CUSTOM_MODEL_DATA = CURRENT_VERSION >= V1_14 ;
61
53
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
-
77
54
/**
78
55
* Gets the current server version
79
56
*
@@ -86,19 +63,10 @@ private static int getCurrentVersion() {
86
63
if (matcher .find ()) {
87
64
String version = matcher .group (1 ).replace ("." , "" );
88
65
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 );
91
68
}
92
69
93
70
throw new RuntimeException ("Could not retrieve server version!" );
94
71
}
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
- }
104
72
}
0 commit comments