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 --- .../nswp/commands/TeleportToWaypoint.java | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java') 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 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; + } + } -- cgit v1.2.3