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/features/garden/GardenLevelDisplay.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt9
3 files changed, 17 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
index 5f2b50e82..38e1c319e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenLevelDisplay.kt
@@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.roundToInt
+import kotlin.time.Duration.Companion.milliseconds
class GardenLevelDisplay {
private val config get() = SkyHanniMod.feature.garden
@@ -48,10 +49,12 @@ class GardenLevelDisplay {
val newLevel = GardenAPI.getLevelForExp(gardenExp.toLong())
if (newLevel == oldLevel + 1) {
if (newLevel > 15) {
- LorenzUtils.chat(
- " \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" +
- " §8+§aRespect from Elite Farmers and SkyHanni members :)\n "
- )
+ LorenzUtils.runDelayed(50.milliseconds) {
+ LorenzUtils.chat(
+ " \n§b§lGARDEN LEVEL UP §8$oldLevel ➜ §b$newLevel\n" +
+ " §8+§aRespect from Elite Farmers and SkyHanni members :)\n "
+ )
+ }
}
}
update()
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
index a7585702f..09ce8a835 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ClipboardUtils.kt
@@ -11,8 +11,6 @@ import java.awt.datatransfer.Clipboard
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection
import java.awt.datatransfer.UnsupportedFlavorException
-import java.util.*
-import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
object ClipboardUtils {
@@ -26,20 +24,12 @@ object ClipboardUtils {
return result
}
- private fun runDelayed(duration: Duration, runnable: () -> Unit) {
- Timer().schedule(object : TimerTask() {
- override fun run() {
- runnable()
- }
- }, duration.inWholeMilliseconds)
- }
-
private suspend fun getClipboard(): Clipboard? {
val deferred = CompletableDeferred<Clipboard?>()
if (canAccessClibpard()) {
deferred.complete(Toolkit.getDefaultToolkit().systemClipboard)
} else {
- runDelayed(5.milliseconds) {
+ LorenzUtils.runDelayed(5.milliseconds) {
SkyHanniMod.coroutineScope.launch {
deferred.complete(getClipboard())
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 04de2d696..08f88ea17 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -33,6 +33,7 @@ import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KMutableProperty1
import kotlin.reflect.KProperty
import kotlin.reflect.KProperty0
+import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
object LorenzUtils {
@@ -485,4 +486,12 @@ object LorenzUtils {
val isDerpy get() = recalculateDerpy.getValue()
fun Int.derpy() = if (isDerpy) this / 2 else this
+
+ fun runDelayed(duration: Duration, runnable: () -> Unit) {
+ Timer().schedule(object : TimerTask() {
+ override fun run() {
+ runnable()
+ }
+ }, duration.inWholeMilliseconds)
+ }
} \ No newline at end of file