Redundant safety checks

This commit is contained in:
ceikry 2021-08-05 16:36:32 -05:00
parent d71cc7c8e2
commit 5b3a6bcf5e
2 changed files with 24 additions and 8 deletions

View file

@ -13,7 +13,7 @@ object SlayerTracker {
const val textX = 7
const val textY = 50
const val spriteY = 30
val boxColor = GameConfig.slayerTrackerColor.toInt(16)
val boxColor = GameConfig.slayerTrackerColor.toIntOrNull(16) ?: 6116423
@JvmField
var lastUpdate = 0L

View file

@ -50,20 +50,32 @@ class GameConfig {
@JvmField
var RCM_BG_COLOR = 6116423
@JvmField
@JvmStatic
var RCM_BG_OPACITY = 255
set(value) {
if(value > 255 || value < 0) field = 255
else field = value
}
@JvmField
var RCM_TITLE_COLOR = 0
@JvmField
@JvmStatic
var RCM_TITLE_OPACITY = 255
set(value) {
if(value > 255 || value < 0) field = 255
else field = value
}
@JvmField
var RCM_BORDER_COLOR = 0
@JvmField
@JvmStatic
var RCM_BORDER_OPACITY = 255
set(value) {
if(value > 255 || value < 0) field = 255
else field = value
}
@JvmField
var RCM_TITLE = "<col=0>Choose Option</col>"
@ -131,8 +143,12 @@ class GameConfig {
@JvmField
var slayerTrackerColor = "#635a38"
@JvmField
@JvmStatic
var slayerTrackerOpacity = 180
set(value) {
if(value > 255 || value < 0) field = 255
else field = value
}
@JvmField
var slayerTaskID = 0
@ -179,7 +195,7 @@ class GameConfig {
//background
if(rcm.containsKey("background")){
val bg = rcm["background"] as JSONObject
if(bg.containsKey("color")) RCM_BG_COLOR = bg["color"].toString().replace("#", "").toInt(16) //convert hex -> deci
if(bg.containsKey("color")) RCM_BG_COLOR = bg["color"].toString().replace("#", "").toIntOrNull(16) ?: 6116423//convert hex -> deci
if(bg.containsKey("opacity")) RCM_BG_OPACITY = bg["opacity"].toString().toInt()
}
@ -187,14 +203,14 @@ class GameConfig {
if(rcm.containsKey("title_bar")){
val tb = rcm["title_bar"] as JSONObject
if(tb.containsKey("font_color")) RCM_TITLE = RCM_TITLE.replace("0", tb["font_color"].toString().replace("#", ""))
if(tb.containsKey("color")) RCM_TITLE_COLOR = tb["color"].toString().replace("#", "").toInt(16) //convert hex -> deci
if(tb.containsKey("color")) RCM_TITLE_COLOR = tb["color"].toString().replace("#", "").toIntOrNull(16) ?: 6116423//convert hex -> deci
if(tb.containsKey("opacity")) RCM_TITLE_OPACITY = tb["opacity"].toString().toInt()
}
//border
if(rcm.containsKey("border")){
val border = rcm["border"] as JSONObject
if(border.containsKey("color")) RCM_BORDER_COLOR = border["color"].toString().replace("#", "").toInt(16) //convert hex -> deci
if(border.containsKey("color")) RCM_BORDER_COLOR = border["color"].toString().replace("#", "").toIntOrNull(16) ?: 6116423 //convert hex -> deci
if(border.containsKey("opacity")) RCM_BORDER_OPACITY = border["opacity"].toString().toInt()
}