diff options
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java')
-rw-r--r-- | src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java | 25 |
1 files changed, 18 insertions, 7 deletions
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; + } + } |