use of com.ebicep.warlords.database.repositories.games.GamesCollections in project Warlords by ebicep.
the class DatabaseGameBase method addGameToDatabase.
public static void addGameToDatabase(DatabaseGameBase databaseGame) {
if (DatabaseManager.gameService == null)
return;
GamesCollections collection = databaseGame.getGameMode().gamesCollections;
// game in the database
if (DatabaseManager.gameService.exists(databaseGame, collection)) {
// if not counted then update player stats then set counted to true, else do nothing
if (!databaseGame.isCounted()) {
databaseGame.updatePlayerStatsFromGame(databaseGame, true);
databaseGame.setCounted(true);
DatabaseManager.updateGameAsync(databaseGame, collection);
}
} else {
// game not in database then add game and update player stats if counted
if (databaseGame.isCounted()) {
databaseGame.updatePlayerStatsFromGame(databaseGame, true);
}
// only add game if comps
// if (databaseGame.isPrivate) {
Warlords.newChain().delay(4, TimeUnit.SECONDS).async(() -> DatabaseManager.gameService.create(databaseGame, collection)).async(() -> LeaderboardManager.addHologramLeaderboards(UUID.randomUUID().toString(), false)).execute();
// }
}
}
use of com.ebicep.warlords.database.repositories.games.GamesCollections in project Warlords by ebicep.
the class DatabaseGameBase method removeGameFromDatabase.
public static void removeGameFromDatabase(DatabaseGameBase databaseGame) {
if (DatabaseManager.gameService == null)
return;
GamesCollections collection = databaseGame.getGameMode().gamesCollections;
// game in the database
if (DatabaseManager.gameService.exists(databaseGame, collection)) {
// if counted then remove player stats then set counted to false, else do nothing
if (databaseGame.isCounted()) {
databaseGame.updatePlayerStatsFromGame(databaseGame, false);
databaseGame.setCounted(false);
DatabaseManager.updateGameAsync(databaseGame, collection);
}
}
// else game not in database then do nothing
}
Aggregations