aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt')
-rw-r--r--src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt53
1 files changed, 46 insertions, 7 deletions
diff --git a/src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt b/src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt
index a05b3a9..4084b08 100644
--- a/src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt
+++ b/src/main/kotlin/xyz/brysonsteck/ServerCraft/dialogs/EulaDialog.kt
@@ -2,15 +2,54 @@ package xyz.brysonsteck.ServerCraft.dialogs
import xyz.brysonsteck.ServerCraft.dialogs.Dialog
import javafx.scene.control.Button
+import javafx.event.EventHandler
+import javafx.event.ActionEvent
+import java.awt.Desktop
+import java.net.URI
class EulaDialog: Dialog {
+ override val type: String
+ override val title: String
+ override val msg: String
+ override val neutralButton: Button?
+ override val yesButton: Button?
+ override val noButton: Button?
- constructor(type: String,
- title: String,
- msg: String,
- yes: String = "Yes",
- no: String = "No",
- neutral: Button?,
- hold: Boolean = true) : super(type, title, msg, yes, no, neutral, hold)
+ constructor() {
+ type = "warning"
+ title = "Minecraft End User License Agreement (EULA)"
+ msg = "Do you agree to the terms of the Minecraft End User License Agreement?"
+
+ noButton = Button("I Disagree")
+ noButton.onAction = EventHandler<ActionEvent>() {
+ result = false
+ dialog.hide()
+ }
+ noButton.isDefaultButton = true
+ yesButton = Button("I Agree")
+ yesButton.onAction = EventHandler<ActionEvent>() {
+ result = true
+ dialog.hide()
+ }
+ neutralButton = Button("View EULA")
+ neutralButton.onAction = EventHandler<ActionEvent>() {
+ val desktop = Desktop.getDesktop()
+ if (desktop.isSupported(Desktop.Action.BROWSE)) {
+ // most likely running on Windows or macOS
+ try {
+ desktop.browse(URI("https://account.mojang.com/documents/minecraft_eula"))
+ } catch (e: Exception) {
+ println(e)
+ }
+ } else {
+ // assume running on linux
+ try {
+ Runtime.getRuntime().exec("xdg-open https://account.mojang.com/documents/minecraft_eula");
+ } catch (e: Exception) {
+ println(e)
+ }
+ }
+ }
+ }
} \ No newline at end of file