Skip to content

Commit

Permalink
Adds BlobLibTagAPI#getAll
Browse files Browse the repository at this point in the history
  • Loading branch information
anjoismysign committed Aug 13, 2024
1 parent cfcce52 commit 2186f90
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/main/java/us/mytheria/bloblib/api/BlobLibTagAPI.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -41,4 +44,15 @@ public DataAssetManager<TagSet> 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<TagSet> getAll() {
return getTagSetManager().getAssets();

}
}
10 changes: 6 additions & 4 deletions src/main/java/us/mytheria/bloblib/managers/DataAssetManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -209,4 +206,9 @@ public T getAsset(@NotNull String key) {
Objects.requireNonNull(key);
return assets.get(key);
}

@NotNull
public List<T> getAssets() {
return assets.values().stream().toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,11 @@ public T getAsset(@NotNull String key) {

public List<T> getAssets(@NotNull String locale) {
Objects.requireNonNull(locale);
Map<String, T> copy = new HashMap<>(locales.get("en_us"));
Map<String, T> 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<T> getAssets() {
Expand Down

0 comments on commit 2186f90

Please sign in to comment.