diff options
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java')
-rw-r--r-- | src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java b/src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java index 4e84e3c..71b2ad3 100644 --- a/src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java +++ b/src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java @@ -6,22 +6,31 @@ import net.benjidial.nswp.Waypoint; import org.bukkit.entity.Player; import java.sql.SQLException; +import java.util.List; -public class TeleportToWaypoint extends WaypointCommand { - public CompletionType getCompletionType() { - return CompletionType.Waypoint; +public class TeleportToWaypoint 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; - Waypoint waypoint = Database.lookupWaypoint(player, args[0]); - if (waypoint == null) - player.sendMessage("No waypoint with that name."); - else { - Database.setWBack(player, player.getLocation()); - player.teleport(waypoint.location); + + Database.createWaypointTable(sender); + + Waypoint wp = Database.lookupWaypoint(sender, args[0]); + if (wp == null) { + sender.sendMessage("You do not have a waypoint " + args[0] + "."); + return true; } + + Database.setWBack(sender, sender.getLocation()); + sender.teleport(wp.location); return true; + } + } |