use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.
the class GeneralListeners method onGameStart.
//
// Time Ticks
//
@Handler(priority = Priority.HIGHEST)
public void onGameStart(GameStartEvent event) {
Game game = event.getGame();
MapTime time = game.getMap().getManifest().getWorld().getTime();
this.walkTime(game.getWorld(), time.getTicks(), time.isLocked());
}
use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.
the class GeneralListeners method onPlayerMove.
//
// Custom Events
//
/**
* Bukkit's {@link PlayerMoveEvent} is not what we need. We can simply
* cancel the last player movement using the setCanceled(...) method in
* {@link PlayerMoveEvent}.
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) {
Game game = this.plugin.getGames().getCurrentGame();
if (game == null) {
return;
}
World fromWorld = event.getFrom().getWorld();
World toWorld = event.getTo().getWorld();
if (fromWorld == null || !fromWorld.equals(toWorld) || !fromWorld.equals(game.getWorld())) {
// We are not interested in such events.
return;
}
GamePlayer player = game.getPlayer(event.getPlayer());
if (player == null) {
return;
}
PlayerMoveEvent wrapper = new PlayerMoveEvent(this.plugin, player, event);
this.plugin.getEventBus().publish(wrapper);
if (wrapper.isCanceled()) {
Location to = event.getFrom().clone();
to.setX(to.getBlockX() + 0.5);
to.setZ(to.getBlockZ() + 0.5);
event.setTo(to);
}
}
use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.
the class MatchStartCountdown method onTick.
@Override
public void onTick(long ticks) {
Game game = this.plugin.getGames().getCurrentGame();
if (game == null) {
return;
} else if (this.getProgress() > 1) {
return;
}
String message = this.getPrintMessage(this.getStartMessage());
BossBar bossBar = this.getBossBar();
bossBar.setProgress(Percentage.finite(this.getProgress()));
bossBar.setText(new TextComponent(message));
for (ArcadePlayer online : this.plugin.getPlayers()) {
GamePlayer player = online.getGamePlayer();
if (player != null) {
bossBar.addPlayer(player, BAR_PRIORITY);
}
}
}
use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.
the class GameCommands method leave.
//
// /leave command
//
@CommandInfo(name = { "leave", "quit" }, description = "Leave the game", clientOnly = true, permission = "arcade.command.leave")
public void leave(Sender sender, CommandContext context) {
Game game = this.plugin.getGames().getCurrentGame();
if (game == null) {
throw new CommandException("Could not leave the game right now. Please try again later.");
}
this.plugin.getEventBus().publish(new LeaveCommandEvent(this.plugin, sender, context));
}
use of pl.themolka.arcade.game.Game in project Arcade2 by ShootGame.
the class GameCommands method modules.
//
// /modules command
//
@CommandInfo(name = { "modulelist", "modules" }, description = "Show a list of modules available in this game", usage = "[# page]", permission = "arcade.command.modulelist")
public void modules(Sender sender, CommandContext context) {
int paramPage = context.getParamInt(0, 1);
Game game = this.plugin.getGames().getCurrentGame();
if (game == null) {
throw new CommandException("No game running right now.");
}
List<Paginationable> modules = new ArrayList<>(game.getModules().getModules());
if (modules.isEmpty()) {
throw new CommandException("No modules were installed in this map.");
}
DynamicPagination pagination = new DynamicPagination.Builder().description(ChatColor.GOLD + "Next page: /" + context.getLabel() + " " + (paramPage + 1)).items(modules).title("Module List").build();
if (paramPage < 1 || paramPage > pagination.getPages()) {
throw new CommandException("Page #" + paramPage + " not found.");
}
pagination.display(sender, paramPage);
}
Aggregations