Trigger conversation is active while the editor is active

This commit is contained in:
fullwall 2012-10-26 22:00:48 +08:00
parent 641b19aa99
commit e898918d6d
3 changed files with 8 additions and 23 deletions

View File

@ -102,6 +102,7 @@ public class LinearWaypointProvider implements WaypointProvider {
@Override @Override
public void begin() { public void begin() {
Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_BEGIN); Messaging.sendTr(player, Messages.LINEAR_WAYPOINT_EDITOR_BEGIN);
conversation = TriggerEditPrompt.start(player, LinearWaypointEditor.this);
} }
private void createWaypointMarker(int index, Waypoint waypoint) { private void createWaypointMarker(int index, Waypoint waypoint) {
@ -178,27 +179,13 @@ public class LinearWaypointProvider implements WaypointProvider {
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!event.getPlayer().equals(player)) if (!event.getPlayer().equals(player))
return; return;
if (event.getMessage().equalsIgnoreCase("triggers")) {
event.setCancelled(true);
if (!player.hasPermission("citizens.waypoints.triggers")) {
Messaging.sendErrorTr(player, Messages.COMMAND_NO_PERMISSION);
return;
}
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override
public void run() {
conversation = TriggerEditPrompt.start(player, LinearWaypointEditor.this);
}
}, 1);
return;
}
if (!event.getMessage().equalsIgnoreCase("toggle path")) if (!event.getMessage().equalsIgnoreCase("toggle path"))
return; return;
event.setCancelled(true); event.setCancelled(true);
// we need to spawn entities, get back on the main thread.
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
// we need to spawn entities, get back on the main thread.
togglePath(); togglePath();
} }
}, 1); }, 1);

View File

@ -34,15 +34,13 @@ public class TriggerEditPrompt extends StringPrompt {
@Override @Override
public String getPromptText(ConversationContext context) { public String getPromptText(ConversationContext context) {
context.setSessionData("previous", this); context.setSessionData("previous", this);
context.setSessionData("exit", false);
if (editor.getCurrentWaypoint() == null)
return Messaging.tr(Messages.WAYPOINT_TRIGGER_EDITOR_INACTIVE);
String base = Messaging.tr(Messages.WAYPOINT_TRIGGER_EDITOR_PROMPT); String base = Messaging.tr(Messages.WAYPOINT_TRIGGER_EDITOR_PROMPT);
if (editor.getCurrentWaypoint() != null) {
Waypoint waypoint = editor.getCurrentWaypoint(); Waypoint waypoint = editor.getCurrentWaypoint();
for (WaypointTrigger trigger : waypoint.getTriggers()) { for (WaypointTrigger trigger : waypoint.getTriggers()) {
base += "\n - " + trigger.description(); base += "\n - " + trigger.description();
} }
}
Messaging.send((CommandSender) context.getForWhom(), base); Messaging.send((CommandSender) context.getForWhom(), base);
return ""; return "";
} }

View File

@ -147,7 +147,7 @@ citizens.editors.waypoints.triggers.add.added=<b>[[Added]] waypoint trigger succ
citizens.editors.waypoints.triggers.add.invalid-trigger=Couldn''t create a trigger by the name [[{0}]]. citizens.editors.waypoints.triggers.add.invalid-trigger=Couldn''t create a trigger by the name [[{0}]].
citizens.editors.waypoints.triggers.add.prompt=Enter in a trigger name to add or type [[back]] to return to the edit prompt. Valid trigger names are {0}. citizens.editors.waypoints.triggers.add.prompt=Enter in a trigger name to add or type [[back]] to return to the edit prompt. Valid trigger names are {0}.
citizens.editors.waypoints.linear.added-waypoint=[[Added]] a waypoint at ({0}) ([[{1}]], [[{2}]]) citizens.editors.waypoints.linear.added-waypoint=[[Added]] a waypoint at ({0}) ([[{1}]], [[{2}]])
citizens.editors.waypoints.linear.begin=<b>Entered the linear waypoint editor!<br>[[Left click]] to add a waypoint, [[right click]] to remove.<br>Type [[toggle path]] to toggle showing entities at waypoints. Type [[triggers]] to begin editing waypoint triggers. citizens.editors.waypoints.linear.begin=<b>Entered the linear waypoint editor!<br>[[Left click]] to add a waypoint, [[right click]] to remove.<br>Type [[toggle path]] to toggle showing entities at waypoints.
citizens.editors.waypoints.linear.edit-slot-set=Editing slot set to [[{0}]] ({1}). 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.end=Exited the linear waypoint editor.
citizens.editors.waypoints.linear.not-showing-markers=[[Stopped]] showing waypoint markers. citizens.editors.waypoints.linear.not-showing-markers=[[Stopped]] showing waypoint markers.