Skip to content

Commit

Permalink
Small improvements on saving statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Jun 16, 2021
1 parent d342050 commit bf5310d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/me/despical/kotl/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@
*/
public class Main extends JavaPlugin {

private boolean forceDisable;

private ExceptionLogHandler exceptionLogHandler;
private boolean forceDisable = false;
private ConfigPreferences configPreferences;
private MysqlDatabase database;
private UserManager userManager;
Expand Down Expand Up @@ -132,7 +133,7 @@ public void onDisable() {
saveAllUserStatistics();

if (configPreferences.getOption(ConfigPreferences.Option.DATABASE_ENABLED)) {
getMysqlDatabase().shutdownConnPool();
database.shutdownConnPool();
}

for (Arena arena : ArenaRegistry.getArenas()) {
Expand All @@ -143,6 +144,8 @@ public void onDisable() {
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.getActivePotionEffects().forEach(effect -> player.removePotionEffect(effect.getType()));

AttributeUtils.healPlayer(player);
}

arena.teleportToEndLocation(player);
Expand Down Expand Up @@ -293,13 +296,12 @@ private void saveAllUserStatistics() {
}

String finalUpdate = update.toString();
((MysqlManager) userManager.getDatabase()).getDatabase().executeUpdate("UPDATE " + ((MysqlManager) getUserManager().getDatabase()).getTableName() + finalUpdate + " WHERE UUID='" + user.getPlayer().getUniqueId().toString() + "';");
MysqlManager database = ((MysqlManager) userManager.getDatabase());
database.getDatabase().executeUpdate("UPDATE " + database.getTableName() + finalUpdate + " WHERE UUID='" + user.getUniqueId().toString() + "';");
continue;
}

for (StatsStorage.StatisticType stat : StatsStorage.StatisticType.values()) {
userManager.getDatabase().saveStatistic(user, stat);
}
userManager.getDatabase().saveAllStatistic(user);
}
}
}

0 comments on commit bf5310d

Please sign in to comment.