Search in sources :

Example 16 with Game

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

the class MapCommands method mapInfo.

// 
// /mapinfo command
// 
@CommandInfo(name = { "mapinfo", "map" }, description = "Describe a map", flags = { "c", "current", "n", "next" }, usage = "[-current|-next|<map...>]", permission = "arcade.command.mapinfo", completer = "mapInfoCompleter")
public void mapInfo(Sender sender, CommandContext context) {
    boolean paramCurrent = context.hasFlag("c") || context.hasFlag("current");
    boolean paramNext = context.hasFlag("n") || context.hasFlag("next");
    String paramMap = context.getParams(0);
    List<OfflineMap> results = new ArrayList<>();
    if (paramCurrent || context.getArgs().length == 0) {
        Game game = this.plugin.getGames().getCurrentGame();
        if (game == null) {
            throw new CommandException("No game running right now.");
        }
        results.add(game.getMap().getMapInfo());
    } else if (paramNext) {
        OfflineMap next = this.plugin.getGames().getQueue().getNextMap();
        if (next == null) {
            throw new CommandException("The map queue is empty.");
        }
        results.add(next);
    } else {
        results.addAll(this.plugin.getMaps().findMap(paramMap));
    }
    if (results.isEmpty()) {
        throw new CommandException("No results found.");
    } else if (results.size() > 1) {
        sender.sendError("Found " + results.size() + " results. Displaying the best one...");
    }
    this.mapInfoDescribe(sender, results.get(0));
}
Also used : Game(pl.themolka.arcade.game.Game) OfflineMap(pl.themolka.arcade.map.OfflineMap) ArrayList(java.util.ArrayList)

Example 17 with Game

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

the class CycleCountdown method onUpdate.

@Override
public void onUpdate(long seconds, long secondsLeft) {
    if (!this.plugin.getGames().getQueue().hasNextMap()) {
        this.cancelCountdown();
        return;
    } else if (!this.isPrintable(secondsLeft)) {
        return;
    }
    OfflineMap nextMap = this.plugin.getGames().getQueue().getNextMap();
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        return;
    }
    String message = this.getPrintMessage(this.getCycleMessage(nextMap.getName()));
    for (ArcadePlayer player : this.plugin.getPlayers()) {
        player.getPlayer().send(message);
    }
    this.plugin.getLogger().info(ChatColor.stripColor(message));
}
Also used : Game(pl.themolka.arcade.game.Game) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) OfflineMap(pl.themolka.arcade.map.OfflineMap)

Example 18 with Game

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

the class DevelopmentCommands method cycleNow.

// 
// /cyclenow command
// 
@CommandInfo(name = { "cyclenow" }, description = "Cycle now to the given map", flags = { "c", "current", "n", "next" }, usage = "<map...>", permission = "arcade.command.cyclenow")
public void cycleNow(Sender sender, CommandContext context) {
    boolean paramCurrent = context.hasFlag("c") || context.hasFlag("current");
    boolean paramNext = context.hasFlag("n") || context.hasFlag("next");
    String paramMap = context.getParams(0);
    List<OfflineMap> results = new ArrayList<>();
    if (paramCurrent || context.getArgs().length == 0) {
        Game game = this.development.getPlugin().getGames().getCurrentGame();
        if (game == null) {
            throw new CommandException("No game running right now.");
        }
        results.add(game.getMap().getMapInfo());
    } else if (paramNext) {
        OfflineMap next = this.development.getPlugin().getGames().getQueue().getNextMap();
        if (next == 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);
        }
        results.add(next);
    } else {
        results.addAll(this.development.getPlugin().getMaps().findMap(paramMap));
    }
    if (results.isEmpty()) {
        throw new CommandException("No results found.");
    } else if (results.size() > 1) {
        sender.sendError("Found " + results.size() + " results. Cycling to the best one...");
    }
    OfflineMap target = results.get(0);
    GeneralCommands.CycleCommandEvent commandEvent = new GeneralCommands.CycleCommandEvent(this.development.getPlugin(), sender, context, target);
    this.development.getPlugin().getEventBus().publish(commandEvent);
    if (!commandEvent.isCanceled()) {
        sender.sendSuccess("Cycling now to " + target.getName() + "...");
        Game game = this.development.getPlugin().getGames().getCurrentGame();
        for (Countdown countdown : game.getRunningCountdowns()) {
            countdown.cancelCountdown();
        }
        this.development.getPlugin().getGames().getCycleCountdown().cancelCountdown();
        this.development.getPlugin().getGames().cycle(target);
    }
}
Also used : Game(pl.themolka.arcade.game.Game) OfflineMap(pl.themolka.arcade.map.OfflineMap) ArrayList(java.util.ArrayList) GeneralCommands(pl.themolka.arcade.command.GeneralCommands) Countdown(pl.themolka.arcade.task.Countdown) CommandException(pl.themolka.arcade.command.CommandException) CommandInfo(pl.themolka.arcade.command.CommandInfo)

Example 19 with Game

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

the class MatchStartCountdown method onUpdate.

@Override
public void onUpdate(long seconds, long secondsLeft) {
    MatchStartCountdownEvent event = new MatchStartCountdownEvent(this.plugin, this.match, this);
    this.plugin.getEventBus().publish(event);
    if (!this.getMatch().isForceStart() && (event.isCanceled() || this.cannotStart)) {
        this.cannotStart = false;
        this.cancelCountdown();
        return;
    } else if (!this.isPrintable(secondsLeft)) {
        return;
    }
    Game game = this.plugin.getGames().getCurrentGame();
    if (game == null) {
        return;
    }
    this.printMessage();
    this.printCount();
    this.playSound();
}
Also used : Game(pl.themolka.arcade.game.Game)

Example 20 with Game

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

the class Sessions method onPlayerDeath.

// 
// Death Event
// 
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent event) {
    ArcadePlayer victim = this.plugin.getPlayer(event.getEntity());
    Player victimBukkit = victim.getBukkit();
    if (victimBukkit == null) {
        return;
    }
    ArcadePlayer killer = this.plugin.getPlayer(victimBukkit.getKiller());
    Game game = this.plugin.getGames().getCurrentGame();
    if (game != null) {
        pl.themolka.arcade.life.PlayerDeathEvent deathEvent = new pl.themolka.arcade.life.PlayerDeathEvent(this.plugin, victim, killer != null ? killer.getGamePlayer() : null, event.getDeathMessage(), event.getDroppedExp(), new ArrayList<>(event.getDrops()));
        deathEvent.setKeepInventory(event.getKeepInventory());
        deathEvent.setKeepLevel(event.getKeepLevel());
        deathEvent.setNewExp(event.getNewExp());
        deathEvent.setNewLevel(event.getNewLevel());
        this.publish(deathEvent);
        this.replaceDrops(event.getDrops(), deathEvent.getDropItems());
        event.setDeathMessage(deathEvent.getDeathMessage());
        event.setDroppedExp(deathEvent.getDropExp());
        event.setKeepInventory(deathEvent.shouldKeepInventory());
        event.setKeepLevel(deathEvent.shouldKeepLevel());
        event.setNewExp(deathEvent.getNewExp());
        event.setNewLevel(deathEvent.getNewLevel());
        if (deathEvent.willAutoRespawn()) {
            this.plugin.getServer().getScheduler().runTaskLater(this.plugin, new Runnable() {

                @Override
                public void run() {
                    victim.respawn();
                }
            }, deathEvent.getAutoRespawnCooldown().toTicks());
        }
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) Player(org.bukkit.entity.Player) Game(pl.themolka.arcade.game.Game) PlayerDeathEvent(org.bukkit.event.entity.PlayerDeathEvent) EventHandler(org.bukkit.event.EventHandler)

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