aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-23 15:14:03 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-03-23 15:14:03 +0100
commitd341829214683e1dfb9009da1120f3dae290a8f1 (patch)
tree5599eb52a673c7eda7016c287a00bc50c943eee0 /src/main
parentfc824ace3d40a6392f05f626887d7bfe80c04eb9 (diff)
downloadskyhanni-d341829214683e1dfb9009da1120f3dae290a8f1.tar.gz
skyhanni-d341829214683e1dfb9009da1120f3dae290a8f1.tar.bz2
skyhanni-d341829214683e1dfb9009da1120f3dae290a8f1.zip
Added LorenzUtils.getPlayerUuid
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt1
4 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
index e7f15854a..d3b6a4e29 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt
@@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent
import at.hannibal2.skyhanni.events.ProfileJoinEvent
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -30,7 +29,7 @@ class ApiDataLoader {
nextApiCallTime = System.currentTimeMillis() + 60_000 * 5
SkyHanniMod.coroutineScope.launch {
val apiKey = SkyHanniMod.feature.hidden.apiKey
- val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID()
+ val uuid = LorenzUtils.getPlayerUuid()
loadProfileData(apiKey, uuid, currentProfileId)
}
}
@@ -56,7 +55,7 @@ class ApiDataLoader {
}
private suspend fun tryUpdateProfileDataAndVerifyKey(apiKey: String): Boolean {
- val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID()
+ val uuid = LorenzUtils.getPlayerUuid()
val url = "https://api.hypixel.net/player?key=$apiKey&uuid=$uuid"
val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
index 2c21a10a5..4eac3e0bb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/EliteFarmingWeight.kt
@@ -13,7 +13,6 @@ import at.hannibal2.skyhanni.utils.TimeUtils
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
-import net.minecraft.client.Minecraft
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -208,7 +207,7 @@ class EliteFarmingWeight {
}
private suspend fun loadLeaderboardPosition() = try {
- val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toString().replace("-", "")
+ val uuid = LorenzUtils.getPlayerUuid()
val showNext = if (isEtaEnabled()) "?showNext=true" else ""
val url = "https://elitebot.dev/api/leaderboard/rank/weight/farming/$uuid/$profileId$showNext"
val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
@@ -228,15 +227,8 @@ class EliteFarmingWeight {
-1
}
- private fun UUID.uuidToString(): String {
- return "$this"
- }
-
private suspend fun loadWeight(localProfile: String) {
- val thePlayer = Minecraft.getMinecraft().thePlayer
- val uniqueID = thePlayer.uniqueID
- val abc = uniqueID.uuidToString()
- val uuid = abc.replace("-", "")
+ val uuid = LorenzUtils.getPlayerUuid()
val url = "https://elitebot.dev/api/weight/$uuid"
try {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 4d7d423b3..f11f45ee4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HyPixelData
import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.features.dungeon.DungeonData
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
import net.minecraft.client.Minecraft
import net.minecraft.entity.EntityLivingBase
@@ -163,4 +164,6 @@ object LorenzUtils {
}
return monthNr
}
+
+ fun getPlayerUuid() = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID()
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index 4b01f9499..659f93ecf 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -48,6 +48,7 @@ object StringUtils {
val incrementedLastChar = (lastChar.code + 1).toChar()
return inputWithoutLastChar + incrementedLastChar
}
+
fun UUID.toDashlessUUID(): String {
return toString().replace("-", "")
}