Package me.gamercoder215.mobchip.util
Class PositionPath
java.lang.Object
me.gamercoder215.mobchip.util.PositionPath
Represents a Path, or a set of
Position
objects to get to a final destination.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPosition
(@NotNull Position position) Adds a position to the end of this Path.void
addPosition
(@NotNull Position position, int index) Adds a position.advance()
Advances this Path to the next Position.Fetches the current position at this Path's current index.Fetches the Position at the end of the path, right beforegetTargetLocation()
.int
Fetches the index of the next position.getPosition
(int index) Fetches the position at this Path's current index.Fetches all the positions in this Path.Fetches the final target position for this Path.getWorld()
Fetches the world this Path takes place in.boolean
Whether this Path has reached its end position.boolean
Whether this Path has not started (getNextPositionIndex()
is 0).
-
Constructor Details
-
PositionPath
public PositionPath(@Nullable @Nullable Iterable<? extends Position> positions, @NotNull @NotNull Location targetLocation) throws IllegalArgumentException Creates a new Path.- Parameters:
positions
- The positions to get to the target position.targetLocation
- Final Target Position- Throws:
IllegalArgumentException
- if targetLocation is null
-
-
Method Details
-
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
Advances this Path to the next Position.- Returns:
- Next Position
- Throws:
IllegalStateException
- if there are no more positions
-
addPosition
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 addindex
- Index to add position at- Throws:
IllegalArgumentException
- if position is null or index is negative
-
getEndPosition
Fetches the Position at the end of the path, right beforegetTargetLocation()
.- Returns:
- End Position
-
getPosition
Fetches the position at this Path's current index.- Parameters:
index
- Index to get- Returns:
- Position at index
-
getCurrentPosition
Fetches the current position at this Path's current index.- Returns:
- Current Position
-
getPositions
Fetches all the positions in this Path.- Returns:
- Path Positions
-
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
-