blob: e160fc0aab216a851376704677ebf4c4fbef76ad (
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
34
35
36
37
38
39
40
|
package net.benjidial.nswp.commands;
import net.benjidial.nswp.Database;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
import java.sql.SQLException;
import java.util.List;
public class TPA extends PlayerCommand {
public List<String> getTabCompletions(Player sender, String[] args) throws SQLException {
return filterByArg(Database.getOnlineTPAAllowedFrom(sender), args, 0);
}
public boolean doCommand(Player sender, String[] args) throws SQLException {
if (args.length != 1)
return false;
Player other = Bukkit.getPlayer(args[0]);
if (other == null) {
sender.sendMessage("Could not find " + args[0] + ". Are they online?");
return true;
}
if (!Database.isTPAAllowed(sender, other)) {
sender.sendMessage("You are not allowed to teleport to " + other.getName() + ".");
sender.sendMessage("They must first run /wtpallow " + sender.getName());
return true;
}
Database.setWBack(sender, sender.getLocation());
sender.teleport(other);
return true;
}
}
|