summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/TeleportToWaypoint.java
blob: 4e84e3c420338f767e67d2c02a099680e1c45b91 (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
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 TeleportToWaypoint extends WaypointCommand {
  public CompletionType getCompletionType() {
    return CompletionType.Waypoint;
  }

  public boolean body(Player player, 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);
    }
    return true;
  }
}