// Path: src/main/java/ru/endlesscode/rpginventory/utils/Version.java
// public final class Version implements Comparable<Version> {
// 
//     private final int major;
//     private final int minor;
//     private final int patch;
//     private final String qualifier;
// 
//     /**
//      * Constructs Version object from the given data according to semantic versioning.
//      *
//      * @param major Major version.
//      * @param minor Minor version.
//      * @param patch Patch version.
//      */
//     public Version(int major, int minor, int patch) {
//         this(major, minor, patch, "");
//     }
// 
//     /**
//      * Constructs Version object from the given data according to semantic versioning.
//      *
//      * @param major     Major version.
//      * @param minor     Minor version.
//      * @param patch     Patch version.
//      * @param qualifier Qualifier, or empty string if qualifier not exists.
//      * @throws IllegalArgumentException when passed negative version codes.
//      */
//     public Version(int major, int minor, int patch, @NotNull String qualifier) {
//         if (major < 0 || minor < 0 || patch < 0) {
//             throw new IllegalArgumentException("Version can't include negative numbers");
//         }
// 
//         this.major = major;
//         this.minor = minor;
//         this.patch = patch;
//         this.qualifier = Objects.requireNonNull(qualifier, "'qualifier' shouldn't be null");
//     }
// 
//     /**
//      * Parses version from the given string.
//      *
//      * @param version String representation of version.
//      * @return The constructed version.
//      * @throws IllegalArgumentException If passed string with wrong format.
//      */
//     @NotNull
//     public static Version parseVersion(@NotNull String version) {
//         String[] parts = version.split("-", 2);
//         String qualifier = (parts.length > 1) ? parts[1] : "";
//         parts = parts[0].split("\\.", 3);
// 
//         try {
//             int patch = (parts.length > 2) ? Integer.parseInt(parts[2]) : 0;
//             int minor = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
//             int major = Integer.parseInt(parts[0]);
// 
//             return new Version(major, minor, patch, qualifier);
//         } catch (NumberFormatException e) {
//             throw new IllegalArgumentException(String.format("Can not parse version string: %s", version), e);
//         }
//     }
// 
//     public int compareTo(String version) {
//         return this.compareTo(Version.parseVersion(version));
//     }
// 
//     @Override
//     public int compareTo(@NotNull Version o) {
//         int result;
//         if ((result = Integer.compare(major, o.major)) != 0
//                 || (result = Integer.compare(minor, o.minor)) != 0
//                 || (result = Integer.compare(patch, o.patch)) != 0) {
//             // TODO: Maybe compare also qualifiers
//             return result;
//         }
// 
//         return 0;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o || o == null || getClass() != o.getClass()) {
//             return true;
//         }
// 
//         Version version = (Version) o;
//         return major == version.major
//                 && minor == version.minor
//                 && patch == version.patch
//                 && Objects.equals(qualifier, version.qualifier);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(major, minor, patch, qualifier);
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("%d.%d.%d%s", major, minor, patch, qualifier.isEmpty() ? "" : "-" + qualifier);
//     }
// 
//     public int getMajor() {
//         return major;
//     }
// 
//     public int getMinor() {
//         return minor;
//     }
// 
//     public int getPatch() {
//         return patch;
//     }
// 
//     @NotNull
//     public String getQualifier() {
//         return qualifier;
//     }
// 
//     /**
//      * Returns version code in format xxyyzz, where x - major version, y - minor and z - patch.
//      * Example:
//      *   1.12.2  ->  11202
//      *   21.0.12 -> 210012
//      *   1.9     ->  10900
//      *   2.2.1   ->  20201
//      * Major, minor and patch versions shouldn't be higher than 99.
//      */
//     public int getVersionCode() {
//         return major * 10000 + minor * 100 + patch;
//     }
// 
//     /**
//      * Checks that version has qualifier.
//      *
//      * @return true if version contains qualifier, otherwise false.
//      */
//     public boolean hasQualifier() {
//         return !qualifier.isEmpty();
//     }
// }


import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import ru.endlesscode.rpginventory.utils.Version;
import java.util.regex.Matcher;
    public static final int VERSION_1_18 = 1_18_00;

    private static final Pattern pattern = Pattern.compile("(?<version>\\d\\.\\d{1,2}(\\.\\d)?)-.*");

    private static int versionCode = -1;

    public static boolean isNotSupportedVersion() {
        return getVersionCode() < VERSION_1_14 || getVersionCode() >= VERSION_1_18;
    }

    public static boolean isExperimentalSupport() {
        return getVersionCode() == VERSION_1_17;
    }

    public static boolean isLegacy() {
        return getVersionCode() < VERSION_1_13;
    }

    public static int getVersionCode() {
        if (versionCode == -1) {
            initVersionCode();
        }

        return versionCode;
    }

    private static void initVersionCode() {
        Matcher matcher = pattern.matcher(Bukkit.getBukkitVersion());
        if (matcher.find()) {
            String versionString = matcher.group("version");
// Path: src/main/java/ru/endlesscode/rpginventory/utils/Version.java
// public final class Version implements Comparable<Version> {
// 
//     private final int major;
//     private final int minor;
//     private final int patch;
//     private final String qualifier;
// 
//     /**
//      * Constructs Version object from the given data according to semantic versioning.
//      *
//      * @param major Major version.
//      * @param minor Minor version.
//      * @param patch Patch version.
//      */
//     public Version(int major, int minor, int patch) {
//         this(major, minor, patch, "");
//     }
// 
//     /**
//      * Constructs Version object from the given data according to semantic versioning.
//      *
//      * @param major     Major version.
//      * @param minor     Minor version.
//      * @param patch     Patch version.
//      * @param qualifier Qualifier, or empty string if qualifier not exists.
//      * @throws IllegalArgumentException when passed negative version codes.
//      */
//     public Version(int major, int minor, int patch, @NotNull String qualifier) {
//         if (major < 0 || minor < 0 || patch < 0) {
//             throw new IllegalArgumentException("Version can't include negative numbers");
//         }
// 
//         this.major = major;
//         this.minor = minor;
//         this.patch = patch;
//         this.qualifier = Objects.requireNonNull(qualifier, "'qualifier' shouldn't be null");
//     }
// 
//     /**
//      * Parses version from the given string.
//      *
//      * @param version String representation of version.
//      * @return The constructed version.
//      * @throws IllegalArgumentException If passed string with wrong format.
//      */
//     @NotNull
//     public static Version parseVersion(@NotNull String version) {
//         String[] parts = version.split("-", 2);
//         String qualifier = (parts.length > 1) ? parts[1] : "";
//         parts = parts[0].split("\\.", 3);
// 
//         try {
//             int patch = (parts.length > 2) ? Integer.parseInt(parts[2]) : 0;
//             int minor = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0;
//             int major = Integer.parseInt(parts[0]);
// 
//             return new Version(major, minor, patch, qualifier);
//         } catch (NumberFormatException e) {
//             throw new IllegalArgumentException(String.format("Can not parse version string: %s", version), e);
//         }
//     }
// 
//     public int compareTo(String version) {
//         return this.compareTo(Version.parseVersion(version));
//     }
// 
//     @Override
//     public int compareTo(@NotNull Version o) {
//         int result;
//         if ((result = Integer.compare(major, o.major)) != 0
//                 || (result = Integer.compare(minor, o.minor)) != 0
//                 || (result = Integer.compare(patch, o.patch)) != 0) {
//             // TODO: Maybe compare also qualifiers
//             return result;
//         }
// 
//         return 0;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o || o == null || getClass() != o.getClass()) {
//             return true;
//         }
// 
//         Version version = (Version) o;
//         return major == version.major
//                 && minor == version.minor
//                 && patch == version.patch
//                 && Objects.equals(qualifier, version.qualifier);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(major, minor, patch, qualifier);
//     }
// 
//     @Override
//     public String toString() {
//         return String.format("%d.%d.%d%s", major, minor, patch, qualifier.isEmpty() ? "" : "-" + qualifier);
//     }
// 
//     public int getMajor() {
//         return major;
//     }
// 
//     public int getMinor() {
//         return minor;
//     }
// 
//     public int getPatch() {
//         return patch;
//     }
// 
//     @NotNull
//     public String getQualifier() {
//         return qualifier;
//     }
// 
//     /**
//      * Returns version code in format xxyyzz, where x - major version, y - minor and z - patch.
//      * Example:
//      *   1.12.2  ->  11202
//      *   21.0.12 -> 210012
//      *   1.9     ->  10900
//      *   2.2.1   ->  20201
//      * Major, minor and patch versions shouldn't be higher than 99.
//      */
//     public int getVersionCode() {
//         return major * 10000 + minor * 100 + patch;
//     }
// 
//     /**
//      * Checks that version has qualifier.
//      *
//      * @return true if version contains qualifier, otherwise false.
//      */
//     public boolean hasQualifier() {
//         return !qualifier.isEmpty();
//     }
// }


// Path: src/main/java/ru/endlesscode/rpginventory/compat/VersionHandler.java
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import ru.endlesscode.rpginventory.utils.Version;
import java.util.regex.Matcher;

    public static final int VERSION_1_18 = 1_18_00;

    private static final Pattern pattern = Pattern.compile("(?<version>\\d\\.\\d{1,2}(\\.\\d)?)-.*");

    private static int versionCode = -1;

    public static boolean isNotSupportedVersion() {
        return getVersionCode() < VERSION_1_14 || getVersionCode() >= VERSION_1_18;
    }

    public static boolean isExperimentalSupport() {
        return getVersionCode() == VERSION_1_17;
    }

    public static boolean isLegacy() {
        return getVersionCode() < VERSION_1_13;
    }

    public static int getVersionCode() {
        if (versionCode == -1) {
            initVersionCode();
        }

        return versionCode;
    }

    private static void initVersionCode() {
        Matcher matcher = pattern.matcher(Bukkit.getBukkitVersion());
        if (matcher.find()) {
            String versionString = matcher.group("version");
            versionCode = Version.parseVersion(versionString).getVersionCode();