summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-12-30 14:24:46 -0500
committerBenji Dial <benji@benjidial.net>2023-12-30 14:24:46 -0500
commite06ee55259b3549a59358a13c095a274bacf6a05 (patch)
treea6e8b1b33434ee2c7de7028d4abad77b7fbe8296 /src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java
parentef65431d405a713b138a55054e78497883f27e54 (diff)
downloadnew-simple-waypoints-e06ee55259b3549a59358a13c095a274bacf6a05.tar.gz
testing new version
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java')
-rw-r--r--src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java25
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;
+
}
+
}