Skip to content

Commit

Permalink
update(tpll): Added proper error handling incase the coordinates give…
Browse files Browse the repository at this point in the history
…n are invalid. (#25)
  • Loading branch information
kyanvde authored Aug 20, 2024
1 parent 454cc70 commit 354b346
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ public void execute(@NotNull CommandSourceStack stack, @NotNull String[] args) {
double maxLon = Terraplusminus.config.getDouble("max_longitude");

double[] coordinates = new double[2];
coordinates[1] = Double.parseDouble(args[0].replace(",", "").replace("°", ""));
coordinates[0] = Double.parseDouble(args[1].replace("°", ""));
try {
coordinates[1] = Double.parseDouble(args[0].replace(",", "").replace("°", ""));
coordinates[0] = Double.parseDouble(args[1].replace("°", ""));
} catch (NumberFormatException e) {
stack.getSender().sendMessage(RED + "Invalid coordinates or command usage!");
stack.getSender().sendMessage(RED + "Proper usage: /tpll <latitude> <longitude> [height (optional]");
return;
}

ChunkGenerator generator = tpWorld.getGenerator();
if (!(generator instanceof RealWorldGenerator)) { // after server reload the generator isnt instanceof RealWorldGenerator anymore
Expand Down

0 comments on commit 354b346

Please sign in to comment.