aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt56
2 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index d7bae165f..e764e4adf 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -717,6 +717,12 @@ public class Garden {
public int nextJacobContestWarnTime = 60 * 2;
@Expose
+ @ConfigOption(name = "Pupup Warning", desc = "Opens a popup when the warning time is reached and minecraft is not in focus.")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 14)
+ public boolean nextJacobContestWarnPopup = false;
+
+ @Expose
public Position nextJacobContestPos = new Position(-278, 11, false, true);
@Expose
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