diff --git a/src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java b/src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java index 8efe01e..960e846 100644 --- a/src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java +++ b/src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java @@ -1,15 +1,12 @@ package com.wasteofplastic.invswitcher; -import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.World; import com.wasteofplastic.invswitcher.listeners.PlayerListener; @@ -26,9 +23,6 @@ */ public class InvSwitcher extends Addon { - protected static final List MAT = Arrays.stream(Material.values()) - .filter(m -> !m.name().startsWith("LEGACY")).toList(); - private Store store; private Settings settings; diff --git a/src/main/java/com/wasteofplastic/invswitcher/Store.java b/src/main/java/com/wasteofplastic/invswitcher/Store.java index ef52765..cb392db 100644 --- a/src/main/java/com/wasteofplastic/invswitcher/Store.java +++ b/src/main/java/com/wasteofplastic/invswitcher/Store.java @@ -36,6 +36,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.Registry; import org.bukkit.Statistic; import org.bukkit.World; import org.bukkit.advancement.Advancement; @@ -275,26 +276,26 @@ private CompletableFuture saveStats(InventoryStorage store, Pl private void saveStatistics(CompletableFuture result, InventoryStorage store, Player player, String worldName) { - Arrays.stream(Statistic.values()).forEach(s -> { + Registry.STATISTIC.forEach(s -> { Map map; Map entMap; switch (s.getType()) { case BLOCK -> { - map = InvSwitcher.MAT.stream().filter(Material::isBlock).filter(m -> player.getStatistic(s, m) > 0) + map = Registry.MATERIAL.stream().filter(Material::isBlock).filter(m -> player.getStatistic(s, m) > 0) .collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v))); if (!map.isEmpty()) { store.getBlockStats(worldName).put(s, map); } } case ITEM -> { - map = InvSwitcher.MAT.stream().filter(Material::isItem).filter(m -> player.getStatistic(s, m) > 0) + map = Registry.MATERIAL.stream().filter(Material::isItem).filter(m -> player.getStatistic(s, m) > 0) .collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v))); if (!map.isEmpty()) { store.getItemStats(worldName).put(s, map); } } case ENTITY -> { - entMap = Arrays.stream(EntityType.values()).filter(EntityType::isAlive) + entMap = Registry.ENTITY_TYPE.stream().filter(EntityType::isAlive) .filter(m -> player.getStatistic(s, m) > 0) .collect(Collectors.toMap(k -> k, v -> player.getStatistic(s, v))); if (!entMap.isEmpty()) { diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index aa99983..7eba1d8 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -1,7 +1,7 @@ name: InvSwitcher main: com.wasteofplastic.invswitcher.InvSwitcher version: ${version}${build.number} -api-version: 2.7.1 +api-version: 3.0.0 authors: tastybento