From c74bd5633e2011f1a9cd410fd3e86ac510f05c1d Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 5 Aug 2012 01:31:45 -0400 Subject: [PATCH] Handle wrong version string length gracefully --- .../java/net/h31ix/anticheat/Anticheat.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index fb23cf5..5c43b5f 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -209,24 +209,27 @@ public class Anticheat extends JavaPlugin logger.log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile"); } } - String v = this.getServer().getVersion().split("-")[6]; - if(v.contains("jnks")) - { - v = v.replaceAll("b", "").replaceAll("jnks", "").split(" ")[0]; - int build = 0; - try + try + { + if(this.getServer().getVersion().split("-").length >= 7) { - build = Integer.parseInt(v); - } - catch(Exception ex){ } - if(build != 0 && build < 2287) - { - System.out.println("[WARNING] You are using an UNSUPPORTED version of CraftBukkit that does not contain the API required to run AntiCheat."); - System.out.println("[WARNING] Please update your server to be build #2287 or higher at http://dl.bukkit.org/downloads/craftbukkit/"); - System.out.println("[WARNING] AntiCheat will now disable itself, and your server will not be protected until you update."); - getServer().getPluginManager().disablePlugin(this); + String v = this.getServer().getVersion().split("-")[6]; + if(v.contains("jnks")) + { + v = v.replaceAll("b", "").replaceAll("jnks", "").split(" ")[0]; + int build = 0; + build = Integer.parseInt(v); + if(build != 0 && build < 2287) + { + System.out.println("[WARNING] You are using an UNSUPPORTED version of CraftBukkit that does not contain the API required to run AntiCheat."); + System.out.println("[WARNING] Please update your server to be build #2287 or higher at http://dl.bukkit.org/downloads/craftbukkit/"); + System.out.println("[WARNING] AntiCheat will now disable itself, and your server will not be protected until you update."); + getServer().getPluginManager().disablePlugin(this); + } + } } - } + } + catch(Exception ex){ } if (verbose) { logger.log(Level.INFO, "Finished loading.");