blob: b6b61a363a006b8c7cf2a8ea72ce299f20aa38ad (
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
|
package net.benjidial.nswp.commands;
import net.benjidial.nswp.Database;
import net.benjidial.nswp.Waypoint;
import org.bukkit.entity.Player;
import org.bukkit.World;
import java.sql.SQLException;
import java.util.ArrayList;
public class ListWaypoints extends WaypointCommand {
public CompletionType getCompletionType() {
return CompletionType.Waypoint;
}
public boolean body(Player player, String[] args) throws SQLException {
if (args.length > 1)
return false;
ArrayList<Waypoint> waypoints = Database.searchWaypoints(player, args.length == 0 ? "" : args[0]);
if (waypoints.size() == 0) {
player.sendMessage("No waypoints found.");
return true;
}
if (waypoints.size() == 1)
player.sendMessage("1 waypoint found:");
else
player.sendMessage(waypoints.size() + " waypoints found:");
World lastWorld = null;
for (Waypoint waypoint : waypoints) {
if (waypoint.location.getWorld() != lastWorld) {
lastWorld = waypoint.location.getWorld();
player.sendMessage(" " + lastWorld.getName() + ": ");
}
player.sendMessage(" " + waypoint.name);
}
return true;
}
}
|