aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron <51387595+AzureAaron@users.noreply.github.com>2024-08-20 00:26:28 -0400
committerAaron <51387595+AzureAaron@users.noreply.github.com>2024-08-20 00:44:58 -0400
commit3f358afc7bc8f842daee8f91afcd9eeedf7be25a (patch)
treea30f55ee4c6e2ce8d686cd9e8736907e87e92800 /src
parent7a9fbebc41d55fa0bb3275c79eaba2ba3604b916 (diff)
downloadSkyblocker-3f358afc7bc8f842daee8f91afcd9eeedf7be25a.tar.gz
Skyblocker-3f358afc7bc8f842daee8f91afcd9eeedf7be25a.tar.bz2
Skyblocker-3f358afc7bc8f842daee8f91afcd9eeedf7be25a.zip
Request Profile Id if we don't receive it
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/hysky/skyblocker/utils/Utils.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/de/hysky/skyblocker/utils/Utils.java b/src/main/java/de/hysky/skyblocker/utils/Utils.java
index 7f91920b..52df4d91 100644
--- a/src/main/java/de/hysky/skyblocker/utils/Utils.java
+++ b/src/main/java/de/hysky/skyblocker/utils/Utils.java
@@ -6,6 +6,8 @@ import com.mojang.util.UndashedUuid;
import de.hysky.skyblocker.events.SkyblockEvents;
import de.hysky.skyblocker.mixins.accessors.MessageHandlerAccessor;
import de.hysky.skyblocker.skyblock.item.MuseumItemCache;
+import de.hysky.skyblocker.utils.scheduler.MessageScheduler;
+import de.hysky.skyblocker.utils.scheduler.Scheduler;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.azureaaron.hmapi.data.rank.PackageRank;
@@ -68,6 +70,7 @@ public class Utils {
*/
@NotNull
private static String profileId = "";
+ private static boolean receivedProfileId = false;
/**
* The following fields store data returned from the Mod API: {@link #environment}, {@link #server}, {@link #gameType}, {@link #locationRaw}, and {@link #map}.
*/
@@ -408,6 +411,7 @@ public class Utils {
if (Utils.gameType.equals("SKYBLOCK")) {
isOnSkyblock = true;
+ tickProfileId();
if (!previousServerType.equals("SKYBLOCK")) SkyblockEvents.JOIN.invoker().onSkyblockJoin();
} else if (previousServerType.equals("SKYBLOCK")) {
@@ -441,6 +445,18 @@ public class Utils {
}
/**
+ * After 8 seconds of having swapped servers we send the /profileid command if we didn't
+ * yet receive the profile id message.
+ */
+ private static void tickProfileId() {
+ receivedProfileId = false;
+
+ Scheduler.INSTANCE.schedule(() -> {
+ if (!receivedProfileId) MessageScheduler.INSTANCE.sendMessageAfterCooldown("/profileid");
+ }, 20 * 8); //8 seconds
+ }
+
+ /**
* Parses /locraw chat message and updates {@link #server}, {@link #gameType}, {@link #locationRaw}, {@link #map}
* and {@link #location}
*
@@ -488,6 +504,8 @@ public class Utils {
} else if (message.startsWith(PROFILE_ID_PREFIX)) {
String prevProfileId = profileId;
profileId = message.substring(PROFILE_ID_PREFIX.length());
+ receivedProfileId = true;
+
if (!prevProfileId.equals(profileId)) {
SkyblockEvents.PROFILE_CHANGE.invoker().onSkyblockProfileChange(prevProfileId, profileId);
}