-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/ac/grim/grimac/manager/init/start/JavaVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ac.grim.grimac.manager.init.start; | ||
|
||
import ac.grim.grimac.manager.init.Initable; | ||
import ac.grim.grimac.utils.anticheat.LogUtil; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class JavaVersion implements Initable { | ||
|
||
@Override | ||
public void start() { | ||
// Stolen from Via, stolen from Paper | ||
String javaVersion = System.getProperty("java.version"); | ||
Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion); | ||
if (!matcher.find()) { | ||
LogUtil.error("Failed to determine Java version; could not parse: " + javaVersion); | ||
return; | ||
} | ||
|
||
String versionString = matcher.group(1); | ||
int version; | ||
try { | ||
version = Integer.parseInt(versionString); | ||
} catch (NumberFormatException e) { | ||
LogUtil.error("Failed to determine Java version; could not parse: " + versionString); | ||
e.printStackTrace(); | ||
return; | ||
} | ||
|
||
if (version < 17) { | ||
LogUtil.warn("You are running an outdated Java version, please update it to at least Java 17 (your version is " + javaVersion + ")."); | ||
LogUtil.warn("GrimAC will no longer support this version of Java in a future release."); | ||
LogUtil.warn("See https://github.com/GrimAnticheat/Grim/wiki/Updating-to-Java-17 for more information."); | ||
} | ||
} | ||
} |