Skip to content

Commit bf7d2b5

Browse files
authored
Merge pull request #277 from Gardelll/main
Clone new location when find new teleport location
2 parents 13086f4 + c82c52a commit bf7d2b5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/com/onarandombox/MultiverseNetherPortals/utils/MVLinkChecker.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ public Location findNewTeleportLocation(Location fromLocation, String worldStrin
3434
double fromScaling = this.worldManager.getMVWorld(fromLocation.getWorld().getName()).getScaling();
3535
double toScaling = tpTo.getScaling();
3636

37-
this.scaleLocation(fromLocation, fromScaling / toScaling);
38-
fromLocation.setWorld(tpTo.getCBWorld());
39-
return fromLocation;
37+
// Clone new location to avoid affecting the original location
38+
Location newTargetLocation = fromLocation.clone();
39+
this.scaleLocation(newTargetLocation, fromScaling / toScaling);
40+
newTargetLocation.setWorld(tpTo.getCBWorld());
41+
return newTargetLocation;
4042
}
4143

4244
return null;
4345
}
4446

45-
private void scaleLocation(Location fromLocation, double scaling) {
46-
fromLocation.setX(fromLocation.getX() * scaling);
47-
fromLocation.setZ(fromLocation.getZ() * scaling);
47+
private void scaleLocation(Location newTargetLocation, double scaling) {
48+
newTargetLocation.setX(newTargetLocation.getX() * scaling);
49+
newTargetLocation.setZ(newTargetLocation.getZ() * scaling);
4850
}
4951
}

0 commit comments

Comments
 (0)