org.bukkit.conversations.Conversable Java Examples

The following examples show how to use org.bukkit.conversations.Conversable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftServer.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public boolean dispatchServerCommand(CommandSender sender, PendingCommand serverCommand) {
    if (sender instanceof Conversable) {
        Conversable conversable = (Conversable) sender;

        if (conversable.isConversing()) {
            conversable.acceptConversationInput(serverCommand.command);
            return true;
        }
    }
    try {
        this.playerCommandState = true;
        return this.dispatchCommand(sender, serverCommand.command);
    } catch (Exception ex) {
        getLogger().log(Level.WARNING,
                "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex);
        return false;
    } finally {
        this.playerCommandState = false;
    }
}
 
Example #2
Source File: NameFactory.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static void askForName(Conversable whom, IPet pet, boolean admin) {
    new ConversationFactory(EchoPet.getPlugin())
            .withModality(true)
            .withLocalEcho(false)
            .withPrefix(new NameConversationPrefix())
            .withTimeout(90)
            .withFirstPrompt(new NamePrompt(pet, admin))
            .withEscapeSequence("exit")
            .withEscapeSequence("quit")
            .buildConversation(whom).begin();
}
 
Example #3
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public boolean dispatchServerCommand(CommandSender sender, net.minecraft.command.ServerCommand serverCommand) {
    if (sender instanceof Conversable) {
        Conversable conversable = (Conversable)sender;

        if (conversable.isConversing()) {
            conversable.acceptConversationInput(serverCommand.command);
            return true;
        }
    }
    try {
        this.playerCommandState = true;
        // Cauldron start - handle bukkit/vanilla console commands
        int space = serverCommand.command.indexOf(" ");
        // if bukkit command exists then execute it over vanilla
        if (this.getCommandMap().getCommand(serverCommand.command.substring(0, space != -1 ? space : serverCommand.command.length())) != null)
        {
            return this.dispatchCommand(sender, serverCommand.command);
        }
        else { // process vanilla console command
            craftCommandMap.setVanillaConsoleSender(serverCommand.sender);
            return this.dispatchVanillaCommand(sender, serverCommand.command);
        }
        // Cauldron end
    } catch (Exception ex) {
        getLogger().log(Level.WARNING, "Unexpected exception while parsing console command \"" + serverCommand.command + '"', ex);
        return false;
    } finally {
        this.playerCommandState = false;
    }
}
 
Example #4
Source File: LangSetting.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
public static void send(Conversable conversable, String message) {
    if (conversable instanceof CommandSender) {
        send((CommandSender) conversable, message);
        return;
    }

    if (message != null) {
        conversable.sendRawMessage(HoloAPI.getPrefix() + ChatColor.translateAlternateColorCodes('&', message));
    }
}
 
Example #5
Source File: CreateCommand.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        command = "create",
        description = "Create a hologram from text",
        permission = "holoapi.holo.create",
        help = {"Lines can be entered one after another", "Once the command is entered, you will be prompted to enter the line content"}
)
public boolean create(CommandEvent event) {
    if (!(event.sender() instanceof Conversable)) {
        event.respond(Lang.NOT_CONVERSABLE.getValue());
        return true;
    }
    InputFactory.buildBasicConversation().withFirstPrompt(new InputPrompt()).buildConversation((Conversable) event.sender()).begin();
    return true;
}
 
Example #6
Source File: CreateCommand.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        command = "create animation",
        description = "Create a hologram using animations",
        permission = "holoapi.holo.create",
        help = "Animation can be defined in the HoloAPI config file"
)
public boolean createAnimation(CommandEvent event) {
    if (!(event.sender() instanceof Conversable)) {
        event.respond(Lang.NOT_CONVERSABLE.getValue());
        return true;
    }
    InputFactory.buildBasicConversation().withFirstPrompt(new AnimationBuilderInputPrompt()).buildConversation((Conversable) event.sender()).begin();
    return true;
}
 
Example #7
Source File: BuildCommand.java    From HoloAPI with GNU General Public License v3.0 5 votes vote down vote up
@Command(
        command = "build",
        description = "Dynamically build a combined hologram of both text and images",
        permission = "holoapi.holo.build"
)
public boolean command(CommandEvent event) {
    if (!(event.sender() instanceof Conversable)) {
        event.respond(Lang.NOT_CONVERSABLE.getValue());
        return true;
    }
    InputFactory.buildBasicConversation().withFirstPrompt(new BuilderInputPrompt()).buildConversation((Conversable) event.sender()).begin();
    return true;
}
 
Example #8
Source File: NameFactory.java    From EchoPet with GNU General Public License v3.0 5 votes vote down vote up
public static void askForName(Conversable whom, IPet pet, boolean admin) {
    new ConversationFactory(EchoPet.getPlugin())
            .withModality(true)
            .withLocalEcho(false)
            .withPrefix(new NameConversationPrefix())
            .withTimeout(90)
            .withFirstPrompt(new NamePrompt(pet, admin))
            .withEscapeSequence("exit")
            .withEscapeSequence("quit")
            .buildConversation(whom).begin();
}
 
Example #9
Source File: LangSetting.java    From HoloAPI with GNU General Public License v3.0 4 votes vote down vote up
public void send(Conversable conversable, String... pairedReplacements) {
    send(conversable, getValue(pairedReplacements));
}