diff --git a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java index f79a802..dcdf779 100644 --- a/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java +++ b/src/main/java/world/bentobox/boxed/listeners/AdvancementListener.java @@ -45,6 +45,8 @@ */ public class AdvancementListener implements Listener { + private static final Material[] MATS = Material.values(); + private final Boxed addon; private final Advancement netherAdvancement; private final Advancement netherFortressAdvancement; @@ -327,7 +329,8 @@ private void grantAdv(User user, List list) { private void clearAdv(User user) { // Clear Statistics - Arrays.stream(Statistic.values()).forEach(s -> resetStats(user, s)); + Bukkit.getScheduler().runTaskAsynchronously(addon.getPlugin(), + () -> Arrays.stream(Statistic.values()).forEach(s -> resetStats(user, s))); // Clear advancements Iterator it = Bukkit.advancementIterator(); while (it.hasNext()) { @@ -340,8 +343,9 @@ private void clearAdv(User user) { private void resetStats(User user, Statistic s) { switch(s.getType()) { - case BLOCK -> Arrays.stream(Material.values()).filter(Material::isBlock).forEach(m -> user.getPlayer().setStatistic(s, m, 0)); - case ITEM -> Arrays.stream(Material.values()).filter(Material::isItem).forEach(m -> user.getPlayer().setStatistic(s, m, 0)); + case BLOCK -> + Arrays.stream(MATS).filter(Material::isBlock).forEach(m -> user.getPlayer().setStatistic(s, m, 0)); + case ITEM -> Arrays.stream(MATS).filter(Material::isItem).forEach(m -> user.getPlayer().setStatistic(s, m, 0)); case ENTITY -> Arrays.stream(EntityType.values()).filter(EntityType::isAlive).forEach(m -> user.getPlayer().setStatistic(s, m, 0)); case UNTYPED -> user.getPlayer().setStatistic(s, 0); }