summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-12-30 14:24:46 -0500
committerBenji Dial <benji@benjidial.net>2023-12-30 14:24:46 -0500
commite06ee55259b3549a59358a13c095a274bacf6a05 (patch)
treea6e8b1b33434ee2c7de7028d4abad77b7fbe8296 /src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
parentef65431d405a713b138a55054e78497883f27e54 (diff)
downloadnew-simple-waypoints-e06ee55259b3549a59358a13c095a274bacf6a05.tar.gz
testing new version
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/ListWaypoints.java')
-rw-r--r--src/main/java/net/benjidial/nswp/commands/ListWaypoints.java42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java b/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
index b6b61a3..336a07b 100644
--- a/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
+++ b/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
@@ -4,36 +4,40 @@ import net.benjidial.nswp.Database;
import net.benjidial.nswp.Waypoint;
import org.bukkit.entity.Player;
-import org.bukkit.World;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.List;
-public class ListWaypoints extends WaypointCommand {
- public CompletionType getCompletionType() {
- return CompletionType.Waypoint;
+public class ListWaypoints extends PlayerCommand {
+
+ public List<String> getTabCompletions(Player sender, String[] args) throws SQLException {
+ return searchWaypointsByArg(sender, args, 0);
}
- public boolean body(Player player, String[] args) throws SQLException {
+ public boolean doCommand(Player sender, String[] args) throws SQLException {
+
if (args.length > 1)
return false;
- ArrayList<Waypoint> waypoints = Database.searchWaypoints(player, args.length == 0 ? "" : args[0]);
- if (waypoints.size() == 0) {
- player.sendMessage("No waypoints found.");
+
+ Database.createWaypointTable(sender);
+ ArrayList<Waypoint> wps = Database.searchWaypoints(sender, args.length == 0 ? "" : args[0]);
+
+ if (wps.size() == 0) {
+ sender.sendMessage("0 waypoints found.");
return true;
}
- if (waypoints.size() == 1)
- player.sendMessage("1 waypoint found:");
+
+ if (wps.size() == 1)
+ sender.sendMessage("1 waypoint found:");
else
- player.sendMessage(waypoints.size() + " waypoints found:");
- World lastWorld = null;
- for (Waypoint waypoint : waypoints) {
- if (waypoint.location.getWorld() != lastWorld) {
- lastWorld = waypoint.location.getWorld();
- player.sendMessage(" " + lastWorld.getName() + ": ");
- }
- player.sendMessage(" " + waypoint.name);
- }
+ sender.sendMessage(wps.size() + " waypoints found:");
+
+ for (Waypoint wp : wps)
+ sender.sendMessage(" " + wp.toString());
+
return true;
+
}
+
}