java.lang.Object
com.fren_gor.ultimateAdvancementAPI.util.Versions

public class Versions extends Object
Utility class for handling UltimateAdvancementAPI versions.
  • Method Details

    • getNMSVersion

      @NotNull public static @NotNull Optional<String> getNMSVersion()
      Gets the NMS version of the current server.

      This returns a Optional<String> like "v1_15_R1". To remove initial 'v' see removeInitialV(String).

      Returns:
      The server NMS version.
    • getApiVersion

      public static String getApiVersion()
      Gets current API version.
      Returns:
      The API version.
    • getSupportedVersions

      @NotNull public static @UnmodifiableView @NotNull List<@NotNull String> getSupportedVersions()
      Gets an unmodifiable list of minecraft versions supported by this release of UltimateAdvancementAPI.

      Returned versions are like "1.15" or "1.15.2".

      Returns:
      An unmodifiable list of minecraft versions supported by this release of UltimateAdvancementAPI.
    • getSupportedNMSVersions

      @NotNull public static @UnmodifiableView @NotNull List<@NotNull String> getSupportedNMSVersions()
      Gets an unmodifiable list of NMS versions supported by this release of UltimateAdvancementAPI.

      Returned versions are like "v1_15_R1".

      Returns:
      An unmodifiable list of minecraft versions supported by this release of UltimateAdvancementAPI.
    • getNMSVersionsRange

      @Nullable public static @Nullable String getNMSVersionsRange()
      Gets the minecraft versions supported by this server NMS version.

      For example, for "v1_15_R1" this method returns "1.15-1.15.2".

      Returns:
      The minecraft versions supported by this server NMS version, or null if the server version is not supported (see getSupportedNMSVersions()).
    • getNMSVersionsRange

      @Nullable @Contract("null -> null") public static @Nullable String getNMSVersionsRange(String version)
      Gets the minecraft versions supported by the provided NMS version.

      For example, for "v1_15_R1" this method returns "1.15-1.15.2".

      Parameters:
      version - The NMS version.
      Returns:
      The minecraft versions supported by the provided NMS version, or null if the provided version is not supported (see getSupportedNMSVersions()).
    • getNMSVersionsList

      @Nullable public static @UnmodifiableView @Nullable List<@NotNull String> getNMSVersionsList()
      Gets an unmodifiable list of the minecraft versions supported by this server NMS version.

      For example, for "v1_15_R1" this method returns a list containing "1.15", "1.15.1", and "1.15.2".

      Returns:
      An unmodifiable list of the minecraft versions supported by this server NMS version, or null if the server version is not supported (see getSupportedNMSVersions()).
    • getNMSVersionsList

      @Nullable @Contract("null -> null") public static @UnmodifiableView @Nullable List<@NotNull String> getNMSVersionsList(String version)
      Gets an unmodifiable list of the minecraft versions supported by the provided NMS version.

      For example, for "v1_15_R1" this method returns a list containing "1.15", "1.15.1", and "1.15.2".

      Parameters:
      version - The NMS version.
      Returns:
      An unmodifiable list of the minecraft versions supported by the provided NMS version, or null if the provided version is not supported (see getSupportedNMSVersions()).
    • removeInitialV

      @Contract("null -> null; !null -> !null") public static String removeInitialV(String string)
      Returns the input string unless it starts with 'v'. In that case, this method returns the string without the first letter. If null, this method returns null.

      Examples:

       removeInitialV("v1_15_R1") returns "1_15_R1"
       removeInitialV("1_15_R1") returns "1_15_R1"
       removeInitialV("") returns ""
       removeInitialV("vv1_15_R1") returns "v1_15_R1"
       removeInitialV(null) returns null
       
      Parameters:
      string - The input string
      Returns:
      null if the string is null, the string itself if the first character isn't 'v', otherwise the string without the first character.