use of org.bukkit.conversations.ConversationFactory in project Citizens2 by CitizensDev.
the class NPCCommandSelector method start.
public static void start(Callback callback, Conversable player, List<NPC> possible) {
final Conversation conversation = new ConversationFactory(CitizensAPI.getPlugin()).withLocalEcho(false).withEscapeSequence("exit").withModality(false).withFirstPrompt(new NPCCommandSelector(callback, possible)).buildConversation(player);
conversation.begin();
}
use of org.bukkit.conversations.ConversationFactory in project TriggerReactor by wysohn.
the class ScriptEditManager method startEdit.
@Override
public void startEdit(ICommandSender sender, String title, String script, SaveHandler saveHandler) {
ConversationFactory factory = new ConversationFactory(plugin.getMain());
EditingPrompt prompt = new EditingPrompt(plugin.getMain(), sender.get(), new ScriptEditor(title, script, saveHandler));
Conversation conv = factory.thatExcludesNonPlayersWithMessage("Sorry, this is in-game only feature!").withFirstPrompt(new UsagePrompt(prompt)).addConversationAbandonedListener(this).buildConversation(sender.get());
conv.getContext().setSessionData("edit", prompt);
conv.begin();
}
use of org.bukkit.conversations.ConversationFactory in project MagicPlugin by elBukkit.
the class CommandAction method runConversations.
private void runConversations(CastContext context, Queue<String> commands, boolean opPlayer) {
CommandSender sender = context.getMage().getCommandSender();
if (!(sender instanceof Conversable)) {
return;
}
Conversable conversable = (Conversable) sender;
ArgumentsPrompt argumentsPrompt = new ArgumentsPrompt(context, sender, commands, opPlayer);
ConversationFactory factory = new ConversationFactory(context.getController().getPlugin());
factory.withLocalEcho(localEcho).withModality(modal).withFirstPrompt(argumentsPrompt);
if (timeout > 0) {
factory.withTimeout(timeout);
}
if (!escapeSequence.isEmpty()) {
factory.withEscapeSequence(escapeSequence);
}
conversable.beginConversation(factory.buildConversation(conversable));
}
use of org.bukkit.conversations.ConversationFactory in project CitizensAPI by CitizensDev.
the class ModalMenuInput method captureInput.
public static void captureInput(Player player, InventoryMenu menu, Consumer<String> input) {
menu.close(player);
// TODO: this unregisters events incorrectly currently
player.beginConversation(new ConversationFactory(CitizensAPI.getPlugin()).addConversationAbandonedListener((evt) -> {
menu.present(player);
}).withLocalEcho(false).withEscapeSequence("exit").withModality(false).withTimeout(60).withFirstPrompt(new StringPrompt() {
@Override
public Prompt acceptInput(ConversationContext ctx, String text) {
input.accept(text);
menu.present(player);
return null;
}
@Override
public String getPromptText(ConversationContext ctx) {
return "";
}
}).buildConversation(player));
}
use of org.bukkit.conversations.ConversationFactory in project Citizens2 by CitizensDev.
the class Text method getEditor.
public Editor getEditor(final Player player) {
final Conversation conversation = new ConversationFactory(plugin).addConversationAbandonedListener(this).withLocalEcho(false).withEscapeSequence("/npc text").withEscapeSequence("exit").withModality(false).withFirstPrompt(new TextStartPrompt(this)).buildConversation(player);
return new Editor() {
@Override
public void begin() {
Messaging.sendTr(player, Messages.TEXT_EDITOR_BEGIN);
conversation.begin();
}
@Override
public void end() {
Messaging.sendTr(player, Messages.TEXT_EDITOR_END);
conversation.abandon();
}
};
}
Aggregations