summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/benjidial/nswp/Plugin.java11
-rw-r--r--src/main/java/net/benjidial/nswp/commands/RenameWaypoint.java37
-rw-r--r--src/main/resources/plugin.yml6
3 files changed, 48 insertions, 6 deletions
diff --git a/src/main/java/net/benjidial/nswp/Plugin.java b/src/main/java/net/benjidial/nswp/Plugin.java
index 9a46cb6..45509a7 100644
--- a/src/main/java/net/benjidial/nswp/Plugin.java
+++ b/src/main/java/net/benjidial/nswp/Plugin.java
@@ -25,10 +25,11 @@ public class Plugin extends JavaPlugin {
return;
}
- getCommand("wlist").setExecutor(new ListWaypoints());
- getCommand("wsave").setExecutor(new SaveWaypoint());
- getCommand("wtp" ).setExecutor(new TeleportToWaypoint());
- getCommand("wdel" ).setExecutor(new DeleteWaypoint());
- getCommand("wback").setExecutor(new WaypointBack());
+ getCommand("wlist" ).setExecutor(new ListWaypoints());
+ getCommand("wsave" ).setExecutor(new SaveWaypoint());
+ getCommand("wtp" ).setExecutor(new TeleportToWaypoint());
+ getCommand("wdel" ).setExecutor(new DeleteWaypoint());
+ getCommand("wback" ).setExecutor(new WaypointBack());
+ getCommand("wrename").setExecutor(new RenameWaypoint());
}
}
diff --git a/src/main/java/net/benjidial/nswp/commands/RenameWaypoint.java b/src/main/java/net/benjidial/nswp/commands/RenameWaypoint.java
new file mode 100644
index 0000000..44af06c
--- /dev/null
+++ b/src/main/java/net/benjidial/nswp/commands/RenameWaypoint.java
@@ -0,0 +1,37 @@
+package net.benjidial.nswp.commands;
+
+import net.benjidial.nswp.Database;
+import net.benjidial.nswp.Waypoint;
+
+import org.bukkit.entity.Player;
+
+import java.sql.SQLException;
+
+public class RenameWaypoint extends WaypointCommand {
+ public CompletionType getCompletionType() {
+ return CompletionType.Waypoint;
+ }
+
+ @Override
+ public boolean body(Player player, String[] args) throws SQLException {
+ if (args.length != 2) return false;
+
+ if (Database.lookupWaypoint(player, args[1]) != null) {
+ player.sendMessage("Waypoint with that name already exists!");
+ return true;
+ }
+
+ Waypoint waypoint = Database.lookupWaypoint(player, args[0]);
+
+ if (waypoint == null) {
+ player.sendMessage("No waypoint with that name.");
+ } else {
+ Database.deleteWaypoint(player, args[0]);
+ waypoint.name = args[1];
+ Database.addWaypoint(player, waypoint);
+ }
+
+ return true;
+ }
+
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 63dcf0e..d6341b1 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: net.benjidial.nswp.Plugin
name: NewSimpleWaypoints
-version: 2.0-SNAPSHOT
+version: 2.1-SNAPSHOT
api-version: 1.19
commands:
@@ -24,3 +24,7 @@ commands:
description: Teleports a player to where they were the last time they ran wtp or wback
usage: /wback
permission: nswp.use
+ wrename:
+ description: Renames a waypoint
+ usage: /wrename <old-name> <new-name>
+ permission: nswp.use