From 1cebe9271a51e20f4f67e62b511c80bd465ad42d Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 1 Nov 2012 14:01:17 +0800 Subject: [PATCH] Add clear to waypoint editor --- .../trait/waypoint/LinearWaypointProvider.java | 16 ++++++++++++++++ src/main/resources/messages_en.properties | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index dc85b4e2b..8cbe40e80 100644 --- a/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -185,6 +185,16 @@ public class LinearWaypointProvider implements WaypointProvider { conversation = TriggerEditPrompt.start(player, LinearWaypointEditor.this); } }); + return; + } + if (event.getMessage().equalsIgnoreCase("clear")) { + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { + @Override + public void run() { + clearWaypoints(); + } + }); + return; } if (!event.getMessage().equalsIgnoreCase("toggle path")) return; @@ -198,6 +208,12 @@ public class LinearWaypointProvider implements WaypointProvider { }); } + private void clearWaypoints() { + editingSlot = 0; + waypoints.clear(); + destroyWaypointMarkers(); + } + @EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL) diff --git a/src/main/resources/messages_en.properties b/src/main/resources/messages_en.properties index 00c34919a..6f228aa42 100644 --- a/src/main/resources/messages_en.properties +++ b/src/main/resources/messages_en.properties @@ -137,7 +137,7 @@ citizens.editors.text.remove-prompt=Enter the index of the entry you wish to rem citizens.editors.text.removed-entry=[[Removed]] entry at index [[{0}]]. citizens.editors.text.start-prompt=Type [[add]] to add an entry, [[edit]] to edit entries, [[remove]] to remove entries, [[close]] to toggle the NPC as a close talker, and [[random]] to toggle the NPC as a random talker. Type [[help]] to show this again. citizens.editors.waypoints.linear.added-waypoint=[[Added]] a waypoint at ({0}) ([[{1}]], [[{2}]]) -citizens.editors.waypoints.linear.begin=Entered the linear waypoint editor!
[[Left click]] to add a waypoint, [[right click]] to remove.
Type [[toggle path]] to toggle showing entities at waypoints. +citizens.editors.waypoints.linear.begin=Entered the linear waypoint editor!
[[Left click]] to add a waypoint, [[right click]] to remove.
Type [[toggle path]] to toggle showing entities at waypoints, [[triggers]] to enter the trigger editor and [[clear]] to clear all waypoints. citizens.editors.waypoints.linear.edit-slot-set=Editing slot set to [[{0}]] ({1}). citizens.editors.waypoints.linear.end=Exited the linear waypoint editor. citizens.editors.waypoints.linear.not-showing-markers=[[Stopped]] showing waypoint markers.