Permalink
Browse files

Check for valid ID

  • Loading branch information...
dirthsj committed Dec 3, 2017
1 parent de3fe99 commit 684e78c5001ec7169d604bd3cee1b4b4a82709dd
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/main/java/dan200/computercraft/ComputerCommand.java
@@ -25,9 +25,15 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
if( args.length < 2 ){
throw new CommandException( "Usage: /computer <id> <value1> [value2]..." );
}
int id;
try {
id = Integer.valueOf(args[0]);
}catch( NumberFormatException e ){
throw new CommandException( "Invalid ID" );
}
boolean found_valid_computer = false;
for( ServerComputer computer : ComputerCraft.serverComputerRegistry.getComputers() ){
if( computer.getID() == Integer.valueOf( args[0] ) && computer.getFamily() == ComputerFamily.Command ){
if( computer.getID() == id && computer.getFamily() == ComputerFamily.Command ){
computer.queueEvent("computer_command", ArrayUtils.remove(args, 0));
found_valid_computer = true;
}

0 comments on commit 684e78c

Please sign in to comment.