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