You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating the server.properties to turn on online-mode, after the server was being used in offline mode, the quest progress, teams and player data will be reset for the players. This is caused by different UUID generation used by Mojang for online/offline mode.
The following folders/files contain UUID information that should be updated(as far as I know):
world/advancements - list of .json files
world/betterquesting/QuestingParties.json
world/betterquesting/QuestProgress - list of .json files the files themselves reference the UUID as well
world/betterquesting/NameCache.json
world/playerdata - list of .dat files
As the offline UUID itself does not contain information about the username the server/usernamecache.json can be used to resolve them.
I was experimenting with implementing this myself, havent't really coded in python so reader discretion is advised. 😄
❗ This does not currently contains replacing the UUID's in the QuestProgress files
I tested it and aside from the quest progress other stuff worked.
Edit: Edited 1 questProgress json file manually, and it fixed quest progress as well.
importosimportrequestsimportjsonimportuuid# Paths to player data and other relevant foldersworld_path="/path/to/your/server/world"usernamecache_path="/path/to/your/server/usernamecache.json"# Directories where files need renamingdirectories_to_update= {
"advancements": ".json",
"betterquesting/QuestProgress": ".json",
"playerdata": ".dat"
}
#Some delay between request could be needed, not sure about Mojang API rate limitsdefget_online_uuid(username):
"""Fetch the Mojang online UUID for a given username."""url=f"https://api.mojang.com/users/profiles/minecraft/{username}"response=requests.get(url)
ifresponse.status_code==200:
data=response.json()
returnstr(uuid.UUID(data['id']))
else:
print(f"Could not fetch UUID for {username}")
returnNonedefcreate_uuid_map():
"""Create a map of old UUIDs to their corresponding username and online UUID."""uuid_map= {}
withopen(usernamecache_path, "r") asf:
username_cache=json.load(f)
foroffline_uuid, usernameinusername_cache.items():
online_uuid=get_online_uuid(username)
ifonline_uuid:
uuid_map[offline_uuid] = {
'username': username,
'online_uuid': online_uuid
}
else:
print(f"Skipping {username} due to failed UUID fetch.")
returnuuid_mapdefrename_files(uuid_map):
"""Rename the files based on the UUID map."""foroffline_uuid, datainuuid_map.items():
online_uuid=data['online_uuid']
username=data['username']
# Rename files in specified directoriesforfolder, extensionindirectories_to_update.items():
old_file=os.path.join(world_path, folder, f"{offline_uuid}{extension}")
new_file=os.path.join(world_path, folder, f"{online_uuid}{extension}")
ifos.path.exists(old_file):
os.replace(old_file, new_file)
print(f"Renamed {old_file} to {new_file}")
else:
print(f"No file found for offline UUID {offline_uuid} in {folder}")
# Delete the username cache file after processingos.remove(usernamecache_path)
print(f"Deleted {usernamecache_path}")
defupdate_questing_parties(uuid_map):
"""Directly replace offline UUIDs with online UUIDs in QuestingParties.json."""questing_file=os.path.join(world_path, "betterquesting", "QuestingParties.json")
ifos.path.exists(questing_file):
withopen(questing_file, "r") asf:
questing_data=f.read() # Read the file as text# Replace all instances of the offline UUIDs with the corresponding online UUIDsforoffline_uuid, datainuuid_map.items():
online_uuid=data['online_uuid']
questing_data=questing_data.replace(offline_uuid, online_uuid)
# Write the modified data back to the filewithopen(questing_file, "w") asf:
f.write(questing_data)
print(f"Updated UUIDs in {questing_file}")
else:
print(f"{questing_file} not found.")
# Run the processuuid_map=create_uuid_map() # Step 1: Create the UUID maprename_files(uuid_map) # Step 2: Rename filesupdate_questing_parties(uuid_map) # Step 3: Update QuestingParties.json
The text was updated successfully, but these errors were encountered:
Heyo!
When updating the server.properties to turn on online-mode, after the server was being used in offline mode, the quest progress, teams and player data will be reset for the players. This is caused by different UUID generation used by Mojang for online/offline mode.
The following folders/files contain UUID information that should be updated(as far as I know):
As the offline UUID itself does not contain information about the username the server/usernamecache.json can be used to resolve them.
https://api.mojang.com/users/profiles/minecraft/{username} request can be used to retrieve a user's online UUID, this returns the short form UUID without dashes so a conversion is needed:
str(uuid.UUID(response.json()['id']))
I was experimenting with implementing this myself, havent't really coded in python so reader discretion is advised. 😄
❗ This does not currently contains replacing the UUID's in the QuestProgress files
I tested it and aside from the quest progress other stuff worked.
Edit: Edited 1 questProgress json file manually, and it fixed quest progress as well.
The text was updated successfully, but these errors were encountered: