Java Code Examples for org.bukkit.conversations.Conversable

The following examples show how to use org.bukkit.conversations.Conversable. These examples are extracted from open source projects. 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 Project: Kettle   Author: KettleFoundation   File: CraftServer.java    License: 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 Project: SonarPet   Author: TechzoneMC   File: NameFactory.java    License: 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 Project: Thermos   Author: CyberdyneCC   File: CraftServer.java    License: 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 Project: HoloAPI   Author: DSH105   File: LangSetting.java    License: 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 Project: HoloAPI   Author: DSH105   File: CreateCommand.java    License: 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 Project: HoloAPI   Author: DSH105   File: CreateCommand.java    License: 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 Project: HoloAPI   Author: DSH105   File: BuildCommand.java    License: 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 Project: EchoPet   Author: DSH105   File: NameFactory.java    License: 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 Project: HoloAPI   Author: DSH105   File: LangSetting.java    License: GNU General Public License v3.0 4 votes vote down vote up
public void send(Conversable conversable, String... pairedReplacements) {
    send(conversable, getValue(pairedReplacements));
}