Search in sources :

Example 1 with Commands

use of pl.themolka.arcade.command.Commands 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)

Aggregations

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