Search in sources :

Example 11 with Game

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());
}
Also used : Game(pl.themolka.arcade.game.Game) MapTime(pl.themolka.arcade.map.MapTime) Handler(net.engio.mbassy.listener.Handler) EventHandler(org.bukkit.event.EventHandler)

Example 12 with Game

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);
    }
}
Also used : Game(pl.themolka.arcade.game.Game) GamePlayer(pl.themolka.arcade.game.GamePlayer) PlayerMoveEvent(pl.themolka.arcade.session.PlayerMoveEvent) World(org.bukkit.World) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 13 with Game

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);
        }
    }
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) Game(pl.themolka.arcade.game.Game) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) GamePlayer(pl.themolka.arcade.game.GamePlayer) BossBar(pl.themolka.arcade.bossbar.BossBar)

Example 14 with Game

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));
}
Also used : Game(pl.themolka.arcade.game.Game)

Example 15 with Game

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);
}
Also used : Paginationable(pl.themolka.arcade.util.pagination.Paginationable) Game(pl.themolka.arcade.game.Game) ArrayList(java.util.ArrayList) DynamicPagination(pl.themolka.arcade.util.pagination.DynamicPagination)

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