use of com.ebicep.warlords.game.state.EndState in project Warlords by ebicep.
the class GameTerminateCommand method doAction.
@Override
protected void doAction(CommandSender sender, Collection<GameHolder> gameInstances) {
sender.sendMessage(ChatColor.RED + "DEV:" + ChatColor.GRAY + " Requesting engine to terminate games...");
if (gameInstances.isEmpty()) {
sender.sendMessage(ChatColor.RED + "No valid targets found!");
return;
}
for (GameHolder holder : gameInstances) {
Game game = holder.getGame();
if (game == null) {
sender.sendMessage(ChatColor.GRAY + "- " + holder.getName() + ": " + ChatColor.RED + "The game is not active now");
continue;
}
if (holder.getGame().isFrozen()) {
holder.getGame().clearFrozenCause();
}
Optional<PlayingState> state = game.getState(PlayingState.class);
if (!state.isPresent()) {
sender.sendMessage(ChatColor.GRAY + "- " + holder.getName() + ": " + ChatColor.RED + "The game is not in playing state, instead it is in " + game.getState().getClass().getSimpleName());
} else {
sender.sendMessage(ChatColor.GRAY + "- " + holder.getName() + ": " + ChatColor.RED + "Terminating game...");
game.setNextState(new EndState(game, null));
}
}
sender.sendMessage(ChatColor.GRAY + "- " + ChatColor.RED + "Game has been terminated. Warping back to lobby...");
}
use of com.ebicep.warlords.game.state.EndState in project Warlords by ebicep.
the class InterchangeModeOption method start.
@Override
public void start(@Nonnull Game game) {
// saving player info as it will be modified during the game
game.getPlayers().forEach((uuid, team) -> {
PlayerSettings playerSettings = Warlords.getPlayerSettings(uuid);
previousSelectedClasses.put(uuid, playerSettings.getSelectedClass());
previousSelectedSkillBoosts.put(uuid, playerSettings.getClassesSkillBoosts());
previousSelectedWeaponSkins.put(uuid, playerSettings.getWeaponSkins());
previousSelectedHelmets.put(uuid, ArmorManager.Helmets.getSelected(uuid));
previousSelectedArmorSets.put(uuid, ArmorManager.ArmorSets.getSelected(uuid));
});
generateNextSwapTime();
new GameRunnable(game) {
int secondsPast = 0;
@Override
public void run() {
if (game.getState() instanceof EndState) {
return;
}
if (secondsPast >= secondsUntilNextSwap) {
swap(game);
generateNextSwapTime();
secondsPast = 0;
}
secondsPast++;
}
}.runTaskTimer(GameRunnable.SECOND, GameRunnable.SECOND);
}
Aggregations