From 78334c4cb1c4cc92d3203fa319af3bc8f9745d3a Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 7 May 2022 20:15:29 +0100 Subject: [PATCH] Fix counts in /computercraft {turn-on,shutdown} We were using the size of the selectors (which is normally 1) rather than the number of computers. --- .../shared/command/CommandComputerCraft.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java index f26284228..70e000046 100644 --- a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java +++ b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java @@ -141,9 +141,10 @@ public final class CommandComputerCraft .then( command( "shutdown" ) .requires( UserLevel.OWNER_OP ) .argManyValue( "computers", manyComputers(), s -> ComputerCraft.serverComputerRegistry.getComputers() ) - .executes( ( context, computers ) -> { + .executes( ( context, computerSelectors ) -> { int shutdown = 0; - for( ServerComputer computer : unwrap( context.getSource(), computers ) ) + Set computers = unwrap( context.getSource(), computerSelectors ); + for( ServerComputer computer : computers ) { if( computer.isOn() ) shutdown++; computer.shutdown(); @@ -155,9 +156,10 @@ public final class CommandComputerCraft .then( command( "turn-on" ) .requires( UserLevel.OWNER_OP ) .argManyValue( "computers", manyComputers(), s -> ComputerCraft.serverComputerRegistry.getComputers() ) - .executes( ( context, computers ) -> { + .executes( ( context, computerSelectors ) -> { int on = 0; - for( ServerComputer computer : unwrap( context.getSource(), computers ) ) + Set computers = unwrap( context.getSource(), computerSelectors ); + for( ServerComputer computer : computers ) { if( !computer.isOn() ) on++; computer.turnOn();