mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-23 01:27:33 +01:00
Fix some off-by-one errors
This commit is contained in:
parent
0b1a8cc369
commit
37e6414b13
@ -779,7 +779,7 @@ public class NPCCommands {
|
||||
throw new CommandException(Messages.HOLOGRAM_INVALID_LINE);
|
||||
}
|
||||
int idx = Math.max(0, args.getInteger(2));
|
||||
if (idx > trait.getLines().size()) {
|
||||
if (idx >= trait.getLines().size()) {
|
||||
throw new CommandException(Messages.HOLOGRAM_INVALID_LINE);
|
||||
}
|
||||
trait.removeLine(idx);
|
||||
|
@ -234,10 +234,10 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
|
||||
return selectedWaypoint == null ? waypoints.get(waypoints.size() - 1) : selectedWaypoint;
|
||||
}
|
||||
|
||||
private Location getPreviousWaypoint() {
|
||||
private Location getLastWaypoint() {
|
||||
if (waypoints.size() <= 1)
|
||||
return null;
|
||||
return waypoints.get(waypoints.size() - 2).getLocation();
|
||||
return waypoints.get(waypoints.size() - 1).getLocation();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -312,7 +312,7 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider {
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
Location at = event.getClickedBlock().getLocation();
|
||||
Location prev = getPreviousWaypoint();
|
||||
Location prev = getLastWaypoint();
|
||||
|
||||
if (prev != null && prev.getWorld() == at.getWorld()) {
|
||||
double distance = at.distance(prev);
|
||||
|
Loading…
Reference in New Issue
Block a user