Skip to content

Commit ca7a44b

Browse files
committed
Add search coords command
1 parent eea55c8 commit ca7a44b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package me.ricglz.discoords.commands;
2+
3+
import me.ricglz.discoords.Coordinates;
4+
import me.ricglz.discoords.exceptions.InvalidAmountOfArgumentsException;
5+
6+
import org.bukkit.Location;
7+
import org.bukkit.command.Command;
8+
import org.bukkit.entity.Player;
9+
10+
public class CommandSearchCoords extends GeneralCommand {
11+
@Override
12+
public void run(Player sender, Command command, String label, String[] args) throws Exception {
13+
if (args.length == 0) {
14+
throw new InvalidAmountOfArgumentsException();
15+
}
16+
final Coordinates coords = discoords.getCoordinates();
17+
Location loc = coords.getCoordinates(args[0]);
18+
String locString = String.format("(%d, %d, %d)", (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
19+
sender.sendMessage(String.format("%s - %s", args[0], locString));
20+
}
21+
}

src/main/resources/plugin.yml

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ commands:
1616
save-coords:
1717
description: Save your current coordinates to everyone to see it
1818
usage: /<command> <label>
19+
search-coords:
20+
description: Search to see the current coordinates saved based on a label
21+
usage: /<command> <label>
1922

2023
permissions:
2124
discoords.*:

0 commit comments

Comments
 (0)