Class PositionPath

java.lang.Object
me.gamercoder215.mobchip.util.PositionPath

public final class PositionPath extends Object
Represents a Path, or a set of Position objects to get to a final destination.
  • Constructor Details

  • Method Details

    • getWorld

      @Nullable public @Nullable World getWorld()
      Fetches the world this Path takes place in.
      Returns:
      World this Path takes place in
    • getNextPositionIndex

      public int getNextPositionIndex()
      Fetches the index of the next position.
      Returns:
      Index of the next position
    • advance

      public Position advance() throws IllegalStateException
      Advances this Path to the next Position.
      Returns:
      Next Position
      Throws:
      IllegalStateException - if there are no more positions
    • addPosition

      public void addPosition(@NotNull @NotNull Position position) throws IllegalArgumentException
      Adds a position to the end of this Path.
      Parameters:
      position - Position to add
      Throws:
      IllegalArgumentException - if position is null
    • addPosition

      public void addPosition(@NotNull @NotNull Position position, int index) throws IllegalArgumentException
      Adds a position.
      Parameters:
      position - Position to add
      index - Index to add position at
      Throws:
      IllegalArgumentException - if position is null or index is negative
    • getEndPosition

      @Nullable public @Nullable Position getEndPosition()
      Fetches the Position at the end of the path, right before getTargetLocation().
      Returns:
      End Position
    • getPosition

      @Nullable public @Nullable Position getPosition(int index)
      Fetches the position at this Path's current index.
      Parameters:
      index - Index to get
      Returns:
      Position at index
    • getCurrentPosition

      @NotNull public @NotNull Position getCurrentPosition()
      Fetches the current position at this Path's current index.
      Returns:
      Current Position
    • getPositions

      @NotNull public @NotNull List<Position> getPositions()
      Fetches all the positions in this Path.
      Returns:
      Path Positions
    • getTargetLocation

      @NotNull public @NotNull Location getTargetLocation()
      Fetches the final target position for this Path.
      Returns:
      Target Position
    • isReached

      public boolean isReached()
      Whether this Path has reached its end position.
      Returns:
      true if reached, false otherwise
    • notStarted

      public boolean notStarted()
      Whether this Path has not started (getNextPositionIndex() is 0).
      Returns:
      true if not started, false otherwise