summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/SaveWaypoint.java
blob: e77d6ffdc6bbcac91d25bc99d4a5ab1847e8c665 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package net.benjidial.nswp.commands;

import net.benjidial.nswp.Database;
import net.benjidial.nswp.Waypoint;

import org.bukkit.entity.Player;

import java.sql.SQLException;

public class SaveWaypoint extends PlayerCommand {

  public boolean doCommand(Player sender, String[] args) throws SQLException {

    if (args.length != 1)
      return false;

    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;

  }

}