Search in sources :

Example 1 with ArcadeSound

use of pl.themolka.arcade.session.ArcadeSound 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 2 with ArcadeSound

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

the class MatchStartCountdown method playSound.

private void playSound() {
    long left = this.getLeftSeconds();
    ArcadeSound sound = null;
    if (left == 0) {
        sound = ArcadeSound.STARTED;
    } else if (left == 1 || left == 2 || left == 3) {
        sound = ArcadeSound.STARTING;
    }
    if (sound != null) {
        for (ArcadePlayer player : this.plugin.getPlayers()) {
            player.play(sound);
        }
    }
}
Also used : ArcadeSound(pl.themolka.arcade.session.ArcadeSound) ArcadePlayer(pl.themolka.arcade.session.ArcadePlayer)

Aggregations

ArcadePlayer (pl.themolka.arcade.session.ArcadePlayer)2 ArcadeSound (pl.themolka.arcade.session.ArcadeSound)2 Handler (net.engio.mbassy.listener.Handler)1 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1