diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/commands/MsgCommandIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/commands/MsgCommandIT.kt index 03dd52f01..885134772 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/commands/MsgCommandIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/commands/MsgCommandIT.kt @@ -50,13 +50,13 @@ class MsgCommandIT { } fun validateStack() { - val node = createNode { - assertEquals(it["msg"], "msg") - assertEquals(it["targets"], NameEntityTarget("Bixilon")) - assertEquals(it["message"], "hi there!") - } + var stack: CommandStack? = null + val node = createNode { stack = it.copy() } node.execute("msg Bixilon hi there!") + assertEquals(stack!!["msg"], "msg") + assertEquals(stack!!["targets"], NameEntityTarget("Bixilon")) + assertEquals(stack!!["message"], "hi there!") } fun redirectExecution() { @@ -69,12 +69,14 @@ class MsgCommandIT { } fun redirectStack() { - val node = createNode { - assertEquals(it["msg"], "redirect") - assertEquals(it["targets"], NameEntityTarget("Bixilon")) - assertEquals(it["message"], "hi there!") - } + var stack: CommandStack? = null + val node = createNode { stack = it.copy() } node.execute("redirect Bixilon hi there!") + + + assertEquals(stack!!["msg"], "redirect") + assertEquals(stack!!["targets"], NameEntityTarget("Bixilon")) + assertEquals(stack!!["message"], "hi there!") } } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/commands/TPCommandIT.kt b/src/integration-test/kotlin/de/bixilon/minosoft/commands/TPCommandIT.kt index fbead695e..d1d2b0def 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/commands/TPCommandIT.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/commands/TPCommandIT.kt @@ -50,12 +50,13 @@ class TPCommandIT { } fun relativeStack() { - val node = createNode { - assertEquals(it["tp"], "tp") - assertEquals(it["target"], SelectorEntityTarget(TargetSelectors.SELF, emptyMap())) - assertEquals(it["destination"], Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, +10.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f))) - } + var stack: CommandStack? = null + val node = createNode { stack = it.copy() } node.execute("tp @s ~ ~10 ~") + + assertEquals(stack!!["tp"], "tp") + assertEquals(stack!!["target"], SelectorEntityTarget(TargetSelectors.SELF, emptyMap())) + assertEquals(stack!!["destination"], Vec3Coordinate(Coordinate(CoordinateRelatives.TILDE, 0.0f), Coordinate(CoordinateRelatives.TILDE, +10.0f), Coordinate(CoordinateRelatives.TILDE, 0.0f))) } } diff --git a/src/main/java/de/bixilon/minosoft/commands/stack/CommandStack.kt b/src/main/java/de/bixilon/minosoft/commands/stack/CommandStack.kt index 71f2330f9..c771fa0d9 100644 --- a/src/main/java/de/bixilon/minosoft/commands/stack/CommandStack.kt +++ b/src/main/java/de/bixilon/minosoft/commands/stack/CommandStack.kt @@ -68,4 +68,16 @@ class CommandStack( } return output } + + + fun copy(): CommandStack { + val stack = CommandStack(null, print) + stack.stack += this.stack + stack.executor = this.executor + if (this::connection.isInitialized) { + stack.connection = this.connection + } + + return stack + } }