Skip to content

Commit

Permalink
Fix potential cast exception on last pos check
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 committed Jan 15, 2025
1 parent 54c827c commit f9bcad0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public static class Incident {
private final Component name;
private final Party party;

private Location last;
private int currTick = 0;
private int lastPlace = 0;
private int glitchBlocks = 0;
Expand All @@ -159,7 +160,7 @@ public Incident(Player player, MatchPlayerState pl, Block initial) {
this.name = pl.getName();
this.party = pl.getParty();

this.queue.add(new MoveAction(player.getLocation()));
this.queue.add(new MoveAction(last = player.getLocation()));
placed(initial, true);
}

Expand All @@ -177,9 +178,9 @@ public void placed(Block block, boolean isGlitching) {

public boolean isOver() {
Location loc = player.getLocation();
if (!(queue.getLast() instanceof MoveAction move) || !move.to.equals(loc)) {
if (!last.equals(loc)) {
maxHeight = Math.max(maxHeight, loc.getY());
queue.add(new MoveAction(loc));
queue.add(new MoveAction(last = loc));
}
return loc.getY() < -64
|| currTick > MAX_LENGTH
Expand Down Expand Up @@ -211,7 +212,7 @@ public Location getStart() {
}

public Location getEnd() {
return ((MoveAction) queue.getLast()).to.clone();
return last.clone();
}

public Component getPlayerName() {
Expand Down

0 comments on commit f9bcad0

Please sign in to comment.