diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-15 14:14:19 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-15 14:14:19 +0200 |
commit | ceef1d3be403db7ee5f8cbda8c49f3370d35df78 (patch) | |
tree | f271d2b943e37331a6f87b352dd3e670af65b7c6 /src/main/java/at/hannibal2/skyhanni | |
parent | ecb40c801ab44118059c1ef07438dfacd75e3927 (diff) | |
download | skyhanni-ceef1d3be403db7ee5f8cbda8c49f3370d35df78.tar.gz skyhanni-ceef1d3be403db7ee5f8cbda8c49f3370d35df78.tar.bz2 skyhanni-ceef1d3be403db7ee5f8cbda8c49f3370d35df78.zip |
removed hypixel api
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
10 files changed, 5 insertions, 281 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 6007339fd..885853f7d 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -139,7 +139,6 @@ class SkyHanniMod { loadModule(HypixelData()) loadModule(DungeonData()) loadModule(ScoreboardData()) - loadModule(ApiDataLoader()) loadModule(SeaCreatureManager()) loadModule(ItemRenderBackground()) loadModule(EntityData()) diff --git a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt index b02a8483e..ca1be6890 100644 --- a/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/api/CollectionAPI.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.api import at.hannibal2.skyhanni.events.CollectionUpdateEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -20,24 +19,6 @@ class CollectionAPI { private val singleCounterPattern = "§7Total Collected: §e(?<amount>.*)".toPattern() @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - val profileData = event.profileData - val jsonElement = profileData["collection"] ?: return - val asJsonObject = jsonElement.asJsonObject ?: return - for ((hypixelId, rawCounter) in asJsonObject.entrySet()) { - val counter = rawCounter.asLong - val internalName = NEUItems.transHypixelNameToInternalName(hypixelId) - - // MUSHROOM_COLLECTION, - internalName.getItemStackOrNull()?.displayName ?: continue - - collectionValue[internalName] = counter - } - - CollectionUpdateEvent().postAndCatch() - } - - @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { collectionValue.clear() } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 6dc3ed238..478eb4a4b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.config.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.commands.SimpleCommand.ProcessCommandRunnable -import at.hannibal2.skyhanni.data.ApiDataLoader import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GuiEditManager import at.hannibal2.skyhanni.features.bingo.BingoCardDisplay @@ -11,6 +10,7 @@ import at.hannibal2.skyhanni.features.bingo.BingoNextStepHelper import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder +import at.hannibal2.skyhanni.features.fame.CityProjectFeatures import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay @@ -20,7 +20,6 @@ import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear import at.hannibal2.skyhanni.features.garden.fortuneguide.FFGuideGUI import at.hannibal2.skyhanni.features.minion.MinionFeatures -import at.hannibal2.skyhanni.features.fame.CityProjectFeatures import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager @@ -142,10 +141,6 @@ object Commands { private fun usersBugFix() { registerCommand("shupdaterepo", "Download the Skyhanni repo again") { SkyHanniMod.repo.updateRepo() } registerCommand( - "shsetapikey", - "Manually set the api key (§cThis command will get removed soon§7)" - ) { ApiDataLoader.command(it) } // TODO remove with api - registerCommand( "shresetburrowwarps", "Manually resetting disabled diana burrow warp points" ) { BurrowWarpHelper.resetDisabledWarps() } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt deleted file mode 100644 index c77210ce6..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt +++ /dev/null @@ -1,154 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.utils.APIUtil -import at.hannibal2.skyhanni.utils.LorenzUtils -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import net.minecraft.client.Minecraft -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.io.File -import java.util.* - -class ApiDataLoader { - private var currentProfileName = "" - private var currentProfileId = "" - - private var usePlayerApiKey = false - - @SubscribeEvent - fun onRepositoryReload(event: RepositoryReloadEvent) { - usePlayerApiKey = false - event.getConstant("DisabledFeatures")?.let { - if (it.asJsonObject["user_api_keys"]?.asBoolean == true) { - usePlayerApiKey = true - } - } - } - - @SubscribeEvent - fun onTick(event: LorenzTickEvent) { - val thePlayer = Minecraft.getMinecraft().thePlayer ?: return - thePlayer.worldObj ?: return - if (!usePlayerApiKey) return - - if (nextApiCallTime != -1L && System.currentTimeMillis() > nextApiCallTime) { - nextApiCallTime = System.currentTimeMillis() + 60_000 * 5 - SkyHanniMod.coroutineScope.launch { - val apiKey = SkyHanniMod.feature.storage.apiKey - val uuid = LorenzUtils.getPlayerUuid() - loadProfileData(apiKey, uuid, currentProfileId) - } - } - } - - @SubscribeEvent - fun onProfileJoin(event: ProfileJoinEvent) { - currentProfileName = event.name - if (!usePlayerApiKey) return - updateApiData() - } - - private suspend fun tryUpdateProfileDataAndVerifyKey(apiKey: String): Boolean { - val uuid = LorenzUtils.getPlayerUuid() - val url = "https://api.hypixel.net/player?key=$apiKey&uuid=$uuid" - val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - - if (jsonObject["success"]?.asBoolean == false) { - if (jsonObject["throttle"]?.asBoolean == true) return true // 429 Too Many Requests doesn't make an invalid key. - val cause = jsonObject["cause"].asString - if (cause == "Invalid API key") { - return false - } else { - throw RuntimeException("API error for url '$url': $cause") - } - } - val player = jsonObject["player"].asJsonObject - val stats = player["stats"].asJsonObject - val skyBlock = stats["SkyBlock"].asJsonObject - val profiles = skyBlock["profiles"].asJsonObject - for (entry in profiles.entrySet()) { - val asJsonObject = entry.value.asJsonObject - val name = asJsonObject["cute_name"].asString - if (currentProfileName == name.lowercase()) { - currentProfileId = asJsonObject["profile_id"].asString - loadProfileData(apiKey, uuid, currentProfileId) - } - } - return true - } - - private fun updateApiData() { - nextApiCallTime = -1 - SkyHanniMod.coroutineScope.launch { - val oldApiKey = SkyHanniMod.feature.storage.apiKey - if (oldApiKey.isNotEmpty() && tryUpdateProfileDataAndVerifyKey(oldApiKey)) { - return@launch - } - findApiCandidatesFromOtherMods().forEach { (modName, newApiKey) -> - if (tryUpdateProfileDataAndVerifyKey(newApiKey)) { - SkyHanniMod.feature.storage.apiKey = newApiKey - LorenzUtils.chat("§e[SkyHanni] Imported valid API key from $modName.") - return@launch - } - } - } - } - - private fun findApiCandidatesFromOtherMods(): Map<String, String> { - LorenzUtils.consoleLog("Trying to find the api key from the config of other mods..") - val candidates = mutableMapOf<String, String>() - for (mod in OtherMod.entries) { - val modName = mod.modName - val file = File(mod.configPath) - if (file.exists()) { - val reader = APIUtil.readFile(file) - try { - val key = mod.readKey(reader).replace("\n", "").replace(" ", "") - if (key == "") { - LorenzUtils.consoleLog("- $modName: no api key set!") - continue - } - UUID.fromString(key) - candidates[modName] = key - } catch (e: Throwable) { - LorenzUtils.consoleLog("- $modName: wrong config format! (" + e.message + ")") - continue - } - } else { - LorenzUtils.consoleLog("- $modName: no mod/config found!") - } - } - return candidates - } - - private suspend fun loadProfileData(apiKey: String, playerUuid: String, profileId: String) { - val url = "https://api.hypixel.net/skyblock/profile?key=$apiKey&profile=$profileId" - - val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - val profile = jsonObject["profile"]?.asJsonObject ?: return - val members = profile["members"]?.asJsonObject ?: return - for (entry in members.entrySet()) { - if (entry.key == playerUuid) { - val profileData = entry.value.asJsonObject - ProfileApiDataLoadedEvent(profileData).postAndCatch() - nextApiCallTime = System.currentTimeMillis() + 60_000 * 3 - } - } - } - - companion object { - private var nextApiCallTime = -1L - - fun command(args: Array<String>) { - SkyHanniMod.feature.storage.apiKey = args[0] - LorenzUtils.chat("§e[SkyHanni] Api key set via command!") - nextApiCallTime = -1 - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt index 0fcc94bf8..93a590016 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/CropAccessoryData.kt @@ -1,6 +1,9 @@ package at.hannibal2.skyhanni.data -import at.hannibal2.skyhanni.events.* +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.features.garden.CropAccessory import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.utils.InventoryUtils @@ -32,17 +35,6 @@ class CropAccessoryData { accessoryPage.clear() } - @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - if (loadedAccessoryThisProfile) return - val inventoryData = event.profileData["inv_contents"] ?: return - val accessories = getCropAccessories(event.profileData["talisman_bag"]).also { - it.addAll(getCropAccessories(inventoryData)) - } - cropAccessory = accessories.maxOrNull() ?: CropAccessory.NONE - loadedAccessoryThisProfile = true - } - // Handle accessory bag detection @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt index 2db2181a1..c847c1710 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SkillExperience.kt @@ -2,7 +2,6 @@ package at.hannibal2.skyhanni.data import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzActionBarEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -18,18 +17,6 @@ class SkillExperience { private val inventoryPattern = ".* §e(?<number>.*)§6/.*".toPattern() @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - val profileData = event.profileData - for ((key, value) in profileData.entrySet()) { - if (key.startsWith("experience_skill_")) { - val label = key.substring(17) - val exp = value.asLong - skillExp[label] = exp - } - } - } - - @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { skillExp.clear() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt index b71b4f4a4..5ee7dfb1d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoNextStepHelper.kt @@ -6,7 +6,6 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.SkillExperience import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.LorenzTickEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.features.bingo.nextstep.* import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -279,22 +278,6 @@ class BingoNextStepHelper { return this } - @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - val profileData = event.profileData - - val visitedZones = profileData["visited_zones"]?.asJsonArray ?: return - for (element in visitedZones) { - val zoneName = element.asString - for (step in islands.values) { - val island = step.island - if (island.apiName == zoneName) { - step.done(true) - } - } - } - } - private infix fun <T : NextStep> T.withItemIslandRequirement(itemName: String): T { itemIslandRequired[itemName]?.let { this requires it } return this diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt index c2f8c508d..c2f4e64fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/trophy/TrophyFishManager.kt @@ -1,8 +1,6 @@ package at.hannibal2.skyhanni.features.fishing.trophy import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.jsonobjects.TrophyFishJson @@ -12,29 +10,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class TrophyFishManager { @SubscribeEvent - fun onProfileJoin(event: ProfileJoinEvent) { - hasLoadedTrophyFish = false - } - - @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - if (hasLoadedTrophyFish) return - val trophyFishes = fishes ?: return - val profileData = event.profileData - trophyFishes.clear() - for ((rawName, value) in profileData["trophy_fish"].asJsonObject.entrySet()) { - val rarity = TrophyRarity.getByName(rawName) ?: continue - val text = rawName.replace("_", "") - val displayName = text.substring(0, text.length - rarity.name.length) - - val amount = value.asInt - val rarities = trophyFishes.getOrPut(displayName) { mutableMapOf() } - rarities[rarity] = amount - hasLoadedTrophyFish = true - } - } - - @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { try { val json = event.getConstant<TrophyFishJson>("TrophyFish") @@ -48,8 +23,6 @@ class TrophyFishManager { } companion object { - private var hasLoadedTrophyFish = false - val fishes: MutableMap<String, MutableMap<TrophyRarity, Int>>? get() = ProfileStorageData.profileSpecific?.crimsonIsle?.trophyFishes diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt index d6e429fa0..1a37cb8ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/NonGodPotEffectDisplay.kt @@ -214,24 +214,6 @@ class NonGodPotEffectDisplay { ) } - @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - val profileData = event.profileData - val effects = profileData["active_effects"]?.asJsonArray ?: return - for (element in effects) { - val effectJson = element.asJsonObject - val name = effectJson["effect"].asString - val effect = NonGodPotEffect.entries.find { it.apiName == name } ?: continue - - val time = effectJson["ticks_remaining"].asLong / 20 - val newValue = System.currentTimeMillis() + time * 1000 - - effectDuration[effect] = if (effect == NonGodPotEffect.INVISIBILITY) { - System.currentTimeMillis() + 1000 * 60 * 60 * 24 - } else newValue - } - } - private fun isEnabled(): Boolean { return LorenzUtils.inSkyBlock && config.nonGodPotEffectDisplay && !LorenzUtils.inDungeons && !LorenzUtils.inKuudraFight } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt index 6c9692a18..827ed137a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/DailyQuestHelper.kt @@ -177,20 +177,6 @@ class DailyQuestHelper(val reputationHelper: CrimsonIsleReputationHelper) { } @SubscribeEvent - fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { - val profileData = event.profileData - val sacks = profileData["sacks_counts"]?.asJsonObject ?: return - - sacksCache.clear() - - for ((name, v) in sacks.entrySet()) { - val amount = v.asLong - sacksCache[name] = amount - } - update() - } - - @SubscribeEvent fun onRenderWorld(event: RenderWorldLastEvent) { if (!isEnabled()) return if (!SkyHanniMod.feature.misc.crimsonIsleReputationLocation) return |