Class ProtocolVersionRange

java.lang.Object
com.viaversion.viaversion.api.protocol.version.ProtocolVersionRange

public class ProtocolVersionRange extends Object
Wrapper class file for Range to support multiple ranges. This class is used to compare ProtocolVersion objects.
  • Method Details

    • all

      public static ProtocolVersionRange all()
      Returns a range that contains all versions. Adding new ranges to this range is not supported.
      Returns:
      the range
    • of

      Returns a range that contains only the given version.
      Parameters:
      min - the version
      max - the version
      Returns:
      the range
    • of

      public static ProtocolVersionRange of(com.google.common.collect.Range<ProtocolVersion> range)
      Returns a range that contains only the given version.
      Parameters:
      range - the version
      Returns:
      the range
    • of

      public static ProtocolVersionRange of(List<com.google.common.collect.Range<ProtocolVersion>> ranges)
      Returns a range that contains only the given version. The list can be immutable.
      Parameters:
      ranges - the version
      Returns:
      the range
    • singleton

      public static ProtocolVersionRange singleton(ProtocolVersion version)
      Returns a range that contains only the given version.
      Parameters:
      version - the version
      Returns:
      the range
    • andNewer

      public static ProtocolVersionRange andNewer(ProtocolVersion version)
      Returns a range that contains all versions equal to or newer than the given version.
      Parameters:
      version - the version
      Returns:
      the range
    • andOlder

      public static ProtocolVersionRange andOlder(ProtocolVersion version)
      Returns a range that contains all versions equal to or older than the given version.
      Parameters:
      version - the version
      Returns:
      the range
    • add

      public ProtocolVersionRange add(com.google.common.collect.Range<ProtocolVersion> range)
      Adds a new range to this range. This method is only available if the range is not already containing all versions.
      Parameters:
      range - the range to add
      Returns:
      this range
    • add

      Adds all ranges from the given range to this range. This method is only available if the range is not already containing all versions.
      Parameters:
      range - the range to add
      Returns:
      this range
    • contains

      public boolean contains(ProtocolVersion version)
      Checks if the given version is included in this range.
      Parameters:
      version - the version
      Returns:
      true if the version is included
    • getMin

      public @Nullable ProtocolVersion getMin()
      Gets the minimum version in this range. If there are multiple ranges, the lowest minimum is returned.
      Returns:
      the minimum version, or null if there is no minimum
    • getMax

      public @Nullable ProtocolVersion getMax()
      Gets the maximum version in this range. If there are multiple ranges, the highest maximum is returned.
      Returns:
      the maximum version, or null if there is no maximum
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • fromString

      public static ProtocolVersionRange fromString(String str)
      Parses a range from a string generated by toString().
      Parameters:
      str - the string
      Returns:
      the range