Skip to content

Commit c568c2b

Browse files
committed
disable output pins on shutdown
1 parent b03c832 commit c568c2b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cranberri-server-plugin/src/main/kotlin/jupiterpi/cranberri/RunningScript.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package jupiterpi.cranberri
22

33
import jupiterpi.cranberri.runtime.Script
4+
import jupiterpi.cranberri.runtime.api.IO
45
import net.kyori.adventure.text.Component
56
import org.bukkit.Bukkit
67

@@ -39,8 +40,13 @@ class RunningScript(private val computer: Computer, val script: Script) {
3940
catch (e: Exception) { handleError(e) }
4041

4142
Bukkit.getScheduler().runTaskTimer(plugin, { task ->
42-
if (shutdown) task.cancel()
43-
else {
43+
if (shutdown) {
44+
pins.filterIsInstance<OutputPin>().forEach {
45+
it.writeValue(IO.PinValue.LOW)
46+
it.fulfillValue()
47+
}
48+
task.cancel()
49+
} else {
4450
try { script.invokeTick() }
4551
catch (e: Exception) { handleError(e) }
4652
}

0 commit comments

Comments
 (0)