aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 22:50:49 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-22 22:51:01 +0200
commit2b5755dc1e3a1d9a93005e28421feb457415c0bb (patch)
tree0f1af62cbe18f0f3b9023e166adb82dd087e35e1 /src/main/java/at/hannibal2/skyhanni/features
parent4dec8bdc1c8131c93e80f078d244790621b76f14 (diff)
downloadskyhanni-2b5755dc1e3a1d9a93005e28421feb457415c0bb.tar.gz
skyhanni-2b5755dc1e3a1d9a93005e28421feb457415c0bb.tar.bz2
skyhanni-2b5755dc1e3a1d9a93005e28421feb457415c0bb.zip
Pupup Warning for Next Jacob's Contest - Opens a popup when the warning time is reached and minecraft is not in focus (default disabled)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt56
1 files changed, 56 insertions, 0 deletions
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 1037d0bb3..7b9e52d14 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -10,11 +10,20 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderSingleLineWithItems
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TimeUtils
import io.github.moulberry.notenoughupdates.util.SkyBlockTime
+import kotlinx.coroutines.launch
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
+import org.lwjgl.opengl.Display
+import java.awt.event.MouseAdapter
+import java.awt.event.MouseEvent
import java.time.Instant
+import javax.swing.JButton
+import javax.swing.JFrame
+import javax.swing.JOptionPane
+import javax.swing.UIManager
class GardenNextJacobContest {
private var display = listOf<Any>()
@@ -215,6 +224,53 @@ class GardenNextJacobContest {
LorenzUtils.chat("§e[SkyHanni] Next farming contest: $cropText")
TitleUtils.sendTitle("§eFarming Contest!", 5_000)
SoundUtils.playBeepSound()
+
+ if (config.nextJacobContestWarnPopup && !Display.isActive()) {
+ SkyHanniMod.coroutineScope.launch {
+ openPopupWindow(
+ "Farming Contest soon!\n" +
+ "Crops: ${cropText.removeColor()}"
+ )
+ }
+ }
+ }
+
+ /**
+ * Taken and modified from Skytils
+ */
+ private fun openPopupWindow(message: String) {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
+ } catch (e: java.lang.Exception) {
+ e.printStackTrace()
+ }
+
+ val frame = JFrame()
+ frame.isUndecorated = true
+ frame.isAlwaysOnTop = true
+ frame.setLocationRelativeTo(null)
+ frame.isVisible = true
+
+ val buttons = mutableListOf<JButton>()
+ val close = JButton("Ok")
+ close.addMouseListener(object : MouseAdapter() {
+ override fun mouseClicked(event: MouseEvent) {
+ frame.isVisible = false
+ }
+ })
+ buttons.add(close)
+
+ val allOptions = buttons.toTypedArray()
+ JOptionPane.showOptionDialog(
+ frame,
+ message,
+ "SkyHanni Jacob Contest Notification",
+ JOptionPane.DEFAULT_OPTION,
+ JOptionPane.INFORMATION_MESSAGE,
+ null,
+ allOptions,
+ allOptions[0]
+ )
}
@SubscribeEvent