Skip to content

Commit

Permalink
Merge pull request #3 from adefee/development
Browse files Browse the repository at this point in the history
Paver v2.0.X: Complete rewrite, supports much larger (15+GB) file sizes.
  • Loading branch information
adefee authored Feb 7, 2024
2 parents 4af0c31 + 6880032 commit b64e31c
Show file tree
Hide file tree
Showing 38 changed files with 5,146 additions and 814 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/package-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build & Package Dev, Cut Pre-Release
on:
push:
branches:
- development
jobs:
package:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Git describe
id: ghd
uses: proudust/gh-describe@v1
# Configure to pull internal Packages, then Yarn Install
- name: Setup NodeJS for NPMJS Build Step
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Get version from package.json
id: package_version
run: echo "::set-output name=VERSION::$(node -p "require('./package.json').version")"
shell: bash
- name : Prep Release Zip
shell: bash
run: |
mkdir bin
cp LICENSE bin/
mv paver-v${{ steps.package_version.outputs.VERSION }}.zip bin/
cp README.md bin/
cp helpers bin/ -r
cp config.example.json bin/config.example.json
- uses: actions/upload-artifact@v4
with:
name: paver-v${{ steps.package_version.outputs.VERSION }}
path: bin/
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
bin/paver-v${{ steps.package_version.outputs.VERSION }}.zip
bin/config.example.json
bin/helpers
LICENSE
README.md
generate_release_notes: true
prerelease: true
37 changes: 17 additions & 20 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Package and Release
name: Build & Package Dev, Cut Pre-Release
on:
push:
branches:
- main
tags:
# Only run workflow on pure-semantic tags for now.
tags:
# Only run workflow on tags with the format vx.y.z
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
package:
Expand All @@ -21,36 +21,33 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Install Packager
run: npm install -g pkg
- name: Install Local Build Dependencies
run: npm install
- name : Build
run: npm run package-all
- shell: bash
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Get version from package.json
id: package_version
run: echo "::set-output name=VERSION::$(node -p "require('./package.json').version")"
shell: bash
- name : Prep Release Zip
shell: bash
run: |
mkdir bin
cp LICENSE bin/
mv paver-v${{ steps.package_version.outputs.VERSION }}.zip bin/
cp README.md bin/
cp helpers bin/ -r
cp config.example.json bin/config.example.json
echo '{"gameSaveDirectoryPath": ""}' > bin/config.json
cd bin
zip -r ./paver-${{steps.ghd.outputs.describe}}-all.zip *
- uses: actions/upload-artifact@v4
with:
name: bin
name: paver-v${{ steps.package_version.outputs.VERSION }}
path: bin/

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
bin/paver-win.exe
bin/paver-linux
bin/paver-macos
bin/paver-${{steps.ghd.outputs.describe}}-all.zip
bin/paver-v${{ steps.package_version.outputs.VERSION }}.zip
bin/config.example.json
bin/config.json
bin/helpers
LICENSE
README.md
generate_release_notes: true
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,18 @@ reports/
reports/*
report/
report/*
build/
build/*
datastore/
datastore/*
helpers/updatePlayersInLevelSav.exe
helpers/cheahjs-save-tools/
helpers/cheahjs-save-tools/*

# Output of pre-build/packaging
index-out.js
sea-prep.blob
paver.exe
paver-build.js
# Not ideal, but for now, including the paver-*.zip release bundles
!paver-*.zip
41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# **Paver**: A Palworld Save Editor
A comprehensive and extensible save editor and reporting tool for Palworld, intended to work with any version of Palworld v0.1.4.0 and above. Point it to your save directory (where your Level.sav is) and go!
A comprehensive and extensible save editor and reporting tool for Palworld, intended to work with any version of Palworld v0.1.2.0 and above. Point it to your save directory (where your Level.sav is) and go!

This project is in early development (in fact, in its first release). I've tried to make it user-friendly and safety-first (don't write changes if anything goes wrong), but **I'll always recommend making a backup of your save before using this tool.**
This project is in early development. I've tried to make it user-friendly and safety-first (don't write changes if anything goes wrong), but **I'll always recommend making a backup of your save before using this tool.**

> Questions? Bugs? Ideas? [Join the Paver Discord](https://discord.gg/tu2rnEBWn9)
Expand Down Expand Up @@ -30,14 +30,16 @@ This project is in early development (in fact, in its first release). I've tried
- Windows users: You can install [Python 3.12 from the Microsoft Store](https://apps.microsoft.com/detail/9NCVDN91XZQP) or from [python.org](https://www.python.org/)
- See the [palworld-save-tools README](https://github.com/cheahjs/palworld-save-tools) for updates and more information.

## First Time Run
2. The `ijson` module for Python is required for the save conversion process, but **Paver will attempt to install it for you** if you don't already have it.
- *This is not needed if your save files are already in JSON format.*
- If you see errors about `ijson`, or see an error related to `helpers/updatePlayersInLevelSav.py`, you can workaround this by installing `ijson` yourself. Just open command prompt, type "pip install ijson", and hit enter. Then restart Paver and you should be good!

## Getting Started: Run Paver!
1) **Install any necessary prerequisites (see above).**

2) **Download the latest release from from [Releases](https://github.com/adefee/palworld-save-editor/releases/latest).** For most users, you'll want to grab `paver-win.exe`. You may also find the other files helpful, or the zip file that includes all assets in the release, if you prefer.

> Note: I normally run from source, so I have only tested the Windows build. **I build for Linux and OSX, too, but I haven't tested them.**
3) Setup your config file. Create a file in the same directory where you downloaded the release, and name it `config.json`. The contents of the file should look something like this:
3) Create a config file, or run Paver once to create one for you. The config file is a JSON file that tells Paver what to do. Later, we might have a nice UI to do this for you - but in the meantime, here's a basic example to get you started:

```json
{
Expand All @@ -49,11 +51,11 @@ This project is in early development (in fact, in its first release). I've tried

- All other fields are optional. You can see a full list of options in [Config Options](#config-options). Reporting, changelogs, and guardrails (help make sure you don't set something wrong) are **enabled by default**.

> Advanced: Add the -c flag to the command to specify a different config file location or name. For example, `paver -c ./my-config.json``.
> Advanced: Add the config flag to the command to specify a different config file location or name. For example, `paver config=./my-config.json``.
4) Run the executable you downloaded. It will pick up your `config.json` file and start working based on what you've added. Check out the [Examples](#config-examples) to see some common use cases.
4) Run the executable you downloaded. It will pick up your config file and start working based on what you've added. Check out the [Examples](#config-examples) to see some common use cases.

## Running from Source
## Advanced: Running from Source
If you want to run Paver as a Node app, feel free! You'll need to have ateast Node.js installed, and then you can run the following commands to get started:

```bash
Expand Down Expand Up @@ -153,23 +155,18 @@ Below is a list of all currently available options for the `config.json` file. A
```json
{
"gameSaveDirectoryPath": "C:\\path\\to\\your\\save\\directory",
"savToJsonConversion": {
"enable": true,
"repoUrl": "https://github.com/cheahjs/palworld-save-tools.git",
"relativeInstallPath": "./palworld-save-tools-cheahjs",
"convertFreshEveryRun": true,
"cleanUpJsonAfterConversion": true
},
"removeAttribution": false,
"skipSavJsonConversion": false,
"cheahJsToolsInstallPath": "./helpers/cheahjs-save-tools",
"cheahJsToolsVersion": "0.18.0",
"cheahJsToolsDownloadUrl": "https://github.com/cheahjs/palworld-save-tools/releases/download/v0.18.0/palworld-save-tools-windows-v0.18.0.zip",
"useCustomDataStorePath": false,
"cleanUpDataStore": true,
"reporting": {
"export": true,
"exportPath": "./reports",
"showSummary": true,
"showCapturedPals": true,
"showPlayerData": true,
"showPlayerUnlockedRecipes": true,
"showPlayerAppearance": true,
"showChangesMade": true
},
"changesToMake": {
"enableGuardrails": true,
Expand All @@ -193,7 +190,7 @@ Below is a list of all currently available options for the `config.json` file. A
"unlockedFastTravels": [
"soon - fast travels will be added here soon!"
],
"relicsInPossession": 0,
"countEffigiesFound": 0,
"currentHp": 50000,
"maxHp": 50000,
"maxSp": 50000,
Expand Down Expand Up @@ -233,7 +230,7 @@ Below is a list of all currently available options for the `config.json` file. A
```

### Options Rundown
Adding this ASAP - it's late and I'm sleepy.
Deeper details on each option and what it does will be added here soon.


## Planned Improvements & Features
Expand Down
58 changes: 58 additions & 0 deletions helpers/updatePlayersInLevelSav.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import ijson
import json
import os
import argparse
from decimal import Decimal

def default(obj):
if isinstance(obj, Decimal):
return float(obj)
raise TypeError(f"Object of type {obj.__class__.__name__} is not JSON serializable")

def process_json_files_in_folder(folder_path, character_data):
# print(f"Processing folder: {folder_path}")
for entry in os.listdir(folder_path):
full_path = os.path.join(folder_path, entry)
if os.path.isdir(full_path):
# If the entry is a directory, recursively process it
process_json_files_in_folder(full_path, character_data)
elif entry.endswith('.json'):
with open(full_path, 'r', encoding='utf-8') as file:
data = json.load(file)
character_data.append(data)
# print(f"Processed file: {entry}")

def insert_into_large_json(large_json_path, small_jsons_folder, insertion_path):
character_data = []

for subfolder in os.listdir(small_jsons_folder):
subfolder_path = os.path.join(small_jsons_folder, subfolder)
if os.path.isdir(subfolder_path):
process_json_files_in_folder(subfolder_path, character_data)

if not character_data:
print("No data found in small JSON files.")
return

with open(large_json_path, 'r', encoding='utf-8') as file:
large_json_data = json.load(file)

insertion_point = large_json_data
path_parts = insertion_path.split('.')
for part in path_parts[:-1]:
insertion_point = insertion_point[part]

insertion_point[path_parts[-1]] = character_data

with open(large_json_path, 'w', encoding='utf-8') as file:
json.dump(large_json_data, file, default=default, indent=2)

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Insert data from small JSON files into a specific point in a large JSON file.')
parser.add_argument('large_json_path', type=str, help='Path to the large JSON file')
parser.add_argument('small_jsons_folder', type=str, help='Folder containing subfolders with small JSON files')
parser.add_argument('insertion_path', type=str, help='Insertion path within the large JSON file')

args = parser.parse_args()

insert_into_large_json(args.large_json_path, args.small_jsons_folder, args.insertion_path)
Loading

0 comments on commit b64e31c

Please sign in to comment.