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?");
}
}
Aggregations