26 Commits
v0.0.3 ... main

Author SHA1 Message Date
Joey Eamigh
beee80e950 dynmap and sleep 2023-06-22 23:49:57 -04:00
Joey Eamigh
ca871d405f mouse tweaks 2023-06-22 22:42:39 -04:00
Joey Eamigh
b7ebfff483 adding hwyla 2023-06-22 22:22:13 -04:00
Joey Eamigh
2212331039 removing multiverse plugin on suspicion of lag 2023-06-22 22:16:25 -04:00
Joey Eamigh
9d28fe80aa removing bountifulbaubles 2023-06-22 22:00:46 -04:00
Joey Eamigh
5ae6a336c1 Merge remote-tracking branch 'refs/remotes/origin/main' 2023-06-22 21:52:33 -04:00
Joey Eamigh
81824cf44f backpacks and baubles 2023-06-22 21:52:20 -04:00
Joey Eamigh
8ec387f4e3 server updates 2023-06-23 00:52:49 +00:00
Joey Eamigh
23ed3e5d97 allow illegal access 2023-06-23 00:36:33 +00:00
Joey Eamigh
560217cd38 update forge version and fix arclight 2023-06-22 23:19:57 +00:00
Joey Eamigh
519e2c8f6d smattering of server changes 2023-06-22 22:56:07 +00:00
Joey Eamigh
f13458073e arclight and another client tweak 2023-06-22 17:31:51 -04:00
Joey Eamigh
315746073d desktop shortcut 2023-06-22 17:01:04 -04:00
Joey Eamigh
d9b87f40ef customizable player models mod 2023-06-22 15:12:45 -04:00
Joey Eamigh
a38910cbaf macos support 2023-06-22 13:39:56 -04:00
Joey Eamigh
93409a83f8 fixed scripts 2023-06-22 00:40:28 -04:00
Joey Eamigh
45d7fe07a5 more windows tomfoolery 2023-06-22 00:27:49 -04:00
Joey Eamigh
dac9469b37 lootr 2023-06-21 23:24:15 -04:00
Joey Eamigh
e3ae3fe83d update 2023-06-21 23:17:17 -04:00
Joey Eamigh
9bea47ca50 Merge remote-tracking branch 'refs/remotes/origin/main' 2023-06-21 22:29:10 -04:00
Joey Eamigh
3707ff5551 downloader.jar not zip 2023-06-21 22:28:58 -04:00
Joey Eamigh
3cb9b47004 server 2023-06-22 02:27:21 +00:00
Joey Eamigh
8373c48de8 server start point 2023-06-21 22:06:33 -04:00
Joey Eamigh
b885e5e3b3 adding api key 2023-06-21 21:31:45 -04:00
Joey Eamigh
1e9379636d windows-compatible modpack downloader 2023-06-21 21:24:13 -04:00
Joey Eamigh
7682582364 windows fixes 2023-06-21 20:34:44 -04:00
26 changed files with 528 additions and 75 deletions

View File

@@ -8,7 +8,7 @@ This is the repo for FishPog Pixelmon, and a bit of experimental tooling to make
git clone https://git.233hfd.com/joey/FishPogPixelmon.git
cd FishPogPixelmon
source ./venv.sh # or just venv.bat on windows
source ./venv.sh # or just venv.ps1 on windows
python tooling.py --setup
```
@@ -21,4 +21,8 @@ now, pax will be installed, which will allow you to edit the modpack. refer to t
python tooling.py --export
```
this command will package up the pack with pax, then bundle some scripts with it that allows for auto-updating and automatically downloading the mods from curseforge, rather than having to distribute a large zip file.
## exporting the modpack client
```bash
python tooling.py --client
```

View File

@@ -1,45 +1,32 @@
# got to the directory where the script is located
Push-Location $PSScriptRoot
# check if winget is installed and if so, set a flag to true
$winget = Get-Command winget -ErrorAction SilentlyContinue
# trust desktop-shortcut.ps1 for good measure
Unblock-File .\desktop-shortcut.ps1
if (!$winget) {
Write-Host "Error: winget is not installed." -Foreground Red
Write-Host "This script probably will not work without winget." -Foreground Red
Write-Host "Run 'Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe' in to install winget." -Foreground Red
Write-Host "If you do install winget, this script should handle the rest." -Foreground Red
}
# Check that python is installed
if (-not (Get-Command "python" -ErrorAction SilentlyContinue)) {
Write-Host "Error: python is not installed." -Foreground Red
if ($winget) {
Write-Host "Attempting to install python."
winget install --id=Python.Python.3.11 -e
}
else {
Write-Host "Please install python to continue." -Foreground Red
exit 1
}
Write-Host "This script will not work without winget." -Foreground Red
Write-Host "Please install winget - trying to open Microsoft Store" -Foreground Yellow
Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
Start-Process "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1"
exit 1
}
# Check that java is installed
if (-not (Get-Command "java" -ErrorAction SilentlyContinue)) {
if (-not (Get-Command "C:\Program Files\AdoptOpenJDK\jdk-11.0.11.9-hotspot\bin\java" -ErrorAction SilentlyContinue)) {
Write-Host "Error: java is not installed." -Foreground Red
if ($winget) {
Write-Host "Attempting to install java."
winget install AdoptOpenJDK.OpenJDK.11
}
else {
Write-Host "Please install java to continue." -Foreground Red
exit 1
}
Write-Host "Attempting to install java."
winget install AdoptOpenJDK.OpenJDK.11
}
if (Test-Path ".venv") { } else { python -m venv .venv }
if (-not (Test-Path ".venv")) { python -m venv .venv }
. ./.venv/bin/Activate.ps1
. .\.venv\Scripts\Activate.ps1
(python -m pip install --upgrade pip) | Out-Null
(python -m pip install -r requirements.txt) | Out-Null

View File

@@ -6,27 +6,31 @@ from typing import Any
OS = sys.platform
MOD_DOWNLOADER_URL = "https://github.com/Advik-B/CMPDL/releases/download/v3.0.0/CMPDL-raw.ZipApp.zip"
MOD_DOWNLOADER_URL = "https://github.com/Joshyx/ModpackDownloader/releases/download/v1.3/ModpackDownloader-1.3.jar"
MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon/releases?limit=1"
DELETION_EXEMPTED_MODS = ["TrainerCommands-1.16.5-2.6.0.jar", "OptiFine_1.16.5_HD_U_G8.jar"]
MULTIMC_DOWNLOAD_URL_WINDOWS = "https://files.multimc.org/downloads/mmc-develop-win32.zip"
MULTIMC_PARENT_DIR = ""
MULTIMC_DIR = ""
INSTANCE_DIR = ""
if OS == "darwin":
cprint("no support for macos yet", "red")
exit(1)
MULTIMC_PARENT_DIR = "/Applications/MultiMC.app"
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/Data"
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
if OS == "linux":
MULTIMC_PARENT_DIR = f"{os.getenv('HOME')}/.local/share"
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/multimc"
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
if OS == "windows":
MULTIMC_PARENT_DIR = f"{os.getenv('APPDATA')}/FishPog"
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}/MultiMC"
INSTANCE_DIR = f"{MULTIMC_DIR}/instances/FishPogPixelmon"
if OS == "win32":
MULTIMC_PARENT_DIR = os.getcwd()
MULTIMC_DIR = f"{MULTIMC_PARENT_DIR}\\MultiMC"
INSTANCE_DIR = f"{MULTIMC_DIR}\\instances\\FishPogPixelmon"
# main
@@ -44,30 +48,60 @@ def run_mmc():
cprint("ready to go! starting multimc!", "green")
os.chdir(MULTIMC_DIR)
if OS == "windows":
if OS == "win32":
subprocess.Popen(["MultiMC.exe"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if OS == "linux":
subprocess.Popen(["./MultiMC"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if OS == "darwin":
subprocess.Popen(["open", "-a", "MultiMC"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
# mods
def mods():
os.chdir(INSTANCE_DIR)
if not os.path.exists(f"{INSTANCE_DIR}/downloader.zip"):
cprint("downloader.zip not found - downloading", "yellow")
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.jar")):
cprint("downloader.jar not found - downloading", "yellow")
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
open("downloader.zip", "wb").write(r.content)
open("downloader.jar", "wb").write(r.content)
cprint("downloading mods. this may take a while, please wait.", "green")
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
for file in glob.glob(f"{INSTANCE_DIR}/mods/*"):
name = os.path.basename(file)
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft/mods", name))
my_env = os.environ.copy()
my_env["CURSEFORGE_API_KEY"] = "$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO"
shutil.rmtree(f"{INSTANCE_DIR}/mods")
os.makedirs(os.path.join(INSTANCE_DIR, "mods"))
if OS != "win32":
subprocess.run(["java", "-jar", "downloader.jar", ".", "mods"], env=my_env)
else:
subprocess.run(
[
"C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.11.9-hotspot\\bin\\java",
"-jar",
"downloader.jar",
".",
"mods",
],
env=my_env,
)
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
if os.path.basename(file) in DELETION_EXEMPTED_MODS:
continue
os.remove(file)
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "mods", "*")):
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks"), exist_ok=True)
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "resourcepacks", "*")):
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks", os.path.basename(file))):
continue
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks", os.path.basename(file)))
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
cprint("mods downloaded successfully", "green")
@@ -97,7 +131,7 @@ def instance():
def download_instance(release: dict[str, Any]):
os.makedirs(f"{INSTANCE_DIR}/.minecraft", exist_ok=True)
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft"), exist_ok=True)
TMP = tempfile.mkdtemp()
os.chdir(TMP)
@@ -108,24 +142,35 @@ def download_instance(release: dict[str, Any]):
shutil.unpack_archive("instance.zip", ".")
os.remove("instance.zip")
for file in glob.glob(f"{TMP}/overrides/*"):
if file == f"{TMP}/overrides/options.txt" and os.path.exists(f"{INSTANCE_DIR}/.minecraft/options.txt"):
for file in glob.glob(os.path.join(TMP, "overrides", "*")):
if file == os.path.join(TMP, "overrides", "options.txt") and os.path.exists(
os.path.join(INSTANCE_DIR, ".minecraft", "options.txt")
):
continue
name = os.path.basename(file)
shutil.move(file, os.path.join(f"{INSTANCE_DIR}/.minecraft", name))
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
if os.path.isdir(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
shutil.rmtree(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
else:
os.remove(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
shutil.rmtree(f"{TMP}/overrides")
shutil.rmtree(os.path.join(TMP, "overrides"))
for file in glob.glob(f"{TMP}/*"):
name = os.path.basename(file)
shutil.move(file, os.path.join(INSTANCE_DIR, name))
shutil.rmtree(TMP)
for file in glob.glob(os.path.join(TMP, "*")):
if os.path.exists(os.path.join(INSTANCE_DIR, os.path.basename(file))):
if os.path.isdir(os.path.join(INSTANCE_DIR, os.path.basename(file))):
shutil.rmtree(os.path.join(INSTANCE_DIR, os.path.basename(file)))
else:
os.remove(os.path.join(INSTANCE_DIR, os.path.basename(file)))
shutil.move(file, os.path.join(INSTANCE_DIR, os.path.basename(file)))
os.chdir(INSTANCE_DIR)
shutil.copy(
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"), os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")
)
if not os.path.exists(os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png")):
os.makedirs(os.path.join(MULTIMC_DIR, "icons"), exist_ok=True)
shutil.copy(
os.path.join(INSTANCE_DIR, "fishpog_pixelmon.png"),
os.path.join(MULTIMC_DIR, "icons", "fishpog_pixelmon.png"),
)
f = open(".version", "w")
f.write(release["tag_name"])
@@ -136,7 +181,7 @@ def multimc():
if os.path.exists(MULTIMC_DIR):
return
if OS != "windows":
if OS != "win32":
cprint("multimc is not installed - please install it", "red")
exit(1)

View File

@@ -12,10 +12,19 @@ if ! [ -x "$(command -v java)" ]; then
exit 1
fi
# check that multimc is installed
if ! [ -x "$(command -v multimc)" ]; then
echo 'Error: multimc is not installed. Please install it to continue.' >&2
exit 1
# check if is macos or linux
if [[ "$OSTYPE" == "linux"* ]]; then
# check that multimc is installed
if ! [ -x "$(command -v multimc)" ]; then
echo 'Error: multimc is not installed. Please install it to continue.' >&2
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# check that MultiMC.app is in /Applications
if ! [ -d "/Applications/MultiMC.app" ]; then
echo 'Error: MultiMC.app is not installed. Please install it to continue.' >&2
exit 1
fi
fi
if ! [ -d .venv ]; then python -m venv .venv; fi

View File

@@ -0,0 +1,12 @@
# creates a desktop shortcut to run client.ps1 in powershell
$ClientFile = "$PSScriptRoot\client.ps1"
$ShortcutPath = "$Home\Desktop\FishPog Pixelmon.lnk"
$IconPath = "$PSScriptRoot\icon.ico"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($ShortcutPath)
$Shortcut.TargetPath = "powershell.exe"
$Shortcut.Arguments = "-ExecutionPolicy Bypass -File `"$ClientFile`""
$Shortcut.IconLocation = $IconPath
$Shortcut.Save()

BIN
client/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -3,7 +3,7 @@
"version": "1.16.5",
"modLoaders": [
{
"id": "forge-36.2.34",
"id": "forge-36.2.39",
"primary": true
}
]
@@ -23,6 +23,42 @@
"name": "JourneyMap"
}
},
{
"projectID": 55438,
"fileID": 3346467,
"required": true,
"__meta": {
"name": "MrCrayfish's Furniture Mod"
}
},
{
"projectID": 60089,
"fileID": 3202662,
"required": true,
"__meta": {
"name": "Mouse Tweaks"
}
},
{
"projectID": 74072,
"fileID": 3695126,
"required": true,
"__meta": {
"name": "Tinkers Construct",
"dependencies": [
74924
]
}
},
{
"projectID": 74924,
"fileID": 3631982,
"required": true,
"__meta": {
"name": "Mantle",
"explicit": false
}
},
{
"projectID": 223852,
"fileID": 3776277,
@@ -31,6 +67,14 @@
"name": "Storage Drawers"
}
},
{
"projectID": 228756,
"fileID": 3543538,
"required": true,
"__meta": {
"name": "Iron Chests"
}
},
{
"projectID": 233342,
"fileID": 3216206,
@@ -66,6 +110,14 @@
"name": "Just Enough Items (JEI)"
}
},
{
"projectID": 245755,
"fileID": 3515707,
"required": true,
"__meta": {
"name": "Waystones"
}
},
{
"projectID": 247560,
"fileID": 4024011,
@@ -82,6 +134,14 @@
"name": "Nature's Compass"
}
},
{
"projectID": 253449,
"fileID": 3033593,
"required": true,
"__meta": {
"name": "Hwyla"
}
},
{
"projectID": 267602,
"fileID": 3137659,
@@ -98,6 +158,15 @@
"name": "Simple Storage Network"
}
},
{
"projectID": 309927,
"fileID": 4419403,
"required": true,
"__meta": {
"name": "Curios API (Forge)",
"explicit": false
}
},
{
"projectID": 328085,
"fileID": 3536025,
@@ -109,6 +178,14 @@
]
}
},
{
"projectID": 361276,
"fileID": 4596216,
"required": true,
"__meta": {
"name": "Lootr (Forge)"
}
},
{
"projectID": 361385,
"fileID": 3276350,
@@ -117,6 +194,14 @@
"name": "Pam's HarvestCraft 2 - Crops"
}
},
{
"projectID": 361579,
"fileID": 3767277,
"required": true,
"__meta": {
"name": "spark"
}
},
{
"projectID": 365460,
"fileID": 3281234,
@@ -180,6 +265,31 @@
"explicit": false
}
},
{
"projectID": 419699,
"fileID": 4521290,
"required": true,
"__meta": {
"name": "Architectury API (Fabric/Forge)",
"explicit": false
}
},
{
"projectID": 422301,
"fileID": 4167327,
"required": true,
"__meta": {
"name": "Sophisticated Backpacks"
}
},
{
"projectID": 439870,
"fileID": 4576329,
"required": true,
"__meta": {
"name": "Customizable Player Models"
}
},
{
"projectID": 486392,
"fileID": 3535459,
@@ -218,6 +328,17 @@
]
}
},
{
"projectID": 545905,
"fileID": 4584293,
"required": true,
"__meta": {
"name": "EnvySTS",
"dependencies": [
389487
]
}
},
{
"projectID": 818696,
"fileID": 4369234,
@@ -225,6 +346,14 @@
"__meta": {
"name": "PokeFactory Compatibility"
}
},
{
"projectID": 861884,
"fileID": 4559794,
"required": true,
"__meta": {
"name": "Universal Pokeloot"
}
}
]
}

View File

@@ -29,10 +29,10 @@
"uid": "net.minecraft"
}
],
"cachedVersion": "36.2.34",
"cachedVersion": "36.2.39",
"uid": "net.minecraftforge",
"version": "36.2.34"
"version": "36.2.39"
}
],
"formatVersion": 1
}
}

1
server/.jabbarc Normal file
View File

@@ -0,0 +1 @@
openjdk@1.11.0-2

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
server/plugins/Vault.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

226
server/server.py Normal file
View File

@@ -0,0 +1,226 @@
#!/usr/bin/env python3
import os, sys, shutil, requests, tempfile, glob, subprocess, argparse
from termcolor import cprint
from typing import Any
parser = argparse.ArgumentParser(description="server script for FishPogPixelmon")
parser.add_argument("--plugins", "-p", help="refreshes plugins", action="store_true")
args = parser.parse_args()
OS = sys.platform
SERVER_DIR = os.getcwd()
MOD_DOWNLOADER_URL = "https://github.com/Joshyx/ModpackDownloader/releases/download/v1.3/ModpackDownloader-1.3.jar"
MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon/releases?limit=1"
ARCLIGHT_URL = "https://github.com/IzzelAliz/Arclight/releases/download/1.16%2F1.0.24/arclight-forge-1.16.5-1.0.24.jar"
ARCLIGHT_JAR = "arclight.jar"
INSTANCE_DIR = os.path.join(str(os.getenv("HOME")), "pixelmon")
DELETION_EXEMPTED_MODS = ["TrainerCommands-1.16.5-2.6.0.jar"]
# main
def __main__():
header()
needs_mods_plugins = instance()
if needs_mods_plugins:
mods()
if args.plugins:
plugins()
arclight()
launch()
# launcher
def launch():
if input("launch server? [Y/n] ").lower() == "n":
exit(0)
os.chdir(f"{INSTANCE_DIR}/.minecraft")
subprocess.run(
[
"java",
"--illegal-access=permit",
"-Xmx30720M",
"-Xms1024M",
"-jar",
ARCLIGHT_JAR,
"--nogui",
]
)
# arclight
def arclight():
os.makedirs(f"{INSTANCE_DIR}/.minecraft", exist_ok=True)
os.chdir(f"{INSTANCE_DIR}/.minecraft")
if os.path.exists(os.path.join(f"{INSTANCE_DIR}/.minecraft", "arclight.jar")):
return
cprint("arclight.jar not found - downloading", "yellow")
r = requests.get(ARCLIGHT_URL, allow_redirects=True)
open("arclight.jar", "wb").write(r.content)
f = open("eula.txt", "w")
f.write("eula=true")
f.close()
# mods
def mods():
os.chdir(INSTANCE_DIR)
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.jar")):
cprint("downloader.jar not found - downloading", "yellow")
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
open("downloader.jar", "wb").write(r.content)
cprint("downloading mods. this may take a while, please wait.", "green")
my_env = os.environ.copy()
my_env["CURSEFORGE_API_KEY"] = "$2a$10$QbCxI6f4KxEs50QKwE2piu1t6oOA8ayOw27H9N/eaH3Sdp5NTWwvO"
os.makedirs(os.path.join(INSTANCE_DIR, "mods"))
subprocess.run(["java", "-jar", "downloader.jar", ".", "mods"], env=my_env)
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
if os.path.basename(file) in DELETION_EXEMPTED_MODS:
continue
os.remove(file)
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "mods", "*")):
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
cprint("mods downloaded successfully", "green")
# plugins
def plugins():
os.chdir(INSTANCE_DIR)
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft", "plugins"), exist_ok=True)
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "plugins", "*")):
if file.endswith(".jar"):
os.remove(file)
for file in glob.glob(os.path.join(SERVER_DIR, "plugins", "*")):
shutil.copy(file, os.path.join(INSTANCE_DIR, ".minecraft", "plugins", os.path.basename(file)))
cprint("plugins copied successfully", "green")
# multimc
def instance():
unclean = False
release = most_recent_release()
if not os.path.exists(INSTANCE_DIR):
unclean = True
cprint("instance not found - downloading", "yellow")
download_instance(release)
version = ""
if os.path.exists(f"{INSTANCE_DIR}/.version"):
f = open(f"{INSTANCE_DIR}/.version", "r")
version = f.read()
if version != release["tag_name"]:
unclean = True
cprint("new update available! - downloading", "green")
download_instance(release)
cprint("instance is up to date", "green")
return unclean
def download_instance(release: dict[str, Any]):
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft"), exist_ok=True)
TMP = tempfile.mkdtemp()
os.chdir(TMP)
download_url = get_release_asset(release)
r = requests.get(download_url, allow_redirects=True)
open("instance.zip", "wb").write(r.content)
shutil.unpack_archive("instance.zip", ".")
os.remove("instance.zip")
for file in glob.glob(os.path.join(TMP, "overrides", "*")):
if file == os.path.join(TMP, "overrides", "options.txt") and os.path.exists(
os.path.join(INSTANCE_DIR, ".minecraft", "options.txt")
):
continue
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
if os.path.isdir(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file))):
shutil.rmtree(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
else:
os.remove(os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", os.path.basename(file)))
shutil.rmtree(os.path.join(TMP, "overrides"))
for file in glob.glob(os.path.join(TMP, "*")):
if os.path.exists(os.path.join(INSTANCE_DIR, os.path.basename(file))):
if os.path.isdir(os.path.join(INSTANCE_DIR, os.path.basename(file))):
shutil.rmtree(os.path.join(INSTANCE_DIR, os.path.basename(file)))
else:
os.remove(os.path.join(INSTANCE_DIR, os.path.basename(file)))
shutil.move(file, os.path.join(INSTANCE_DIR, os.path.basename(file)))
os.chdir(INSTANCE_DIR)
f = open(".version", "w")
f.write(release["tag_name"])
f.close()
# releases
def most_recent_release() -> dict[str, Any]:
r = requests.get(MODPACK_RELEASES_URL)
releases: list[dict[str, Any]] = r.json()
return releases[0]
def most_recent_version(release: dict[str, Any]) -> str:
return release["tag_name"]
def get_release_asset(release: dict[str, Any]):
return release["assets"][0]["browser_download_url"]
# ascii art lol
def header():
cprint(
"""
_______ __ __ _______
| _ ||__|.-----.| |--.| _ |.-----..-----.
|. 1___|| ||__ --|| ||. 1 || _ || _ |
|. __) |__||_____||__|__||. ____||_____||___ |
|: | |: | |_____|
|::.| |::.|
`---' `---'
_______ __ __
| _ ||__|.--.--..-----.| |.--------..-----..-----.
|. 1 || ||_ _|| -__|| || || _ || |
|. ____||__||__.__||_____||__||__|__|__||_____||__|__|
|: |
|::.|
`---'
""",
"green",
)
# run app
__main__()

22
server/server.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# check that python is installed
if ! [ -x "$(command -v python)" ]; then
echo 'Error: python is not installed. Please install it to continue.' >&2
exit 1
fi
# check that java is installed
if ! [ -x "$(command -v java)" ]; then
echo 'Error: java is not installed. Please install it to continue.' >&2
exit 1
fi
if ! [ -d .venv ]; then python -m venv .venv; fi
source .venv/bin/activate &>/dev/null
python -m pip install --upgrade pip &>/dev/null
python -m pip install -r ../client/requirements.txt &>/dev/null
python ./server.py $1

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
import os, sys, argparse, tempfile, subprocess, shutil, requests
import os, sys, argparse, tempfile, subprocess, shutil, requests, zipfile
from git.repo import Repo
from termcolor import cprint
@@ -8,6 +8,7 @@ parser = argparse.ArgumentParser(description="a helper script for liightninggod
parser.add_argument("--export", "-e", help="export modpack zip", action="store_true")
parser.add_argument("--release", "-r", help="release modpack version", action="store_true")
parser.add_argument("--client", "-c", help="export modpack client as a zip file", action="store_true")
parser.add_argument("--setup", "-s", help="setup project and install dependencies", action="store_true")
parser.add_argument("--force", "-f", help="forces things when needed, like redoing setup", action="store_true")
parser.add_argument("--build-pax", help="builds pax from source, even if on a supported platform", action="store_true")
@@ -39,12 +40,29 @@ def __main__():
elif args.release:
release()
return
elif args.client:
print("exporting modpack client")
export_client()
return
print(
"no command provided. pass the -h flag to see commands for tooling, or run ./pax to interact with the modpack's files"
)
# client
def export_client():
z = zipfile.ZipFile(".out/FishPogPixelmonClient.zip", "w", zipfile.ZIP_DEFLATED)
z.write("client/README.md", "README.md")
z.write("client/client.ps1", "client.ps1")
z.write("client/client.sh", "client.sh")
z.write("client/requirements.txt", "requirements.txt")
z.write("client/client.py", "client.py")
z.write("client/icon.ico", "icon.ico")
z.write("client/desktop-shortcut.ps1", "desktop-shortcut.ps1")
z.close()
# setup
def setup_pack():
pax()
@@ -108,7 +126,7 @@ def pax():
os.chmod("pax", 0o755)
return
if OS == "windows":
if OS == "win32":
print("downloading and extracting pax for windows...")
r = requests.get(PAX_WINDOWS, allow_redirects=True)
open("pax-windows.zip", "wb").write(r.content)
@@ -118,7 +136,7 @@ def pax():
def pax_from_source():
if OS == "windows":
if OS == "win32":
cprint("building from source not supported on windows yet", "red")
exit(1)

View File

@@ -12,7 +12,7 @@ if (-Not (Test-Path "./.venv")) {
}
# Activate the virtual environment
. ./.venv/bin/Activate.ps1
. .\.venv\Scripts\Activate.ps1
# Install required packages
& $python -m pip install --upgrade pip