aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt3
4 files changed, 11 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt
index 2508391d9..d4ad57e2d 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/MayorElection.kt
@@ -15,6 +15,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class MayorElection {
private var lastUpdate = 0L
+ private var dispatcher = Dispatchers.IO
companion object {
var rawMayorData: MayorJson? = null
@@ -40,7 +41,7 @@ class MayorElection {
lastUpdate = System.currentTimeMillis()
SkyHanniMod.coroutineScope.launch {
val url = "https://api.hypixel.net/resources/skyblock/election"
- val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }
+ val jsonObject = withContext(dispatcher) { APIUtil.getJSONResponse(url) }
rawMayorData = ConfigManager.gson.fromJson(jsonObject, MayorJson::class.java)
val data = rawMayorData ?: return@launch
val map = mutableMapOf<Int, MayorJson.Candidate>()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index e1f069cdf..3254e685b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -37,6 +37,7 @@ import javax.swing.UIManager
import kotlin.time.Duration.Companion.seconds
object GardenNextJacobContest {
+ private var dispatcher = Dispatchers.IO
private var display = emptyList<Any>()
private var simpleDisplay = emptyList<String>()
private var contests = mutableMapOf<Long, FarmingContest>()
@@ -421,7 +422,7 @@ object GardenNextJacobContest {
private suspend fun fetchUpcomingContests() {
try {
val url = "https://api.elitebot.dev/contests/at/now"
- val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
+ val result = withContext(dispatcher) { APIUtil.getJSONResponse(url) }.asJsonObject
val newContests = mutableMapOf<Long, FarmingContest>()
@@ -482,7 +483,7 @@ object GardenNextJacobContest {
val url = "https://api.elitebot.dev/contests/at/now"
val body = Gson().toJson(formatted)
- val result = withContext(Dispatchers.IO) { APIUtil.postJSONIsSuccessful(url, body) }
+ val result = withContext(dispatcher) { APIUtil.postJSONIsSuccessful(url, body) }
if (result) {
LorenzUtils.chat("§e[SkyHanni] Successfully submitted this years upcoming contests, thank you for helping everyone out!")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
index 38a21b1d8..e8491ae96 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
@@ -90,6 +90,7 @@ class FarmingWeightDisplay {
companion object {
private val config get() = SkyHanniMod.feature.garden.eliteFarmingWeights
private val localCounter = mutableMapOf<CropType, Long>()
+ private var dispatcher = Dispatchers.IO
private var display = emptyList<Renderable>()
private var profileId = ""
@@ -399,7 +400,7 @@ class FarmingWeightDisplay {
val atRank = if (isEtaEnabled() && goalRank != 10001) "&atRank=$goalRank" else ""
val url = "https://api.elitebot.dev/leaderboard/rank/farmingweight/$uuid/$profileId$includeUpcoming$atRank"
- val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
+ val result = withContext(dispatcher) { APIUtil.getJSONResponse(url) }.asJsonObject
if (isEtaEnabled()) {
nextPlayers.clear()
@@ -424,7 +425,7 @@ class FarmingWeightDisplay {
val url = "https://api.elitebot.dev/weight/$uuid"
try {
- val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
+ val result = withContext(dispatcher) { APIUtil.getJSONResponse(url) }.asJsonObject
for (profileEntry in result["profiles"].asJsonArray) {
val profile = profileEntry.asJsonObject
val profileName = profile["profileName"].asString.lowercase()
@@ -504,7 +505,7 @@ class FarmingWeightDisplay {
attemptingCropWeightFetch = true
val url = "https://api.elitebot.dev/weights"
- val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
+ val result = withContext(dispatcher) { APIUtil.getJSONResponse(url) }.asJsonObject
for (crop in result.entrySet()) {
val cropType = CropType.getByName(crop.key)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
index 035259a1a..31008d9b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
@@ -14,6 +14,7 @@ import java.awt.datatransfer.UnsupportedFlavorException
import kotlin.time.Duration.Companion.milliseconds
object ClipboardUtils {
+ private var dispatcher = Dispatchers.IO
private var lastClipboardAccessTime = SimpleTimeMark.farPast()
private fun canAccessClipboard(): Boolean {
@@ -55,7 +56,7 @@ object ClipboardUtils {
suspend fun readFromClipboard(step: Int = 0): String? {
try {
return try {
- withContext(Dispatchers.IO) {
+ withContext(dispatcher) {
getClipboard()?.getData(DataFlavor.stringFlavor)?.toString()
}
} catch (e: UnsupportedFlavorException) {