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/SaveWaypoint.java | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java') diff --git a/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java b/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java index f0b9dcd..e77d6ff 100644 --- a/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java +++ b/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java @@ -7,16 +7,27 @@ import org.bukkit.entity.Player; import java.sql.SQLException; -public class SaveWaypoint extends WaypointCommand { - public CompletionType getCompletionType() { - return CompletionType.None; - } +public class SaveWaypoint extends PlayerCommand { + + public boolean doCommand(Player sender, String[] args) throws SQLException { - public boolean body(Player player, String[] args) throws SQLException { if (args.length != 1) return false; - Waypoint waypoint = new Waypoint(args[0], player.getLocation()); - Database.addWaypoint(player, waypoint); + + Database.createWaypointTable(sender); + + Waypoint wp = Database.lookupWaypoint(sender, args[0]); + if (wp != null) { + sender.sendMessage("You already have a waypoint " + wp.toString() + "."); + return true; + } + + wp = new Waypoint(args[0], sender.getLocation()); + Database.addWaypoint(sender, wp); + + sender.sendMessage("Added " + wp.toString() + "."); return true; + } + } -- cgit v1.2.3