use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.
the class PlayingState method begin.
@Override
@SuppressWarnings("null")
public void begin() {
this.game.setAcceptsSpectators(true);
this.game.setAcceptsPlayers(false);
this.resetTimer();
RemoveEntities.doRemove(this.game);
for (Option option : game.getOptions()) {
option.start(game);
}
this.game.forEachOfflinePlayer((player, team) -> {
if (team != null) {
PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
Warlords.addPlayer(new WarlordsPlayer(player, this, team, playerSettings));
}
});
this.game.forEachOfflineWarlordsPlayer(wp -> {
CustomScoreboard customScoreboard = Warlords.playerScoreboards.get(wp.getUuid());
updateBasedOnGameState(customScoreboard, wp);
if (wp.getEntity() instanceof Player) {
wp.applySkillBoost((Player) wp.getEntity());
}
});
if (DatabaseManager.playerService != null) {
Warlords.newChain().async(() -> game.forEachOfflinePlayer((player, team) -> {
DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
DatabaseManager.updatePlayerAsync(databasePlayer);
DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.SEASON_5, () -> {
});
DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.WEEKLY, () -> {
});
DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.DAILY, () -> {
});
})).execute();
} else {
System.out.println("ATTENTION - playerService is null");
}
game.registerEvents(new Listener() {
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onWin(WarlordsGameTriggerWinEvent event) {
game.setNextState(new EndState(game, event));
winEvent = event;
}
});
GameRunnable.create(game, this::updateScoreboard).runTaskTimer(0, 10);
new GameRunnable(game) {
@Override
public void run() {
counter++;
timer += GameRunnable.SECOND;
if (counter >= 60) {
counter -= 60;
PlayerFilter.playingGame(game).forEach(wp -> wp.getMinuteStats().advanceMinute());
}
PlayerFilter.playingGame(game).forEach(wp -> wp.getSecondStats().advanceSecond());
}
}.runTaskTimer(0, GameRunnable.SECOND);
game.registerGameMarker(TimerSkipAbleMarker.class, (delay) -> {
counter += delay / GameRunnable.SECOND;
timer += delay;
});
Warlords.getInstance().hideAndUnhidePeople();
}
use of com.ebicep.warlords.game.option.Option in project Warlords by ebicep.
the class DebugMenuGameOptions method openTimerMenu.
public static void openTimerMenu(Player player, Game game) {
TimerDebugAble timerDebugAble = (TimerDebugAble) game.getState();
Menu menu = new Menu("Timer", 9 * 4);
menu.setItem(2, 1, new ItemBuilder(Material.WOOD_BUTTON).name(ChatColor.GREEN + "Reset").get(), (m, e) -> timerDebugAble.resetTimer());
menu.setItem(4, 1, new ItemBuilder(Material.STONE_BUTTON).name(ChatColor.GREEN + "Skip").get(), (m, e) -> timerDebugAble.skipTimer());
menu.setItem(6, 1, new ItemBuilder(Material.WATCH).name(ChatColor.GREEN + "Set").get(), (m, e) -> {
for (Option option : game.getOptions()) {
if (option instanceof WinAfterTimeoutOption) {
int timeLeft = ((WinAfterTimeoutOption) option).getTimeRemaining();
openTimerSetMenu(player, game, timeLeft / 60, timeLeft % 60);
break;
}
}
});
menu.setItem(3, 3, MENU_BACK, (m, e) -> openGameEditorMenu(player, game));
menu.setItem(4, 3, MENU_CLOSE, ACTION_CLOSE_MENU);
menu.openForPlayer(player);
}
Aggregations