Skip to content

Commit 8814d11

Browse files
committed
Add null checks
1 parent 6f76acd commit 8814d11

File tree

1 file changed

+6
-3
lines changed
  • src/main/java/br/com/pinter/tqrespec/save/player

1 file changed

+6
-3
lines changed

src/main/java/br/com/pinter/tqrespec/save/player/Player.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -906,13 +906,16 @@ public void removeTeleport(int difficulty, UID uid) {
906906
TeleportDifficulty teleportDifficulty = getTeleportUidFromDifficulty(difficulty);
907907

908908
if (teleportDifficulty == null) {
909-
throw new UnhandledRuntimeException("error creating teleport");
909+
throw new UnhandledRuntimeException("error removing teleport");
910910
}
911911

912912
VariableInfo uidsSize = getTeleportUIDsSizeVar(difficulty);
913913

914914
List<VariableInfo> toRemove = new ArrayList<>();
915915
for (VariableInfo stagingVar : teleportDifficulty.getBlockInfo().getStagingVariables().values()) {
916+
if(stagingVar == null) {
917+
continue;
918+
}
916919
if (stagingVar.getVariableType().equals(VariableType.UID) && stagingVar.getName().equals(Constants.Save.VAR_TELEPORTUID)) {
917920
UID uidTp;
918921
try {
@@ -1059,8 +1062,8 @@ private TeleportDifficulty getTeleportUidFromDifficulty(int difficulty) {
10591062

10601063
//search for teleports pending save
10611064
for (VariableInfo v : block.getStagingVariables().get(Constants.Save.VAR_TELEPORTUID)
1062-
.stream().sorted(Comparator.comparing(VariableInfo::getKeyOffset)).toList()) {
1063-
if (v.getKeyOffset() >= startOffset && v.getKeyOffset() <= endOffset) {
1065+
.stream().sorted(Comparator.comparing(variableInfo -> variableInfo != null ? variableInfo.getKeyOffset() : 0)).toList()) {
1066+
if (v != null && v.getKeyOffset() >= startOffset && v.getKeyOffset() <= endOffset) {
10641067
teleports.add(v);
10651068
}
10661069
}

0 commit comments

Comments
 (0)