diff --git a/src/main/kotlin/com/spoiligaming/generator/GeneratorBean.kt b/src/main/kotlin/com/spoiligaming/generator/GeneratorBean.kt index 9a9284c..4e6b0e3 100644 --- a/src/main/kotlin/com/spoiligaming/generator/GeneratorBean.kt +++ b/src/main/kotlin/com/spoiligaming/generator/GeneratorBean.kt @@ -19,7 +19,7 @@ object GeneratorBean { fun startGeneratingNitro() { timer( initialDelay = 0, - period = BaseConfigurationFactory.getInstance().generalSettings.generationDelay.takeIf { it != 0L } ?: 1, + period = BaseConfigurationFactory.getInstance().generalSettings.generationDelay.takeIf { it > 0L } ?: 1, ) { val config = BaseConfigurationFactory.getInstance() // reset isConfigUpdated to ensure concurrent operations work @@ -61,7 +61,7 @@ object GeneratorBean { runBlocking { var index = 0 - repeat(config.multithreadingSettings.threadLimit) { + repeat(config.multithreadingSettings.threadLimit.takeIf { it > 0 } ?: 1) { launch(Dispatchers.IO) { while (isActive && !BaseConfigurationFactory.isConfigUpdated && @@ -81,7 +81,7 @@ object GeneratorBean { semaphore.release() } } - delay(config.multithreadingSettings.threadLaunchDelay) + delay(config.multithreadingSettings.threadLaunchDelay.takeIf { it >= 0 } ?: 0) } } } diff --git a/src/main/kotlin/com/spoiligaming/generator/gui/element/ElementValue.kt b/src/main/kotlin/com/spoiligaming/generator/gui/element/ElementValue.kt index 6c87da0..89061d5 100644 --- a/src/main/kotlin/com/spoiligaming/generator/gui/element/ElementValue.kt +++ b/src/main/kotlin/com/spoiligaming/generator/gui/element/ElementValue.kt @@ -133,14 +133,18 @@ object ElementValue { when (property) { is SimpleIntegerProperty -> { val newValue = property.get().toLong() + increment - property.set(newValue.toInt()) - valueUpdater(newValue.toInt()) + if (newValue >= 0) { + property.set(newValue.toInt()) + valueUpdater(newValue.toInt()) + } } is SimpleLongProperty -> { val newValue = property.get() + increment - property.set(newValue) - valueUpdater(newValue) + if (newValue >= 0) { + property.set(newValue) + valueUpdater(newValue) + } } else -> throw IllegalArgumentException("Unsupported property type")