public void save() { datastore.save(globalVehicleStatistics.values()); Collection<PlayerVehicleStatisticContext> contexts = playerLifecycleHolder.getObjects(PlayerVehicleStatisticContext.class); for (PlayerVehicleStatisticContext context : contexts) context.save(); }
@Override protected void onInit() { load(); PlayerLifecycleObjectFactory<PlayerVehicleStatisticContext> factory = (eventManager, player) -> new PlayerVehicleStatisticContext( eventManager, player, VehicleStatisticManager.this, VehicleStatisticManager.this.datastore); playerLifecycleHolder.registerClass(PlayerVehicleStatisticContext.class, factory); saveTimer = Timer.create(1000 * 60 * 5, (factualInterval) -> save()); saveTimer.start(); addDestroyable(saveTimer); }
public void endRacingStatistic(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); context.endRacingStatistic(); }
public boolean isRacingStatistic(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return context.isRacingStatistic(); }
public OncePlayerVehicleStatisticImpl startRacingStatistic(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return context.startRacingStatistic(); }
public List<OncePlayerVehicleStatistic> getPlayerRecordedOnceStatistics(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return context.getRecordedOnceStatistics(); }
public OncePlayerVehicleStatistic getPlayerCurrentOnceStatistic(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return context.getCurrentOnceStatistic(); }
public Collection<PlayerVehicleStatistic> getPlayerVehicleStatistics(Player player) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return Collections.unmodifiableCollection( (Collection<? extends PlayerVehicleStatistic>) context.getVehicleStatistics()); }
public PlayerVehicleStatisticImpl getPlayerVehicleStatistic(Player player, int modelId) { PlayerVehicleStatisticContext context = playerLifecycleHolder.getObject(player, PlayerVehicleStatisticContext.class); return context.getVehicleStatistic(modelId); }