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);
}
}
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);
}
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;
}
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);
}
}
}
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);
}
}
}
Aggregations