Skip to content

Commit cf97e37

Browse files
committed
Add try/catch to java version check
1 parent 1629334 commit cf97e37

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main/java/net/tcpshield/tcpshield/TCPShieldPlugin.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,28 @@ public interface TCPShieldPlugin {
1212

1313
/**
1414
* Gets the plugin's config provider
15+
*
1516
* @return The plugin's config provider
1617
*/
1718
ConfigProvider getConfigProvider();
1819

1920
/**
2021
* Gets the plugin's logger
22+
*
2123
* @return The plugin's logger
2224
*/
2325
Logger getLogger();
2426

2527
/**
2628
* Gets the packet handler
29+
*
2730
* @return The packet handler
2831
*/
2932
TCPShieldPacketHandler getPacketHandler();
3033

3134
/**
3235
* Gets the plugin's debugger
36+
*
3337
* @return The plugin's debugger
3438
*/
3539
Debugger getDebugger();
@@ -40,12 +44,15 @@ public interface TCPShieldPlugin {
4044
*/
4145
default void initialization() {
4246
String jvmVersion = System.getProperty("java.version");
43-
44-
// Java 11 check/warning (Will eventually force Java 16 without warning)
45-
String[] versionParts = jvmVersion.split("\\.");
46-
int baseVersion = Integer.parseInt(versionParts[0]);
47-
if (baseVersion < 11) // Java 8, and below, starts with 1, but since we are using Java 11 we can ignore sub values
48-
this.getDebugger().warn("The Java version you are running is outdated for TCPShield and may cause issues. Update to atleast Java 11. Your version: Java %s", jvmVersion);
47+
try {
48+
// Java 11 check/warning (Will eventually force Java 16 without warning)
49+
String[] versionParts = jvmVersion.split("\\.");
50+
int baseVersion = Integer.parseInt(versionParts[0]);
51+
if (baseVersion < 11) // Java 8, and below, starts with 1, but since we are using Java 11 we can ignore sub values
52+
this.getDebugger().warn("The Java version you are running is outdated for TCPShield and may cause issues. Update to atleast Java 11. Your version: Java %s", jvmVersion);
53+
} catch (Throwable t) {
54+
this.getDebugger().error("Failed to check java version for string: " + jvmVersion);
55+
}
4956
}
5057

5158
}

0 commit comments

Comments
 (0)