summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/DenyTPA.java
blob: 43077abaabd02440808a0e035c70d6a7c85259c3 (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
package net.benjidial.nswp.commands;

import net.benjidial.nswp.Database;

import org.bukkit.entity.Player;

import java.sql.SQLException;
import java.util.List;

public class DenyTPA extends PlayerCommand {

  public List<String> getTabCompletions(Player sender, String[] args) throws SQLException {
    return filterByArg(Database.getTPAAllowedTo(sender), args, 0);
  }

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

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

    int removed = Database.disallowTPA(args[0], sender);

    if (removed == 0)
      sender.sendMessage("Did not find anyone allowed to teleport to you with the name " + args[0] + ".");
    else
      sender.sendMessage(args[0] + " is no longer allowed to teleport to you.");

    return true;

  }

}