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