Skip to content

Commit

Permalink
Fix bug for CopyPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbear committed Feb 4, 2024
1 parent 6a3e8c3 commit 2d2febf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion palworld_server_toolkit/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,34 @@ def RenamePlayer(player_uid, new_name):
break


def GetPlayerItems(player_uid):
load_skiped_decode(wsd, ["ItemContainerSaveData"])
item_containers = {}
for item_container in wsd["ItemContainerSaveData"]['value']:
item_containers[str(item_container['key']['ID']['value'])] = [{
'ItemId': x['ItemId']['value']['StaticId']['value'],
'SlotIndex': x['SlotIndex']['value'],
'StackCount': x['StackCount']['value']
}
for x in item_container['value']['Slots']['value']['values']
]
player_sav_file = os.path.dirname(os.path.abspath(args.filename)) + "/Players/" + player_uid.upper().replace("-",
"") + ".sav"
if not os.path.exists(player_sav_file):
print("\033[33mWarning: Player Sav file Not exists: %s\033[0m" % player_sav_file)
return
else:
with open(player_sav_file, "rb") as f:
raw_gvas, _ = decompress_sav_to_gvas(f.read())
player_gvas_file = GvasFile.read(raw_gvas, PALWORLD_TYPE_HINTS, PALWORLD_CUSTOM_PROPERTIES)
player_gvas = player_gvas_file.properties['SaveData']['value']
for idx_key in ['CommonContainerId', 'DropSlotContainerId', 'EssentialContainerId', 'FoodEquipContainerId',
'PlayerEquipArmorContainerId', 'WeaponLoadOutContainerId']:
print(" %s" % player_gvas['inventoryInfo']['value'][idx_key]['value']['ID']['value'])
pp.pprint(item_containers[str(player_gvas['inventoryInfo']['value'][idx_key]['value']['ID']['value'])])
print()


def OpenBackup(filename):
global backup_gvas_file, backup_wsd
print(f"Loading {filename}...")
Expand Down Expand Up @@ -1176,7 +1204,7 @@ def LoadPlayers(data_source=None):
playerMeta[player_k] = playerParams[player_k]['value']
if data_source == wsd:
playerMapping = l_playerMapping
l_instanceMapping = instanceMapping
instanceMapping = l_instanceMapping
return l_playerMapping, l_instanceMapping


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = palworld-server-toolkit
version = 0.1.5
version = 0.1.7
author = MagicBear
author_email = [email protected]
description = A toolset for PalWorld Server
Expand Down

0 comments on commit 2d2febf

Please sign in to comment.