diff --git a/api/src/main/java/org/screamingsandals/bedwars/api/statistics/PlayerStatisticsManager.java b/api/src/main/java/org/screamingsandals/bedwars/api/statistics/PlayerStatisticsManager.java index 6fbc16f7f..f38c53828 100644 --- a/api/src/main/java/org/screamingsandals/bedwars/api/statistics/PlayerStatisticsManager.java +++ b/api/src/main/java/org/screamingsandals/bedwars/api/statistics/PlayerStatisticsManager.java @@ -23,8 +23,13 @@ import java.util.UUID; public interface PlayerStatisticsManager { + + PlayerStatistic getStatistic(UUID uuid); List getLeaderboard(int count); + /** + * @see #getStatistic(UUID) + */ PlayerStatistic loadStatistic(UUID uuid); } diff --git a/build.gradle b/build.gradle index 540bcaaf1..dd891482d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,12 @@ plugins { id 'org.screamingsandals.plugin-builder' version '1.0.84' apply false - id 'me.kcra.takenaka.accessor' version '1.0.0' apply false + id 'me.kcra.takenaka.accessor' version '1.0.4-SNAPSHOT' apply false id 'com.github.gmazzo.buildconfig' version '3.0.0' apply false } allprojects { group = 'org.screamingsandals.bedwars' - version = '0.2.30' + version = '0.2.31-SNAPSHOT' } if (version.toString().endsWith('-SNAPSHOT')) { diff --git a/plugin/src/main/java/org/screamingsandals/bedwars/statistics/PlayerStatisticManager.java b/plugin/src/main/java/org/screamingsandals/bedwars/statistics/PlayerStatisticManager.java index 817d6fe4b..ac1f1ca65 100644 --- a/plugin/src/main/java/org/screamingsandals/bedwars/statistics/PlayerStatisticManager.java +++ b/plugin/src/main/java/org/screamingsandals/bedwars/statistics/PlayerStatisticManager.java @@ -50,11 +50,19 @@ public PlayerStatistic getStatistic(OfflinePlayer player) { return null; } - if (!this.playerStatistic.containsKey(player.getUniqueId())) { - return this.loadStatistic(player.getUniqueId()); + return getStatistic(player.getUniqueId()); + } + + public PlayerStatistic getStatistic(UUID uuid) { + if (uuid == null) { + return null; + } + + if (!this.playerStatistic.containsKey(uuid)) { + return this.loadStatistic(uuid); } - return this.playerStatistic.get(player.getUniqueId()); + return this.playerStatistic.get(uuid); } public void initialize() { @@ -191,6 +199,13 @@ private PlayerStatistic loadYamlStatistic(UUID uuid) { return playerStatistic; } + if (!this.fileDatabase.isConfigurationSection("data." + uuid.toString())) { + Main.getInstance().getLogger().warning("Statistics of player with UUID " + uuid + " are not properly saved and the plugin cannot load them!"); + PlayerStatistic playerStatistic = new PlayerStatistic(uuid); + this.playerStatistic.put(uuid, playerStatistic); + return playerStatistic; + } + HashMap deserialize = new HashMap<>(); deserialize.putAll(this.fileDatabase.getConfigurationSection("data." + uuid.toString()).getValues(false)); PlayerStatistic playerStatistic = new PlayerStatistic(deserialize);