From b7dc33f79e9aeb1814132383c8a19b488a449eca Mon Sep 17 00:00:00 2001 From: Carl Andersson Date: Thu, 11 Nov 2021 06:31:35 +0100 Subject: [PATCH] Keybinding: If JIntellitype fails to load, still allow server to run --- src/main/java/io/eiren/vr/Keybinding.java | 37 ++++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/eiren/vr/Keybinding.java b/src/main/java/io/eiren/vr/Keybinding.java index 0e7d5b11d..d790850f7 100644 --- a/src/main/java/io/eiren/vr/Keybinding.java +++ b/src/main/java/io/eiren/vr/Keybinding.java @@ -1,6 +1,7 @@ package io.eiren.vr; import com.melloware.jintellitype.JIntellitype; +import com.melloware.jintellitype.JIntellitypeException; import com.melloware.jintellitype.HotkeyListener; import io.eiren.util.ann.AWTThread; import io.eiren.util.logging.LogManager; @@ -14,24 +15,30 @@ public class Keybinding implements HotkeyListener { public Keybinding(VRServer server) { this.server = server; - if(JIntellitype.isJIntellitypeSupported()) { - JIntellitype.getInstance().addHotKeyListener(this); + try { + if(JIntellitype.isJIntellitypeSupported()) { + JIntellitype.getInstance().addHotKeyListener(this); - String resetBinding = this.server.config.getString("keybindings.reset"); - if(resetBinding == null) { - resetBinding = "CTRL+ALT+SHIFT+Y"; - this.server.config.setProperty("keybindings.reset", resetBinding); - } - JIntellitype.getInstance().registerHotKey(RESET, resetBinding); - LogManager.log.info("[Keybinding] Bound reset to " + resetBinding); + String resetBinding = this.server.config.getString("keybindings.reset"); + if(resetBinding == null) { + resetBinding = "CTRL+ALT+SHIFT+Y"; + this.server.config.setProperty("keybindings.reset", resetBinding); + } + JIntellitype.getInstance().registerHotKey(RESET, resetBinding); + LogManager.log.info("[Keybinding] Bound reset to " + resetBinding); - String quickResetBinding = this.server.config.getString("keybindings.quickReset"); - if(quickResetBinding == null) { - quickResetBinding = "CTRL+ALT+SHIFT+U"; - this.server.config.setProperty("keybindings.quickReset", quickResetBinding); + String quickResetBinding = this.server.config.getString("keybindings.quickReset"); + if(quickResetBinding == null) { + quickResetBinding = "CTRL+ALT+SHIFT+U"; + this.server.config.setProperty("keybindings.quickReset", quickResetBinding); + } + JIntellitype.getInstance().registerHotKey(QUICK_RESET, quickResetBinding); + LogManager.log.info("[Keybinding] Bound quick reset to " + quickResetBinding); } - JIntellitype.getInstance().registerHotKey(QUICK_RESET, quickResetBinding); - LogManager.log.info("[Keybinding] Bound quick reset to " + quickResetBinding); + } + catch (JIntellitypeException je) + { + LogManager.log.info("[Keybinding] JIntellitype initialization failed. Keybindings will be disabled. Try restarting your computer."); } }