Class PlotId

java.lang.Object
com.plotsquared.core.plot.PlotId

public final class PlotId extends Object
The PlotId class represents a Plot's x and y coordinates within a PlotArea. PlotId x,y values do not correspond to Block locations. A PlotId instance can be created using the of(int, int) method or parsed from a string using the fromString(String) method.
  • Method Details

    • of

      public static @NonNull PlotId of(int x, int y)
      Returns a new PlotId instance with the specified x and y coordinates.
      Parameters:
      x - the x-coordinate of the plot
      y - the y-coordinate of the plot
      Returns:
      a new PlotId instance with the specified x and y coordinates
    • fromString

      public static @NonNull PlotId fromString(@NonNull String string)
      Get a Plot Id based on a string
      Parameters:
      string - to create id from
      Returns:
      the PlotId representation of the argument
      Throws:
      IllegalArgumentException - if the string does not contain a valid PlotId
    • fromStringOrNull

      Returns a PlotId object from the given string, or null if the string is invalid. The string should be in the format "x;y" where x and y are integers. The string can also contain any combination of the characters ";_,." as delimiters.
      Parameters:
      string - the string to parse
      Returns:
      a PlotId object parsed from the given string, or null if the string is invalid
    • unpair

      public static @NonNull PlotId unpair(int hash)
      Returns a new PlotId instance from the given hash.
      Parameters:
      hash - the hash to unpair
      Returns:
      a new PlotId instance
    • getX

      public int getX()
      Returns the x-coordinate of this Plot ID.
      Returns:
      the x-coordinate of this Plot ID
    • getY

      public int getY()
      Returns the y-coordinate of this Plot ID.
      Returns:
      the y-coordinate of this Plot ID
    • getNextId

      Returns the next Plot ID for claiming purposes based on the current Plot ID.
      Returns:
      the next Plot ID
    • getRelative

      Returns a new Plot ID in the specified relative direction based on the current Plot ID.
      Parameters:
      direction - the direction in which to get the relative Plot ID
      Returns:
      the relative Plot ID
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      Returns a string representation of this Plot ID in the format "x;y".

      The format is x + ";" + y

      Overrides:
      toString in class Object
      Returns:
      a string representation of this Plot ID
    • toSeparatedString

      Returns a string representation of this Plot ID with the specified separator.

      The format is x + separator + y

      Parameters:
      separator - the separator to use between the X and Y coordinates
      Returns:
      a string representation of this Plot ID with the specified separator
    • toCommaSeparatedString

      Returns a string representation of this Plot ID in the format "x,y".
      Returns:
      a string representation of this Plot ID
    • toUnderscoreSeparatedString

      Returns a string representation of this Plot ID in the format "x_y".
      Returns:
      a string representation of this Plot ID
    • toDashSeparatedString

      Returns a string representation of this Plot ID in the format "x-y".
      Returns:
      a string representation of this Plot ID
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object