From 147df027bb8fa6156488c8fdcd51af0457ffae8c Mon Sep 17 00:00:00 2001 From: fullwall Date: Sat, 29 Jun 2024 14:30:10 +0800 Subject: [PATCH] Stop previous AStarTargeter nav strategy, usability tweaks for animation/chat triggers --- .../java/net/citizensnpcs/npc/ai/MCTargetStrategy.java | 3 +++ .../waypoint/triggers/AnimationTriggerPrompt.java | 10 +++++++++- .../trait/waypoint/triggers/ChatTriggerPrompt.java | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java b/main/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java index 0ee52a9ad..04ca25166 100644 --- a/main/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java +++ b/main/src/main/java/net/citizensnpcs/npc/ai/MCTargetStrategy.java @@ -186,6 +186,9 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget { } location = block.getLocation(); } + if (strategy != null) { + strategy.stop(); + } strategy = npc.isFlyable() ? new FlyingAStarNavigationStrategy(npc, location, parameters) : new AStarNavigationStrategy(npc, location, parameters); } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/AnimationTriggerPrompt.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/AnimationTriggerPrompt.java index b7a66f196..d8cddf2ff 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/AnimationTriggerPrompt.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/AnimationTriggerPrompt.java @@ -47,6 +47,7 @@ public class AnimationTriggerPrompt extends StringPrompt implements WaypointTrig if (animation == null) { Messaging.sendErrorTr((CommandSender) context.getForWhom(), Messages.INVALID_ANIMATION, input, getValidAnimations()); + return this; } animations.add(animation); Messaging.sendTr((CommandSender) context.getForWhom(), Messages.ANIMATION_ADDED, input); @@ -64,7 +65,14 @@ public class AnimationTriggerPrompt extends StringPrompt implements WaypointTrig @Override public String getPromptText(ConversationContext context) { - Messaging.sendTr((CommandSender) context.getForWhom(), Messages.ANIMATION_TRIGGER_PROMPT, getValidAnimations()); + if (context.getSessionData("said") == Boolean.TRUE) { + Messaging.send((CommandSender) context.getForWhom(), + "Current animations:
- " + Joiner.on("
- ").join(animations)); + } else { + Messaging.sendTr((CommandSender) context.getForWhom(), Messages.ANIMATION_TRIGGER_PROMPT, + getValidAnimations()); + context.setSessionData("said", true); + } return ""; } diff --git a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/ChatTriggerPrompt.java b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/ChatTriggerPrompt.java index 5c9a4aee2..6a6226f70 100644 --- a/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/ChatTriggerPrompt.java +++ b/main/src/main/java/net/citizensnpcs/trait/waypoint/triggers/ChatTriggerPrompt.java @@ -44,7 +44,7 @@ public class ChatTriggerPrompt extends StringPrompt implements WaypointTriggerPr @Override public WaypointTrigger createFromShortInput(ConversationContext context, String input) { - return null; + return new ChatTrigger(radius, Lists.newArrayList(input)); } @Override @@ -54,6 +54,7 @@ public class ChatTriggerPrompt extends StringPrompt implements WaypointTriggerPr "Current lines:
- " + Joiner.on("
- ").join(lines)); } else { Messaging.sendTr((CommandSender) context.getForWhom(), Messages.CHAT_TRIGGER_PROMPT); + context.setSessionData("said", true); } return ""; }