diff --git a/src/main/java/us/mytheria/bloblib/api/BlobLibTagAPI.java b/src/main/java/us/mytheria/bloblib/api/BlobLibTagAPI.java index ce973ab..2bf40ff 100644 --- a/src/main/java/us/mytheria/bloblib/api/BlobLibTagAPI.java +++ b/src/main/java/us/mytheria/bloblib/api/BlobLibTagAPI.java @@ -1,10 +1,13 @@ package us.mytheria.bloblib.api; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import us.mytheria.bloblib.BlobLib; import us.mytheria.bloblib.entities.tag.TagSet; import us.mytheria.bloblib.managers.DataAssetManager; +import java.util.List; + public class BlobLibTagAPI { private static BlobLibTagAPI instance; private final BlobLib plugin; @@ -41,4 +44,15 @@ public DataAssetManager getTagSetManager() { public TagSet getTagSet(String key) { return getTagSetManager().getAsset(key); } + + /** + * Gets all TagSet that successfully loaded + * + * @return A list of the TagSet + */ + @NotNull + public List getAll() { + return getTagSetManager().getAssets(); + + } } diff --git a/src/main/java/us/mytheria/bloblib/managers/DataAssetManager.java b/src/main/java/us/mytheria/bloblib/managers/DataAssetManager.java index 5b98070..ceeed29 100644 --- a/src/main/java/us/mytheria/bloblib/managers/DataAssetManager.java +++ b/src/main/java/us/mytheria/bloblib/managers/DataAssetManager.java @@ -11,10 +11,7 @@ import us.mytheria.bloblib.exception.ConfigurationFieldException; import java.io.File; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; +import java.util.*; import java.util.function.BiFunction; import java.util.function.Predicate; @@ -209,4 +206,9 @@ public T getAsset(@NotNull String key) { Objects.requireNonNull(key); return assets.get(key); } + + @NotNull + public List getAssets() { + return assets.values().stream().toList(); + } } diff --git a/src/main/java/us/mytheria/bloblib/managers/LocalizableDataAssetManager.java b/src/main/java/us/mytheria/bloblib/managers/LocalizableDataAssetManager.java index 89dd7b1..37637d7 100644 --- a/src/main/java/us/mytheria/bloblib/managers/LocalizableDataAssetManager.java +++ b/src/main/java/us/mytheria/bloblib/managers/LocalizableDataAssetManager.java @@ -218,10 +218,11 @@ public T getAsset(@NotNull String key) { public List getAssets(@NotNull String locale) { Objects.requireNonNull(locale); + Map copy = new HashMap<>(locales.get("en_us")); Map map = locales.get(locale); - if (map == null) - return new ArrayList<>(); - return new ArrayList<>(map.values()); + if (map != null) + copy.putAll(map); + return copy.values().stream().toList(); } public List getAssets() {