blob: 07f255a662f489bb6578028bf1075881c41e40d0 (
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
41
42
43
44
45
46
47
48
49
50
|
package net.benjidial.nswp.commands;
import net.benjidial.nswp.Database;
import net.benjidial.nswp.Waypoint;
import org.bukkit.entity.Player;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class RenameWaypoint extends PlayerCommand {
public List<String> getTabCompletions(Player sender, String[] args) throws SQLException {
if (args.length > 1)
return new ArrayList<String>();
return searchWaypointsByArg(sender, args, 0);
}
public boolean doCommand(Player sender, String[] args) throws SQLException {
if (args.length != 2)
return false;
Database.createWaypointTable(sender);
Waypoint wp = Database.lookupWaypoint(sender, args[0]);
if (wp == null) {
sender.sendMessage("You do not have a waypoint " + args[0] + ".");
return true;
}
Waypoint otherWP = Database.lookupWaypoint(sender, args[1]);
if (otherWP != null) {
sender.sendMessage("You already have a waypoint " + otherWP.toString() + ".");
return true;
}
String oldToString = wp.toString();
wp.name = args[1];
Database.deleteWaypoint(sender, args[0]);
Database.addWaypoint(sender, wp);
sender.sendMessage("Renamed " + oldToString + " to " + args[1] + ".");
return true;
}
}
|