Class PositionPath
java.lang.Object
me.gamercoder215.mobchip.util.PositionPath
-
Constructor Summary
ConstructorsConstructorDescriptionPositionPath(@Nullable Iterable<? extends Position> positions, @NotNull Location targetLocation) Creates a new Path. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPosition(@NotNull Position position) Adds a position to the end of this Path.voidaddPosition(@NotNull Position position, int index) Adds a position.advance()Advances this Path to the next Position.@NotNull PositionFetches the current position at this Path's current index.@Nullable PositionFetches the Position at the end of the path, right beforegetTargetLocation().intFetches the index of the next position.@Nullable PositiongetPosition(int index) Fetches the position at this Path's current index.Fetches all the positions in this Path.@NotNull LocationFetches the final target position for this Path.@Nullable WorldgetWorld()Fetches the world this Path takes place in.booleanWhether this Path has reached its end position.booleanWhether 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
-
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
-