Search in sources :

Example 1 with ConversationFactory

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();
}
Also used : ConversationFactory(org.bukkit.conversations.ConversationFactory) Conversation(org.bukkit.conversations.Conversation)

Example 2 with ConversationFactory

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();
}
Also used : EditingPrompt(io.github.wysohn.triggerreactor.bukkit.tools.prompts.EditingPrompt) UsagePrompt(io.github.wysohn.triggerreactor.bukkit.tools.prompts.UsagePrompt) ConversationFactory(org.bukkit.conversations.ConversationFactory) Conversation(org.bukkit.conversations.Conversation) ScriptEditor(io.github.wysohn.triggerreactor.tools.ScriptEditor)

Example 3 with ConversationFactory

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));
}
Also used : ConversationFactory(org.bukkit.conversations.ConversationFactory) Conversable(org.bukkit.conversations.Conversable) CommandSender(org.bukkit.command.CommandSender)

Example 4 with ConversationFactory

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));
}
Also used : Consumer(java.util.function.Consumer) CitizensAPI(net.citizensnpcs.api.CitizensAPI) StringPrompt(org.bukkit.conversations.StringPrompt) ConversationFactory(org.bukkit.conversations.ConversationFactory) ConversationContext(org.bukkit.conversations.ConversationContext) Prompt(org.bukkit.conversations.Prompt) Player(org.bukkit.entity.Player) ConversationFactory(org.bukkit.conversations.ConversationFactory) StringPrompt(org.bukkit.conversations.StringPrompt) StringPrompt(org.bukkit.conversations.StringPrompt) Prompt(org.bukkit.conversations.Prompt) ConversationContext(org.bukkit.conversations.ConversationContext)

Example 5 with ConversationFactory

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();
        }
    };
}
Also used : ConversationFactory(org.bukkit.conversations.ConversationFactory) Conversation(org.bukkit.conversations.Conversation) Editor(net.citizensnpcs.editor.Editor)

Aggregations

ConversationFactory (org.bukkit.conversations.ConversationFactory)6 Conversation (org.bukkit.conversations.Conversation)4 EditingPrompt (io.github.wysohn.triggerreactor.bukkit.tools.prompts.EditingPrompt)1 UsagePrompt (io.github.wysohn.triggerreactor.bukkit.tools.prompts.UsagePrompt)1 ScriptEditor (io.github.wysohn.triggerreactor.tools.ScriptEditor)1 Consumer (java.util.function.Consumer)1 CitizensAPI (net.citizensnpcs.api.CitizensAPI)1 Editor (net.citizensnpcs.editor.Editor)1 CommandSender (org.bukkit.command.CommandSender)1 Conversable (org.bukkit.conversations.Conversable)1 ConversationContext (org.bukkit.conversations.ConversationContext)1 Prompt (org.bukkit.conversations.Prompt)1 StringPrompt (org.bukkit.conversations.StringPrompt)1 Player (org.bukkit.entity.Player)1