diff options
author | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-12-30 14:24:46 -0500 |
commit | e06ee55259b3549a59358a13c095a274bacf6a05 (patch) | |
tree | a6e8b1b33434ee2c7de7028d4abad77b7fbe8296 /src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java | |
parent | ef65431d405a713b138a55054e78497883f27e54 (diff) | |
download | new-simple-waypoints-e06ee55259b3549a59358a13c095a274bacf6a05.tar.gz |
testing new version
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; + } + } |