b-Universe / b-network

Server scripts for a Minecraft server named B
The Unlicense
3 stars 3 forks source link

Resource Pack Self-Hosting (Draft) #8

Open BehrRiley opened 8 months ago

BehrRiley commented 8 months ago

Three parts to this system, allowing us to host the resource pack directly from our web cloud and the server directly.

Save and Compile Pack

This piece is the first piece but can be skipped for the moment since we can manually upload the pack to it's file location on the web cloud.

Generate the Pack SHA-1

This should be simple; the endpoint opened explicitly for this file: https://api.behr.dev/resource/b.zip That should make the entirety of the script, excluding any debugging or error handling:

- ~webget https://api.behr.dev/resource/b.zip headers:[User-Agent=b] save:response
- flag server behr.essentials.resource.SHA-1:<entry[response].result_binary.hash[SHA-1].to_hex>

this can be updated on startup:

after server start:
  - run resource_fetch

Serve the Resource Pack

Lastly and simply, just serving it on join:

after player joins:
  - resourcepack https://api.behr.dev/resource/b.zip hash:<server.flag[behr.essentials.resource.SHA-1]>

Likely may need something to do with the resource pack status event

BehrRiley commented 7 months ago

The zipping can be done via a script Python API script:

set "FOLDER_NAME=b-resource" set "ZIP_FILE=b.zip"

cd %FOLDER_NAME%

REM Pull the latest changes from the remote repository echo Pulling latest changes from the git repository... git pull

REM Check for git pull errors if errorlevel 1 ( echo Error encountered during 'git pull'. Aborting script. goto End )

REM Using git to archive non-ignored files echo Creating archive of non-ignored files... git archive -o "../%ZIP_FILE%" HEAD

echo Archive created successfully.

:End ENDLOCAL