Skip to content

Commit

Permalink
fixed several bugs and logical issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SpoilerRules committed Apr 7, 2024
1 parent 77d6db5 commit b128ec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/com/spoiligaming/generator/GeneratorBean.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand All @@ -81,7 +81,7 @@ object GeneratorBean {
semaphore.release()
}
}
delay(config.multithreadingSettings.threadLaunchDelay)
delay(config.multithreadingSettings.threadLaunchDelay.takeIf { it >= 0 } ?: 0)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit b128ec2

Please sign in to comment.