summaryrefslogtreecommitdiff
path: root/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2022-11-12 13:39:07 -0500
committerBenji Dial <benji6283@gmail.com>2022-11-12 13:39:07 -0500
commitda7924881ab14e4580ae6c56dbdf8346dbf2a267 (patch)
tree3631cbb3a0eaa6c57c6b8476d130472561dc16c6 /src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
downloadnew-simple-waypoints-da7924881ab14e4580ae6c56dbdf8346dbf2a267.tar.gz
first commit for new version
Diffstat (limited to 'src/main/java/net/benjidial/nswp/commands/ListWaypoints.java')
-rw-r--r--src/main/java/net/benjidial/nswp/commands/ListWaypoints.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java b/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
new file mode 100644
index 0000000..b6b61a3
--- /dev/null
+++ b/src/main/java/net/benjidial/nswp/commands/ListWaypoints.java
@@ -0,0 +1,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;
+ }
+}