diff options
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/ListWaypoints.java')
-rw-r--r-- | src/main/java/net/benjidial/nswp/commands/ListWaypoints.java | 42 |
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; + } + } |