diff options
author | Yasin <LifeIsAParadox@users.noreply.github.com> | 2023-08-07 16:19:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-07 16:19:21 +0200 |
commit | 84ea4626690c30177d7f13b7789eb375dea9c705 (patch) | |
tree | ac16d378fed65e50430c7d9aed98641160006cf4 /src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java | |
parent | 528dd7d73c16dfab5b65a761b2888c5b5591c2c5 (diff) | |
parent | 0d0bd433af7f1250af27dd989b45aa7e5cab5223 (diff) | |
download | Skyblocker-84ea4626690c30177d7f13b7789eb375dea9c705.tar.gz Skyblocker-84ea4626690c30177d7f13b7789eb375dea9c705.tar.bz2 Skyblocker-84ea4626690c30177d7f13b7789eb375dea9c705.zip |
Merge pull request #229 from kevinthegreat1/random-refactors
Random refactors
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java')
-rw-r--r-- | src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java index ccffdcca..2bdfa401 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java +++ b/src/main/java/me/xmrvizzy/skyblocker/skyblock/FairySouls.java @@ -20,6 +20,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.DyeColor; import net.minecraft.util.math.BlockPos; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +36,18 @@ public class FairySouls { private static final Map<String, Set<BlockPos>> fairySouls = new HashMap<>(); private static final Map<String, Map<String, Set<BlockPos>>> foundFairies = new HashMap<>(); + public static CompletableFuture<Void> runAsyncAfterFairySoulsLoad(Runnable runnable) { + if (fairySoulsLoaded == null) { + LOGGER.error("Fairy Souls have not being initialized yet! Please ensure the Fairy Souls module is initialized before modules calling this method in SkyblockerMod#onInitializeClient. This error can be safely ignore in a test environment."); + return CompletableFuture.completedFuture(null); + } + return fairySoulsLoaded.thenRunAsync(runnable); + } + + public static int getFairySoulsSize(@Nullable String location) { + return location == null ? fairySouls.values().stream().mapToInt(Set::size).sum() : fairySouls.get(location).size(); + } + public static void init() { fairySoulsLoaded = NEURepo.runAsyncAfterLoad(() -> { try { |