Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.71 KB | None | 0 0
  1. proc(_extractValue, @stringToCheck, @key,
  2.  
  3.     msg(concat('String to check: ', @stringToCheck))
  4.  
  5.     @regx_header = "\\@"; # Regular expression header
  6.     @regx_footer = "([\\w\\d\\s\\n.]+[^\\@])"; # Regular expression footer 
  7.     @regx_pattern = concat(@regx_header, @key, @regx_footer); # Create the regular expression using the supplied key
  8.    
  9.     msg(concat('Regex Pattern Used: ', @regx_pattern))
  10.    
  11.     @result = reg_match(@regx_pattern, @stringToCheck); # Check the string for results
  12.    
  13.     if (array_size(@result) > 1){ # Check to see if the result of the match is greater than 1 which means we found the pattern and the capture group
  14.    
  15.         msg(@result[1])
  16.    
  17.         return (@result[1]); # Return the capture group
  18.    
  19.     }
  20.    
  21.     msg('no results');
  22.     msg(concat('Result Returned: ', @result))
  23.     return (null); # No results found  
  24.  
  25. )
  26.  
  27. register_command(createhero,
  28.  
  29.     array(  
  30.  
  31.         description: 'Generates a Hero using parameters within a book',        
  32.  
  33.         usage: '/createhero',
  34.        
  35.         permission: 'essentials.copybook',
  36.        
  37.         noPermMsg: 'Sorry you don\'t have permission to use this command.',
  38.  
  39.         executor: closure(@alias, @sender, @args) {
  40.        
  41.             @hero_name = null;            
  42.  
  43.             @playerThatRanCmd = player(); # Create a player object
  44.            
  45.             @slotHighlighted = pheld_slot(@playerThatRanCmd)
  46.             @itemInHand = pinv(@playerThatRanCmd, @slotHighlighted); # Grab the ID of the item in the players hand
  47.             @itemMeta =  get_itemmeta(@slotHighlighted); # Grab the meta data      
  48.            
  49.             @pages = @itemMeta['pages']; # Grab all the pages of the book
  50.            
  51.             @hero_name = _extractValue(@pages, "name:");
  52.             msg(@hero_name);                
  53.  
  54.         }
  55.     )
  56. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement