diff options
author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-03-18 00:42:36 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 00:42:36 -0400 |
commit | 23f44b47c3f37fc3dc3e25724d4f8e9c2996a1e4 (patch) | |
tree | d7c5738daaf20160158578ec90603ea69988b084 /src/main/java/de | |
parent | 6448ef2ad0b6197876ad1b1a05dbc621d76cd39b (diff) | |
parent | 4f8f1bf6e647e547906ac1d0a7a6c8ef1f8ead34 (diff) | |
download | Skyblocker-23f44b47c3f37fc3dc3e25724d4f8e9c2996a1e4.tar.gz Skyblocker-23f44b47c3f37fc3dc3e25724d4f8e9c2996a1e4.tar.bz2 Skyblocker-23f44b47c3f37fc3dc3e25724d4f8e9c2996a1e4.zip |
Merge pull request #596 from kevinthegreat1/profile-waypoints-fix
Fix fairy and enigma souls profile loading and add chat profile detection
Diffstat (limited to 'src/main/java/de')
4 files changed, 30 insertions, 33 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/MuseumItemCache.java b/src/main/java/de/hysky/skyblocker/skyblock/item/MuseumItemCache.java index 773f1808..ae908245 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/MuseumItemCache.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/MuseumItemCache.java @@ -1,26 +1,10 @@ package de.hysky.skyblocker.skyblock.item; -import java.io.ByteArrayInputStream; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.lang.reflect.Type; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Path; -import java.util.Base64; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import com.mojang.util.UndashedUuid; - import de.hysky.skyblocker.SkyblockerMod; import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.Http.ApiResponse; @@ -29,12 +13,21 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; import net.minecraft.client.MinecraftClient; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; -import net.minecraft.nbt.NbtIo; -import net.minecraft.nbt.NbtList; -import net.minecraft.nbt.NbtTagSizeTracker; -import net.minecraft.util.Util; +import net.minecraft.nbt.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.util.Base64; +import java.util.Map; +import java.util.concurrent.CompletableFuture; public class MuseumItemCache { private static final Logger LOGGER = LoggerFactory.getLogger(MuseumItemCache.class); @@ -142,9 +135,8 @@ public class MuseumItemCache { public static void tick(String profileId) { if (loaded.isDone()) { String uuid = UndashedUuid.toString(MinecraftClient.getInstance().getSession().getUuidOrNull()); - Object2ObjectOpenHashMap<String, ProfileMuseumData> playerData = MUSEUM_ITEM_CACHE.computeIfAbsent(uuid, uuid1 -> Util.make(new Object2ObjectOpenHashMap<>(), map -> { - map.put(profileId, ProfileMuseumData.EMPTY); - })); + Object2ObjectOpenHashMap<String, ProfileMuseumData> playerData = MUSEUM_ITEM_CACHE.computeIfAbsent(uuid, _uuid -> new Object2ObjectOpenHashMap<>()); + playerData.putIfAbsent(profileId, ProfileMuseumData.EMPTY); if (playerData.get(profileId).stale()) updateData4ProfileMember(uuid, profileId); } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java b/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java index aa55a4e3..8d0c30b8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/rift/EnigmaSouls.java @@ -71,7 +71,7 @@ public class EnigmaSouls { try (BufferedReader reader = Files.newBufferedReader(FOUND_SOULS_FILE)) { for (Map.Entry<String, JsonElement> profile : JsonParser.parseReader(reader).getAsJsonObject().asMap().entrySet()) { for (JsonElement foundSoul : profile.getValue().getAsJsonArray().asList()) { - SOUL_WAYPOINTS.get(PosUtils.parsePosString(foundSoul.getAsString())).setFound(); + SOUL_WAYPOINTS.get(PosUtils.parsePosString(foundSoul.getAsString())).setFound(profile.getKey()); } } } catch (NoSuchFileException ignored) { diff --git a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java index f0e94770..7f826b23 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/waypoint/FairySouls.java @@ -52,7 +52,7 @@ public class FairySouls { @SuppressWarnings("UnusedReturnValue") 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."); + LOGGER.error("[Skyblocker] 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); @@ -79,10 +79,9 @@ public class FairySouls { try (BufferedReader reader = Files.newBufferedReader(SkyblockerMod.CONFIG_DIR.resolve("found_fairy_souls.json"))) { for (Map.Entry<String, JsonElement> foundFairiesForProfileJson : JsonParser.parseReader(reader).getAsJsonObject().asMap().entrySet()) { for (Map.Entry<String, JsonElement> foundFairiesForLocationJson : foundFairiesForProfileJson.getValue().getAsJsonObject().asMap().entrySet()) { - String profile = foundFairiesForLocationJson.getKey(); - Map<BlockPos, ProfileAwareWaypoint> fairiesForLocation = fairySouls.get(profile); + Map<BlockPos, ProfileAwareWaypoint> fairiesForLocation = fairySouls.get(foundFairiesForLocationJson.getKey()); for (JsonElement foundFairy : foundFairiesForLocationJson.getValue().getAsJsonArray().asList()) { - fairiesForLocation.get(PosUtils.parsePosString(foundFairy.getAsString())).setFound(profile); + fairiesForLocation.get(PosUtils.parsePosString(foundFairy.getAsString())).setFound(foundFairiesForProfileJson.getKey()); } } } diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java index 08d0b167..3e3bc4af 100644 --- a/src/main/java/de/hysky/skyblocker/utils/Utils.java +++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java @@ -37,6 +37,8 @@ public class Utils { private static final String ALTERNATE_HYPIXEL_ADDRESS = System.getProperty("skyblocker.alternateHypixelAddress", ""); private static final String PROFILE_PREFIX = "Profile: "; + private static final String PROFILE_MESSAGE_PREFIX = "§aYou are playing on profile: §e"; + public static final String PROFILE_ID_PREFIX = "Profile ID: "; private static boolean isOnHypixel = false; private static boolean isOnSkyblock = false; private static boolean isInjected = false; @@ -424,10 +426,14 @@ public class Utils { return shouldFilter; } - if (isOnSkyblock && message.startsWith("Profile ID: ")) { - profileId = message.replace("Profile ID: ", ""); + if (isOnSkyblock) { + if (message.startsWith(PROFILE_MESSAGE_PREFIX)) { + profile = message.substring(PROFILE_MESSAGE_PREFIX.length()).split("§b")[0]; + } else if (message.startsWith(PROFILE_ID_PREFIX)) { + profileId = message.substring(PROFILE_ID_PREFIX.length()); - MuseumItemCache.tick(profileId); + MuseumItemCache.tick(profileId); + } } return true; |