Search in sources :

Example 6 with ArcadePlayer

use of pl.themolka.arcade.session.ArcadePlayer in project Arcade2 by ShootGame.

the class MatchGame method onGameOverScreenRender.

/*
     * Don't use MatchEndEvent, because it is called before the players
     * are reset. The reset method would reset their titles.
     */
@Handler(priority = Priority.LAST)
public void onGameOverScreenRender(MatchEndedEvent event) {
    BaseComponent[] defaultComponent = TextComponent.fromLegacyText(ChatColor.AQUA + ChatColor.UNDERLINE.toString() + "Game over!");
    BaseComponent[] winnerComponent = TextComponent.fromLegacyText(ChatColor.GOLD + ChatColor.UNDERLINE.toString() + "Victory!");
    BaseComponent[] loserComponent = TextComponent.fromLegacyText(ChatColor.RED + ChatColor.UNDERLINE.toString() + "Defeat!");
    MatchWinner winner = event.getWinner();
    BaseComponent[] resultComponent;
    if (winner != null) {
        resultComponent = TextComponent.fromLegacyText(winner.getMessage());
    } else {
        // empty
        resultComponent = TextComponent.fromLegacyText("");
    }
    int fadeIn = (int) Time.ofTicks(10).toTicks();
    int stay = (int) Time.ofSeconds(3).toTicks();
    int fadeOut = (int) Time.ofTicks(30).toTicks();
    boolean isDrawWinner = winner instanceof DrawMatchWinner;
    for (ArcadePlayer online : event.getPlugin().getPlayers()) {
        if (online.getGamePlayer() == null) {
            continue;
        }
        BaseComponent[] title;
        ArcadeSound sound;
        if (winner == null || this.getObservers().contains(online)) {
            title = defaultComponent;
            sound = ArcadeSound.ENEMY_LOST;
        } else if (isDrawWinner || winner.contains(online)) {
            title = winnerComponent;
            sound = ArcadeSound.ENEMY_LOST;
        } else {
            title = loserComponent;
            sound = ArcadeSound.ENEMY_WON;
        }
        online.getBukkit().showTitle(title, resultComponent, fadeIn, stay, fadeOut);
        online.play(sound);
    }
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) ArcadeSound(pl.themolka.arcade.session.ArcadeSound) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) Handler(net.engio.mbassy.listener.Handler)

Example 7 with ArcadePlayer

use of pl.themolka.arcade.session.ArcadePlayer in project Arcade2 by ShootGame.

the class GamePlayer method refreshVisibilityArcadePlayer.

public void refreshVisibilityArcadePlayer(Iterable<ArcadePlayer> viewers) {
    List<GamePlayer> players = new ArrayList<>();
    for (ArcadePlayer viewer : viewers) {
        GamePlayer player = viewer.getGamePlayer();
        if (player != null && player.isOnline()) {
            players.add(player);
        }
    }
    this.refreshVisibility(players);
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) ArrayList(java.util.ArrayList)

Example 8 with ArcadePlayer

use of pl.themolka.arcade.session.ArcadePlayer in project Arcade2 by ShootGame.

the class SimpleGameManager method createGame.

@Override
public Game createGame(ArcadeMap map) throws DOMException, IOException {
    MapManager maps = this.plugin.getMaps();
    this.plugin.getLogger().info("Accessing the '" + map.getMapInfo().getDirectory().getName() + "' directory...");
    File[] copied = maps.copyFiles(map);
    StringBuilder copiedFiles = new StringBuilder();
    for (int i = 0; i < copied.length; i++) {
        File file = copied[i];
        copiedFiles.append(file.getName());
        if (file.isDirectory()) {
            copiedFiles.append("[d]");
        } else if (file.isFile()) {
            copiedFiles.append("[f]");
        }
        if (i != copied.length - 1) {
            copiedFiles.append(", ");
        }
    }
    this.plugin.getLogger().info("Copied " + copied.length + " map files - " + copiedFiles.toString() + ".");
    this.plugin.getLogger().info("Generating new unique world '" + map.getWorldName() + "' for map '" + map.getMapInfo().getName() + "'...");
    World world = maps.createWorld(map);
    Game game = new Game(this.plugin, this.gameId++, map, world);
    map.setGame(game);
    // Don't forget to setup the world object!
    map.getManifest().getWorld().getSpawn().setWorld(world);
    for (ArcadePlayer player : this.plugin.getPlayers()) {
        GamePlayer gamePlayer = player.getGamePlayer();
        gamePlayer.getBossBarFacet().removeAll();
        player.setGamePlayer(new GamePlayer(game, player));
        game.getPlayers().playerJoin(player.getGamePlayer());
    }
    this.resetPlayers(game);
    return game;
}
Also used : ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) MapManager(pl.themolka.arcade.map.MapManager) CraftWorld(org.bukkit.craftbukkit.CraftWorld) World(org.bukkit.World) File(java.io.File)

Example 9 with ArcadePlayer

use of pl.themolka.arcade.session.ArcadePlayer in project Arcade2 by ShootGame.

the class RestartCountdown 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.getRestartMessage());
    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) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer) BossBar(pl.themolka.arcade.bossbar.BossBar)

Example 10 with ArcadePlayer

use of pl.themolka.arcade.session.ArcadePlayer 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)

Aggregations

ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)19 GamePlayer (pl.themolka.arcade.game.GamePlayer)5 TextComponent (net.md_5.bungee.api.chat.TextComponent)3 BossBar (pl.themolka.arcade.bossbar.BossBar)3 Game (pl.themolka.arcade.game.Game)3 OfflineMap (pl.themolka.arcade.map.OfflineMap)2 ArcadeSound (pl.themolka.arcade.session.ArcadeSound)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Handler (net.engio.mbassy.listener.Handler)1 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1 World (org.bukkit.World)1 CraftWorld (org.bukkit.craftbukkit.CraftWorld)1 Cancellable (org.bukkit.event.Cancellable)1 EventHandler (org.bukkit.event.EventHandler)1 BlockTransformEvent (pl.themolka.arcade.event.BlockTransformEvent)1 KitContent (pl.themolka.arcade.kit.content.KitContent)1 MapManager (pl.themolka.arcade.map.MapManager)1