Mass player position change bash scripts

Discussion in 'Bukkit Tools' started by mdcollins05, Mar 17, 2012.

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


    I couldn't find any tools to do a mass player position change, so I found a helper utility and made 2 scripts to work with it. In my case, I'm using it to reset players to a spawn point on a map change, while keeping their inventory.

    The 2 scripts rely on nbtedit from the python nbt2yaml library as seen here:

    Make 2 files. Doesn't matter the names but do remember which is which.

    The first file I named and it should contain:
    awk ' BEGIN { RS="" }
          { s="  - Pos: !list_double\n    - !double \"[-+]?[0-9]*\.?[0-9]+\"\n    - !double \"[-+]?[0-9]*\.?[0-9]+\"\n    - !double \"[-+]?[0-9]*\.?[0-9]+\"\n" }
          { r="  - Pos: !list_double\n    - !double \"15.0\"\n    - !double \"70.0\"\n    - !double \"15.0\"\n" }
          FILENAME==ARGV[1] { sub(s,r) ; print }
        ' "$1" > ./temp_file
    mv -f ./temp_file "$1"
    The important part of that file is the 5th line (Starts with { r=...). It needs to be updated to the new coordinates you want. I (believe) it uses the order of X Y Z.

    The second file I named and it should contain:
    for f in $1*.dat
      nbtedit $f
    The important line in that one is the EDITOR= line. It needs to have the filename of the first file in it.

    Once the 2 files are ready, make sure they are executable (chmod +x and the bukkit/minecraft server is off.

    Run the second file from the command like, like so:
    Code: /path/to/world/players/
    After you hit enter, it'll echo all the files it's editing and will make a player.dat.saved for the original file.

    It's been tested for me with no errors for an upcoming new map on my server. Hope it helps someone out.
Thread Status:
Not open for further replies.

Share This Page