Search in sources :

Example 1 with Game

use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.

the class ArcadePlugin method stop.

public final void stop() throws Throwable {
    if (!this.isRunning()) {
        throw new IllegalStateException("Already not running!");
    }
    this.running = false;
    Game game = this.getGames().getCurrentGame();
    if (game != null) {
        this.getGames().destroyGame(game);
    }
    this.getTasks().cancelAll();
    this.getTickableTask().cancel();
    for (Module<?> module : this.getModules().getModules()) {
        try {
            module.onDisable();
        } catch (Throwable th) {
            this.getLogger().log(Level.SEVERE, "Could not disable module '" + module.getId() + "': " + th.getMessage(), th);
        }
        module.destroy();
    }
    try {
        this.getEnvironment().onDisable();
    } catch (Throwable th) {
        this.getLogger().log(Level.SEVERE, "Could not disable environment " + this.getEnvironment().getType().toString(), th);
    }
    this.getEventBus().shutdown();
}
Also used : Game(pl.themolka.arcade.game.Game)

Example 2 with Game

use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.

the class GameCommands method join.

// 
// /join command
// 
@CommandInfo(name = { "join", "play" }, description = "Join the game", flags = { "a", "auto" }, usage = "[-auto] [context...]", clientOnly = true, permission = "arcade.command.join", completer = "joinCompleter")
public void join(Sender sender, CommandContext context) {
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        throw new CommandException("Could not join the game right now. Please try again later.");
    }
    String param = context.getParam(0);
    if (param != null) {
        boolean observers = param.equalsIgnoreCase("obs") || param.equalsIgnoreCase("observers");
        if (observers) {
            this.leave(sender, context);
            return;
        }
    }
    boolean auto = param == null || context.hasFlag("a") || context.hasFlag("auto");
    JoinCommandEvent event = new JoinCommandEvent(this.plugin, sender, context, auto);
    this.plugin.getEventBus().publish(event);
    if (!event.isCanceled() && !event.hasJoined()) {
        sender.sendError("Could not join any game right now.");
    }
}
Also used : Game(pl.themolka.arcade.game.Game)

Example 3 with Game

use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.

the class GameCommands method gameInfo.

// 
// /game command
// 
@CommandInfo(name = { "gameinfo", "game" }, description = "Describe the game", permission = "arcade.command.gameinfo")
public void gameInfo(Sender sender, CommandContext context) {
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        throw new CommandException("No game running right now. Please try again later.");
    }
    CommandUtils.sendTitleMessage(sender, "Game", "#" + game.getGameId());
    this.plugin.getEventBus().publish(new GameCommandEvent(this.plugin, sender, context));
}
Also used : Game(pl.themolka.arcade.game.Game)

Example 4 with Game

use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.

the class GeneralCommands method cancel.

// 
// /cancel command
// 
@CommandInfo(name = "cancel", description = "Cancel current countdown", flags = { "f", "force" }, usage = "[-force]", permission = "arcade.command.cancel")
public void cancel(Sender sender, CommandContext context) {
    boolean paramForce = context.hasFlag("f") || context.hasFlag("force");
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        throw new CommandException("Could not cancel right now. Please try again later.");
    }
    List<Countdown> countdowns = game.getRunningCountdowns();
    if (countdowns.isEmpty()) {
        throw new CommandException("No countdowns running right now.");
    }
    int i = 0;
    for (Countdown countdown : game.getRunningCountdowns()) {
        if (countdown.cancelCountdown()) {
            countdown.setForcedCancel(paramForce);
            i++;
        }
    }
    if (i != 0) {
        sender.sendSuccess("Successfully canceled " + i + " countdown(s).");
    } else {
        throw new CommandException("No countdowns could be canceled right now.");
    }
}
Also used : Game(pl.themolka.arcade.game.Game) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Example 5 with Game

use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.

the class GeneralCommands method cycle.

// 
// /cycle command
// 
@CommandInfo(name = "cycle", description = "Cycle to next map", usage = "[seconds]", permission = "arcade.command.cycle")
public void cycle(Sender sender, CommandContext context) {
    int paramSeconds = context.getParamInt(0, (int) CycleCountdown.DEFAULT_DURATION.getSeconds());
    OfflineMap nextMap = this.plugin.getGames().getQueue().getNextMap();
    if (nextMap == null) {
        String reason = "The map queue is empty.";
        if (sender.hasPermission("arcade.command.setnext")) {
            reason += " Set next map using /setnext <map...>.";
        }
        throw new CommandException(reason);
    }
    CycleCommandEvent commandEvent = new CycleCommandEvent(this.plugin, sender, context, nextMap);
    this.plugin.getEventBus().publish(commandEvent);
    if (commandEvent.isCanceled()) {
        return;
    }
    int seconds = paramSeconds;
    if (seconds < 3) {
        seconds = 3;
    }
    CycleStartEvent startEvent = new CycleStartEvent(this.plugin, nextMap, seconds);
    this.plugin.getEventBus().publish(startEvent);
    this.plugin.getGames().setNextRestart(false);
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        for (Countdown countdown : game.getRunningCountdowns()) {
            countdown.cancelCountdown();
        }
        CycleCountdown countdown = this.plugin.getGames().getCycleCountdown();
        countdown.cancelCountdown();
        countdown.setDuration(Duration.ofSeconds(seconds));
        countdown.countSync();
    }
}
Also used : Game(pl.themolka.arcade.game.Game) CycleStartEvent(pl.themolka.arcade.cycle.CycleStartEvent) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) OfflineMap(pl.themolka.arcade.map.OfflineMap) CycleCountdown(pl.themolka.arcade.cycle.CycleCountdown) Countdown(pl.themolka.arcade.task.Countdown) RestartCountdown(pl.themolka.arcade.game.RestartCountdown)

Aggregations

Game (pl.themolka.arcade.game.Game)22 OfflineMap (pl.themolka.arcade.map.OfflineMap)7 Countdown (pl.themolka.arcade.task.Countdown)6 GamePlayer (pl.themolka.arcade.game.GamePlayer)5 ArrayList (java.util.ArrayList)4 EventHandler (org.bukkit.event.EventHandler)4 CycleCountdown (pl.themolka.arcade.cycle.CycleCountdown)4 RestartCountdown (pl.themolka.arcade.game.RestartCountdown)4 CycleStartEvent (pl.themolka.arcade.cycle.CycleStartEvent)3 ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)3 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Location (org.bukkit.Location)2 BossBar (pl.themolka.arcade.bossbar.BossBar)2 CommandException (pl.themolka.arcade.command.CommandException)2 CommandInfo (pl.themolka.arcade.command.CommandInfo)2 GeneralCommands (pl.themolka.arcade.command.GeneralCommands)2 Handler (net.engio.mbassy.listener.Handler)1 World (org.bukkit.World)1 Player (org.bukkit.entity.Player)1 PlayerDeathEvent (org.bukkit.event.entity.PlayerDeathEvent)1