Created
October 17, 2020 12:01
-
-
Save crabdancing/37125dad2ef81f00f5face5cef811737 to your computer and use it in GitHub Desktop.
NBT inventory scanner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # Copyleft (C) Alexandria Pettit 2020 | |
| # Bit of trash code to automatically scan a collection of minecraft world directories | |
| # for a NBT item in all player inventories. | |
| # Pretty simple :) | |
| import nbtlib | |
| from pathlib import Path | |
| def scanPlayerNBT(path): | |
| nbt = nbtlib.load(path) | |
| for item in nbt.root['Inventory']: | |
| if 'computer' in item['id']: | |
| print(f'Item {item["id"]} found in {path}!!!!!') | |
| def main(): | |
| for world_path in Path('.').iterdir(): | |
| print(f'Scanning world {world_path}') | |
| try: | |
| try: | |
| for player_dat_file in (world_path / 'playerdata').iterdir(): | |
| scanPlayerNBT(player_dat_file) | |
| except NotADirectoryError: | |
| print('Path is not a directory! Skipping...') | |
| continue | |
| except FileNotFoundError: | |
| print('Couldn\'t find file! Skipping...') | |
| continue | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment