Advertisement
Guest User

Untitled

a guest
May 24th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.33 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. open(LS, "ls -1 *.dat |");
  4.  
  5. open(MAP, "> uuids.map");
  6.  
  7. while($file = <LS>) {
  8.     chomp $file;
  9.  
  10.     $cmd = "nbt2yaml $file > temp.yml";
  11.     system($cmd);
  12.  
  13.     $file =~ /^(.+)\.dat/;
  14.     $uuid = $1;
  15.    
  16.     open(DAT, "temp.yml");
  17.     while($line = <DAT>) {
  18.         chomp $line;
  19.  
  20.         if ($line =~ /Dimension: (\d+)/) {
  21.             $dimension = $1;
  22.  
  23.             $nr_in_dim[$dimension]++;
  24.  
  25.             if ($dimension == 1) {
  26.                 $x = int($x + 0.5);
  27.                 $y = int($y + 0.5);
  28.                 $z = int($z + 0.5);
  29.                 print "Player [$name] is in the end at ($x, $y, $z)\n";
  30.                 print $uuid . "\n";
  31.                
  32.             }
  33.         }
  34.         elsif ($line =~ / Pos: /) {
  35.             $line = <DAT>;
  36.             $line =~ /\"([0-9\-\.]+)\"/;
  37.             $x = $1;
  38.             $line = <DAT>;
  39.             $line =~ /\"([0-9\-\.]+)\"/;
  40.             $y = $1;
  41.             $line = <DAT>;
  42.             $line =~ /\"([0-9\-\.]+)\"/;
  43.             $z = $1;
  44.         }
  45.         elsif ($line =~ /lastKnownName: (.+)/) {
  46.             $name = $1;
  47.             print MAP "$uuid $name\n";
  48.         }
  49.     }
  50.     close DAT;
  51.    
  52. }  # while
  53.  
  54. close MAP;
  55.  
  56. for($i=-1; $i <= 1; $i++) {
  57.     print "Number in dimension [$i] = " . $nr_in_dim[$i] . "\n";
  58.  
  59. }  # for
  60.  
  61. print "done\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement