Skip to content

Commit

Permalink
add location info to message if setloselevel fails
Browse files Browse the repository at this point in the history
  • Loading branch information
steve4744 committed Jan 7, 2022
1 parent 523c8f5 commit 5455b57
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/java/tntrun/commands/setup/arena/SetLoseLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package tntrun.commands.setup.arena;

import java.text.DecimalFormat;
import java.util.StringJoiner;

import org.bukkit.Location;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -51,13 +54,21 @@ public boolean handleCommand(Player player, String[] args) {

Location loc = player.getLocation();
if (arena.getStructureManager().setLoseLevel(loc)) {
Messages.sendMessage(player, "&7 Arena &6" + args[0] + "&7 Loselevel set to Y: " + loc.getY());
Messages.sendMessage(player, "&7 Arena &6" + args[0] + "&7 loselevel set:\n&6Y = " + loc.getY());
} else {
Messages.sendMessage(player, "&c Arena &6" + args[0] + "&c Error: Loselevel is not within the bounds of the arena");
Messages.sendMessage(player, "&c Arena &6" + args[0] + "&c error: loselevel (&6" + displayLocation(loc) + "&c) is not within the bounds of the arena:\n" +
"P1 = &6" + arena.getStructureManager().getP1() + "\n&cP2 = &6" + arena.getStructureManager().getP2());
}
return true;
}

private String displayLocation(Location loc) {
StringJoiner msg = new StringJoiner(", ");
DecimalFormat df = new DecimalFormat("#.#");
msg.add(df.format(loc.getX())).add(df.format(loc.getY())).add(df.format(loc.getZ()));
return msg.toString();
}

@Override
public int getMinArgsLength() {
return 1;
Expand Down

0 comments on commit 5455b57

Please sign in to comment.