Search in sources :

Example 1 with Command

use of pl.themolka.arcade.command.Command in project Arcade2 by ShootGame.

the class ObserverListeners method onMatchWindowOpen.

// 
// Miscellaneous
// 
@EventHandler(priority = EventPriority.MONITOR)
public void onMatchWindowOpen(PlayerInteractEvent event) {
    Action action = event.getAction();
    if (!(action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK))) {
        // Deny all actions which are not right clicks.
        return;
    }
    ItemStack item = event.getItem();
    if (item != null && item.isSimilar(ObserversKit.PLAY_ITEM.getResult())) {
        GamePlayer player = this.game.getGame().getPlayer(event.getPlayer());
        if (player == null) {
            return;
        }
        PlayMatchWindow window = this.game.getMatch().getPlayWindow();
        if (window != null && window.open(player)) {
            return;
        }
        // The PlayerMatchWindow is not set. As we cannot handle the window
        // join the given player to match with the '/join' command instead.
        Commands commands = this.game.getPlugin().getCommands();
        Command command = commands.getCommand(PLAY_COMMAND);
        if (command != null) {
            commands.handleCommand(player, command, command.getCommand(), null);
            return;
        }
        player.sendError("Could not join the match right now. Did you defined format module?");
    }
}
Also used : Action(org.bukkit.event.block.Action) Command(pl.themolka.arcade.command.Command) GamePlayer(pl.themolka.arcade.game.GamePlayer) Commands(pl.themolka.arcade.command.Commands) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Command

use of pl.themolka.arcade.command.Command in project Arcade2 by ShootGame.

the class RepoFile method read.

public static RepoFile read(RepositoriesModule module, String[] file) {
    RepoFile repo = new RepoFile(module);
    for (int i = 0; i < file.length; i++) {
        String[] line = file[i].split(" ");
        String[] args = new String[0];
        if (line.length > 1) {
            System.arraycopy(line, 1, args, 0, line.length - 1);
        }
        Command command = repo.getQueries().getCommand(line[0]);
        if (command != null) {
            try {
                CommandContext context = CommandContext.parse(command, line[0], args);
                command.handleCommand(repo.getQueries().getConsole(), context);
            } catch (Throwable th) {
                module.getPlugin().getLogger().log(Level.SEVERE, "Could not handle repo query: " + command.getCommand(), th);
            }
        }
    }
    return repo;
}
Also used : CommandContext(pl.themolka.arcade.command.CommandContext) Command(pl.themolka.arcade.command.Command)

Aggregations

Command (pl.themolka.arcade.command.Command)2 EventHandler (org.bukkit.event.EventHandler)1 Action (org.bukkit.event.block.Action)1 ItemStack (org.bukkit.inventory.ItemStack)1 CommandContext (pl.themolka.arcade.command.CommandContext)1 Commands (pl.themolka.arcade.command.Commands)1 GamePlayer (pl.themolka.arcade.game.GamePlayer)1