Skylinerw

Pseudocode command processing

Sep 23rd, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. // The command class itself, where "commandArgs" are the arguments provided for the command
  2.  
  3. CommandBase commandClass = this.getCommandClass(commandArgs[0]);
  4.  
  5. // The target index in the command's syntax (indicating where the selector is)
  6.  
  7. int targetIndex = commandClass.getTargetIndex();
  8.  
  9. if (getsMultipleTargets(commandArgs[targetIndex])) {
  10.    
  11.     // Process the selector using the target index to locate it in the arguments provided
  12.    
  13.     List<Entity> entities = this.processSelector(commandArgs[targetIndex]);
  14.    
  15.     // Cycle through each entity...
  16.    
  17.     for (Entity entity : entities) {
  18.        
  19.         // Replace the selector with a UUID
  20.        
  21.         commandArgs[targetIndex] = entity.getUUID();
  22.        
  23.         // Execute command
  24.        
  25.         commandClass.process(commandArgs);
  26.     }
  27. } else {
  28.    
  29.     // Execute command without any changes, meaning the selector is not processed and is at the whim of the command class
  30.    
  31.     commandClass.process(commandArgs);
  32. }
Add Comment
Please, Sign In to add comment