package net.wesjd.anvilgui.version;

import org.bukkit.Bukkit;

import java.util.Arrays;
import java.util.List;

/**
 * Matches the server's NMS version to its {@link VersionWrapper}
 *
 * @author Wesley Smith
 * @since 1.2.1
 */
public class VersionMatcher {

    /**
     * The server's version
     */
    private final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].substring(1);

    /**
     * Matches the server version to it's {@link VersionWrapper}
     *
     * @return The {@link VersionWrapper} for this server
     * @throws RuntimeException If AnvilGUI doesn't support this server version
     */
    public VersionWrapper match() {
        try {
            return (VersionWrapper) Class.forName(this.getClass().getPackage().getName() + ".Wrapper" + serverVersion).newInstance();
        } catch (IllegalAccessException | InstantiationException ex) {
            throw new RuntimeException(ex);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("Your server version isn't supported in AnvilGUI!");
        }
    }

}

@@ -61,57 +61,8 @@
 t;%0A%0A
-import java.util.Arrays;%0Aimport java.util.List;%0A%0A
 /**%0A
@@ -209,177 +209,8 @@
  %7B%0A%0A
-    /**%0A     * The server's version%0A     */%0A    private final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split(%22%5C%5C.%22)%5B3%5D.substring(1);%0A%0A
     
@@ -358,22 +358,27 @@
 @throws 
-Runtim
+IllegalStat
 eExcepti
@@ -387,96 +387,242 @@
  If 
-AnvilGUI doesn't support this server version%0A     */%0A    public VersionWrapper match() %7B
+the version wrapper failed to be instantiated or is unable to be found%0A     */%0A    public VersionWrapper match() %7B%0A        final String serverVersion = Bukkit.getServer().getClass().getPackage().getName().split(%22%5C%5C.%22)%5B3%5D.substring(1);
 %0A   
@@ -686,13 +686,8 @@
 ame(
-this.
 getC
@@ -828,16 +828,23 @@
 ption ex
+ception
 ) %7B%0A    
@@ -865,27 +865,109 @@
 new 
-RuntimeException(ex
+IllegalStateException(%22Failed to instantiate version wrapper for version %22 + serverVersion, exception
 );%0A 
@@ -1006,16 +1006,24 @@
 eption e
+xception
 ) %7B%0A    
@@ -1044,14 +1044,19 @@
 new 
-Runtim
+IllegalStat
 eExc
@@ -1067,57 +1067,86 @@
 on(%22
-Your server version isn't supported in AnvilGUI!%22
+AnvilGUI does not support server version %5C%22%22 + serverVersion + %22%5C%22%22, exception
 );%0A 

make serverVersion local variable, improve exceptions and exception messages