Useful perl scripts to import old data.

Discussion in 'Bukkit Tools' started by xrobau, Sep 7, 2011.

Thread Status:
Not open for further replies.
  1. Offline


    We've (/r/minecraftau) recently been reviving some old maps to have a look around. One of the annoying things I've discovered is that no-one has written an importer or parser from Hey0's old warps.txt, and cuboid's protection zones into new Essentials-compatible files.

    So, to save the next person having to do it all over again, here's a couple of scripts.

    1: Convert hey0 warps.txt to Essentials yml files. Note that this grabs the warps.txt file from /tmp, feel free to change it to suit your location. It saves the yml files to the current directory, so it would be best to run this in your plugins/Essentials/warps folder.
    # convert hmod warps.txt to Bukkit Essentials warp format
    open FP,"/tmp/warps.txt" or die;
    while (<FP>) {
        my @a = split(':');
        $name = shift @a;
        open OUT,"> $name.yml" or die;
        print OUT "name: $name\npitch: $a[4]\nz: $a[2]\ny: $a[1]\nx: $a[0]\n";
        print OUT "yaw: $a[3]\n";
        print OUT "world: world\n";
        close OUT;
    # hmod format - "warps.txt":
    # murder:34.50087286234928:64.0:-271.7976912052464:-2611.204:0.4504166:
    # name:x:y:z:yaw:pitch
    2: Convert Cuboid protectedCuboids.txt to WorldGuard regions.yml file
    Note this takes stdin, and outputs to stdout, so you run it like ' < /tmp/protectedCuboids.txt >> regions.yml'. As with the other one, it creates its files in the current directory.
    while (<>) {
            my $line = $_;
            next if ($line =~ /^#/);
            $line =~ s/\r//;
            $line =~ s/\n//;
            # -1127,54,-1442,-1162,62,-1405,o:Mish84 junkz0r,atlantisext
            my ($minx, $miny, $minz, $maxx, $maxy, $maxz, $perms, $name) = split(/,/, $line);
            my $players = "{}";
            my $owners = "{}";
            my @p = split(/ /, $perms);
            while ($user = shift @p) {
                    if ($user eq "city") {
                            $user = "city-owned-land"
                    next if ($user =~ /g:/);
                    if ($user =~ /^o:/)  {
                            $user =~ s/^o://;
                            if ($owners eq "{}") {
                                    $owners = "
          players: [$user, ";
                            } else {
                                    $owners .= "$user, ";
                    } else {
                            if ($players eq "{}") {
                                    $players = "
          players: [$user, ";
                            } else {
                                    $players .= "$user, ";
            $owners =~ s/, $/]/;
            $players =~ s/, $/]/;
            print "  $name:
        min: {z: $minz.0, y: $miny.0, x: $minx.0}
        flags: {}
        max: {z: $maxz.0, y: $maxy.0, x: $maxx.0}
        priority: 0
        type: cuboid
        owners: $owners
        members: $players
    I expect very few people would want this, apart from other big server operators, but if it's here, when someone searches for it, they'll find it!

    Enjoy. If you have any questions, ask here, or catch me anywhere as xrobau. Reddit, gmail, etc.

Thread Status:
Not open for further replies.

Share This Page