diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java index 88d3bb199..2f03b3d27 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/LinearWaypointProvider.java @@ -132,7 +132,9 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider { @Override public void setPaused(boolean paused) { - currentGoal.setPaused(paused); + if (currentGoal != null) { + currentGoal.setPaused(paused); + } } @Override @@ -462,8 +464,8 @@ public class LinearWaypointProvider implements EnumerableWaypointProvider { getNavigator().getLocalParameters().addSingleUseCallback(new NavigatorCallback() { @Override public void onCompletion(@Nullable CancelReason cancelReason) { - if (npc.isSpawned() && currentDestination != null && Util - .locationWithinRange(npc.getEntity().getLocation(), currentDestination.getLocation(), 4)) { + if (npc.isSpawned() && currentDestination != null + && Util.locationWithinRange(npc.getStoredLocation(), currentDestination.getLocation(), 2)) { currentDestination.onReach(npc); } selector.finish(); diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java index 65403a7c3..a00557a99 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/Waypoint.java @@ -3,6 +3,11 @@ package net.citizensnpcs.trait.waypoint; import java.util.Collections; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.Location; + +import com.google.common.collect.Lists; + import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.persistence.Persist; @@ -11,11 +16,6 @@ import net.citizensnpcs.trait.waypoint.triggers.DelayTrigger; import net.citizensnpcs.trait.waypoint.triggers.WaypointTrigger; import net.citizensnpcs.trait.waypoint.triggers.WaypointTriggerRegistry; -import org.bukkit.Bukkit; -import org.bukkit.Location; - -import com.google.common.collect.Lists; - public class Waypoint { @Persist(required = true) private Location location; @@ -69,9 +69,8 @@ public class Waypoint { return location; } - @SuppressWarnings("unchecked") public List getTriggers() { - return triggers == null ? Collections.EMPTY_LIST : triggers; + return triggers == null ? Collections. emptyList() : triggers; } @Override @@ -96,7 +95,7 @@ public class Waypoint { int delay = ((DelayTrigger) trigger).getDelay(); if (delay <= 0) continue; - final int newStart = i; + final int newStart = i + 1; Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { @Override public void run() { diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/DelayTrigger.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/DelayTrigger.java index 2f1f9b5cb..f6d8ba019 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/DelayTrigger.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/DelayTrigger.java @@ -1,14 +1,14 @@ package net.citizensnpcs.trait.waypoint.triggers; +import org.bukkit.Bukkit; +import org.bukkit.Location; + import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.persistence.Persist; import net.citizensnpcs.trait.waypoint.WaypointProvider; import net.citizensnpcs.trait.waypoint.Waypoints; -import org.bukkit.Bukkit; -import org.bukkit.Location; - public class DelayTrigger implements WaypointTrigger { @Persist private int delay = 0; diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerEditPrompt.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerEditPrompt.java index df70ddcfd..63b8c8957 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerEditPrompt.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerEditPrompt.java @@ -1,11 +1,5 @@ package net.citizensnpcs.trait.waypoint.triggers; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.util.Messaging; -import net.citizensnpcs.trait.waypoint.Waypoint; -import net.citizensnpcs.trait.waypoint.WaypointEditor; -import net.citizensnpcs.util.Messages; - import org.bukkit.command.CommandSender; import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationContext; @@ -14,6 +8,12 @@ import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; import org.bukkit.entity.Player; +import net.citizensnpcs.api.CitizensAPI; +import net.citizensnpcs.api.util.Messaging; +import net.citizensnpcs.trait.waypoint.Waypoint; +import net.citizensnpcs.trait.waypoint.WaypointEditor; +import net.citizensnpcs.util.Messages; + public class TriggerEditPrompt extends StringPrompt { private final WaypointEditor editor; @@ -54,8 +54,8 @@ public class TriggerEditPrompt extends StringPrompt { public static Conversation start(Player player, WaypointEditor editor) { final Conversation conversation = new ConversationFactory(CitizensAPI.getPlugin()).withLocalEcho(false) - .withEscapeSequence("exit").withEscapeSequence("/npc path").withModality(false) - .withFirstPrompt(new TriggerEditPrompt(editor)).buildConversation(player); + .withEscapeSequence("exit").withEscapeSequence("triggers").withEscapeSequence("/npc path") + .withModality(false).withFirstPrompt(new TriggerEditPrompt(editor)).buildConversation(player); conversation.begin(); return conversation; } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java index 65b1d2219..13f744d35 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/TriggerRemovePrompt.java @@ -2,15 +2,15 @@ package net.citizensnpcs.trait.waypoint.triggers; import java.util.List; -import net.citizensnpcs.api.util.Messaging; -import net.citizensnpcs.trait.waypoint.WaypointEditor; -import net.citizensnpcs.util.Messages; - import org.bukkit.command.CommandSender; import org.bukkit.conversations.ConversationContext; import org.bukkit.conversations.Prompt; import org.bukkit.conversations.StringPrompt; +import net.citizensnpcs.api.util.Messaging; +import net.citizensnpcs.trait.waypoint.WaypointEditor; +import net.citizensnpcs.util.Messages; + public class TriggerRemovePrompt extends StringPrompt { private final WaypointEditor editor; @@ -37,7 +37,7 @@ public class TriggerRemovePrompt extends StringPrompt { return this; } List triggers = editor.getCurrentWaypoint().getTriggers(); - if (index < triggers.size() || index >= triggers.size()) { + if (index >= triggers.size()) { Messaging.sendErrorTr((CommandSender) context.getForWhom(), Messages.WAYPOINT_TRIGGER_REMOVE_INDEX_OUT_OF_RANGE, triggers.size()); } else { @@ -61,7 +61,7 @@ public class TriggerRemovePrompt extends StringPrompt { for (WaypointTrigger trigger : editor.getCurrentWaypoint().getTriggers()) { root += String.format("
%d. " + trigger.description(), i++); } - Messaging.sendTr((CommandSender) context.getForWhom(), Messages.WAYPOINT_TRIGGER_REMOVE_PROMPT + root); + Messaging.send((CommandSender) context.getForWhom(), root); return ""; } } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java index 35b1f8988..60c8980f0 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/WaypointTriggerRegistry.java @@ -22,6 +22,12 @@ public class WaypointTriggerRegistry implements Persister { @Override public void save(WaypointTrigger instance, DataKey root) { PersistenceLoader.save(instance, root); + for (Map.Entry> entry : triggers.entrySet()) { + if (entry.getValue() == instance.getClass()) { + root.setString("type", entry.getKey()); + break; + } + } } public static void addTrigger(String name, Class triggerClass, diff --git a/main/src/main/resources/messages_en.properties b/main/src/main/resources/messages_en.properties index 8be5638f2..8e74e6c33 100644 --- a/main/src/main/resources/messages_en.properties +++ b/main/src/main/resources/messages_en.properties @@ -220,7 +220,7 @@ citizens.editors.waypoints.guided.end=Exited the guided waypoint editor. citizens.editors.waypoints.guided.added-guide=Added a [[guide]] waypoint. This will guide NPCs to their destination. citizens.editors.waypoints.guided.added-available=Added a [[destination]] waypoint. This will be available for NPCs to path to. 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, [[triggers]] to enter the trigger editor and [[clear]] to clear all 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. @@ -239,11 +239,11 @@ citizens.editors.waypoints.triggers.chat.missing-radius=No radius supplied. citizens.editors.waypoints.triggers.chat.prompt=Enter in chat lines to say.
Type in [[radius (radius)]] to set the block radius to broadcast the messages.
Type [[finish]] to finish the chat trigger or [[back]] to return to the previous prompt. citizens.editors.waypoints.triggers.delay.prompt=Enter the delay in [[server ticks]] to use. (20 ticks = 1 second) citizens.editors.waypoints.triggers.main.missing-waypoint=Not editing a waypoint. -citizens.editors.waypoints.triggers.main.prompt=Entered the waypoint trigger editor.
Type [[add]] to begin adding triggers and [[remove]] to remove triggers.
Type [[triggers]] to enter the waypoint trigger editor.
Current triggers are: +citizens.editors.waypoints.triggers.main.prompt=Entered the waypoint trigger editor.
Type [[add]] to begin adding triggers and [[remove]] to remove triggers.
Type [[triggers]] to enter the waypoint trigger editor.
Current triggers are: citizens.editors.waypoints.triggers.remove.index-out-of-range=Index must be in the range [[1-{0}]]. citizens.editors.waypoints.triggers.remove.not-a-number=Index must be a number. citizens.editors.waypoints.triggers.remove.prompt=Enter in the index of the trigger to delete or [[back]] to return to the edit prompt. Current triggers are: -citizens.editors.waypoints.triggers.remove.removed=Successfully removed trigger {0}. +citizens.editors.waypoints.triggers.remove.removed=Successfully removed trigger [[{0}]]. citizens.editors.waypoints.triggers.speed.prompt=Enter the speed modifier as a [[percentage]] of its base speed. citizens.editors.waypoints.triggers.teleport.invalid-format=Invalid location given. Format is [[world]]:[[x]]:[[y]]:[[z]]. citizens.editors.waypoints.triggers.teleport.prompt=Enter the destination in the format world:x:y:z. Type [[here]] to use your current location. Type [[back]] to return to the edit prompt.