From e06ee55259b3549a59358a13c095a274bacf6a05 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 30 Dec 2023 14:24:46 -0500 Subject: testing new version --- .../net/benjidial/nswp/commands/ListWaypoints.java | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src/main/java/net/benjidial/nswp/commands/ListWaypoints.java') 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 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 waypoints = Database.searchWaypoints(player, args.length == 0 ? "" : args[0]); - if (waypoints.size() == 0) { - player.sendMessage("No waypoints found."); + + Database.createWaypointTable(sender); + ArrayList 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; + } + } -- cgit v1.2.3