treewide: Remove minecraft server

This has fallen into disuse since the big Java vulnerability, and I
have ideas for better ways of doing this. Meanwhile it's making
maintenance and refactoring more difficult.

Hence I'll remove the server completely for the time being.
This commit is contained in:
Tristan Daniël Maat 2022-10-12 01:05:24 +01:00
parent 046a88905d
commit 7095ab2631
Signed by: tlater
GPG key ID: 49670FD774E43268
207 changed files with 5 additions and 17764 deletions

View file

@ -1,31 +0,0 @@
{
lib,
fetchurl,
}:
with builtins;
{
project,
id,
filename,
...
} @ args: let
# I think this is supposed to be some weak automation
# protection. This split "id" is simply part of the download URL.
#
# Note that if it's zero-prefixed we need to remove the zeroes. It's
# really an odd one...
a = head (match "0*([[:digit:]]+)" (substring 0 4 (toString id)));
b = head (match "0*([[:digit:]]+)" (substring 4 7 (toString id)));
encoded-filename = replaceStrings [" "] ["%20"] filename;
url = "https://media.forgecdn.net/files/${a}/${b}/${encoded-filename}";
otherArgs = removeAttrs args ["project" "project_id" "id" "filename"];
in
fetchurl (otherArgs
// {
inherit url;
# Rename files to avoid names incompatible with the nix store
name = "${project}.jar";
# Avoid accidental URL globbing
curlOpts = "--globoff";
})

View file

@ -1,21 +1,5 @@
{
pkgs,
local-lib,
...
}: let
inherit (pkgs.lib) callPackageWith;
callPackage = callPackageWith (pkgs // {inherit local-lib;});
{pkgs, ...}: let
inherit (pkgs.lib) callPackage;
in {
# Forge
forge-server = callPackage ./minecraft/forge-server.nix {};
# Build support
fetchFromCurseForge = callPackage ./build-support/fetchFromCurseForge.nix {};
# Minecraft modpacks
voor-kia = callPackage ./minecraft/voor-kia.nix {};
voor-kia-client = callPackage ./minecraft/voor-kia-client.nix {};
# Starbound
starbound = callPackage ./starbound {};
}

View file

@ -1,120 +0,0 @@
{
lib,
stdenv,
fetchurl,
busybox,
coreutils,
jre_headless,
runtimeShell,
mods ? null,
modConfig ? null,
defaultconfigs ? null,
}: let
name = "forge-server";
version = "1.16.5-36.2.2";
mirror = "https://files.minecraftforge.net/maven/net/minecraftforge/forge";
src = fetchurl {
url = "${mirror}/${version}/forge-${version}-installer.jar";
curlOpts = "--globoff";
# Forge doesn't seem to like newer shas
sha1 = "sha1-oHNpyrgHluRrAXWZJg9j+OInAwA=";
};
unpackCmd = "mkdir -p src; cp $curSrc src/forge-${version}-installer.jar";
nativeBuildInputs = [jre_headless];
# Somewhat evil pre-install step to run through the network
# dependency resolution forge needs. This is also common for gradle
# projects, so I think this is ok-ish here, though ideally I'd
# identify all the dependencies and package them as well.
deps = stdenv.mkDerivation {
name = "${name}-deps";
inherit src unpackCmd nativeBuildInputs;
buildPhase = ''
java -jar forge-${version}-installer.jar --installServer installation
'';
installPhase = ''
mkdir -p $out
# The installer will patch the Minecraft server jar in some
# fashion, and include it in "libraries". This'd be fine, if the
# patch was bit-for-bit reproducible. Sadly it is not, so we
# defer this to the *real* package build.
rm -r installation/libraries/net/minecraft/
cp -r installation/* $out
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "VuUGc5JnzcRhDt9aaGrU+yUrJILVdU2vzv1PxLwdAig=";
};
in
stdenv.mkDerivation rec {
inherit name version src unpackCmd nativeBuildInputs;
buildPhase = ''
mkdir -p installation
# Take the input deps and patch the Minecraft server jar into our
# libraries to create the package.
cp -rv ${deps}/* installation/
chmod -R +w installation/
java -jar forge-${version}-installer.jar --offline --installServer installation/
'';
installPhase = ''
mkdir -p $out/{bin,lib/forge}
cp -r installation/{forge-${version}.jar,libraries} $out/lib/forge/
cat > $out/bin/forge-server << EOF
#!${runtimeShell}
set -eu
# Delete any previous mods directory so that it can be updated
${busybox}/bin/rm -fr mods
${lib.optionalString (mods != null) ''
# Copy the specified mods into the directory. Note that, sadly,
# forge doesn't support symlinks here.
${busybox}/bin/mkdir -p mods
${busybox}/bin/cp -r '${mods}/mods/'*.jar mods
''}
# Delete any previous config directories so that they can be updated
${busybox}/bin/rm -fr config defaultconfigs
${lib.optionalString (modConfig != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p config
${busybox}/bin/cp -r '${modConfig}'/* config
${busybox}/bin/chmod -R u+w config
''}
${lib.optionalString (defaultconfigs != null) ''
# Copy the specified configs into the directory. Forge (and
# mods) will try to write here, so we cannot symlink.
${busybox}/bin/mkdir -p defaultconfigs
${busybox}/bin/cp -r '${defaultconfigs}'/* defaultconfigs
${busybox}/bin/chmod -R u+w defaultconfigs
''}
exec ${jre_headless}/bin/java \$@ -jar $out'/lib/forge/forge-${version}.jar' nogui
EOF
chmod +x $out/bin/forge-server
'';
meta = with lib; {
description = "Forge Minecraft Server";
homepage = "https://files.minecraftforge.net/";
# Forge itself is open source, but this package pulls in
# minecraft.
license = licenses.unfreeRedistributable;
platforms = platforms.unix;
};
}

View file

@ -1,12 +0,0 @@
{
lib,
local-lib,
stdenv,
}:
local-lib.minecraft.mkModpackZip {
name = "voor-kia-client";
version = "1.1";
mods =
(builtins.fromJSON (builtins.readFile ./voor-kia/mods.json))
++ (builtins.fromJSON (builtins.readFile ./voor-kia/client-mods.json));
}

View file

@ -1,10 +0,0 @@
{
lib,
local-lib,
stdenv,
}:
local-lib.minecraft.mkModpack {
name = "voor-kia";
version = "1.0";
mods = builtins.fromJSON (builtins.readFile ./voor-kia/mods.json);
}

View file

@ -1,86 +0,0 @@
[
{
"filename": "AmbientSounds_v3.1.9_mc1.16.5.jar",
"id": 3334857,
"project": "ambientsounds",
"project_id": 254284,
"sha256": "c8ed21587fe96745695aa9a8f23b6effbcc6a5c5340aed11b8515c0e0aa2c310"
},
{
"filename": "BackTools-1.16.5-10.1.0.jar",
"id": 3224955,
"project": "back-tools",
"project_id": 229061,
"sha256": "cd5ed82919dd8acf2874c7edadba5bacfaffa898e572f8574241329e4478518e"
},
{
"filename": "BetterAdvancements-1.16.5-0.1.1.111.jar",
"id": 3400299,
"project": "better-advancements",
"project_id": 272515,
"sha256": "83c159f83bebc1d0f72c9de465bdcbeb2b02a56b88dcaa6661fe54df50a9aab5"
},
{
"filename": "Controlling-7.0.0.23.jar",
"id": 3348514,
"project": "controlling",
"project_id": 250398,
"sha256": "627308ed0b4fc1fdcc75113db8412c0684c3a774d1c6a07ae993543e605f5655"
},
{
"filename": "EntityCulling-1.16.5-2.1.6.jar",
"id": 3328602,
"project": "entity-culling",
"project_id": 409087,
"sha256": "eede3bfc68f48acb3e06fec2ea280510287cd5d492a02b8ace8e0dda742d7342"
},
{
"filename": "ftb-library-forge-1605.3.1-build.48.jar",
"id": 3373833,
"project": "ftb-library-forge",
"project_id": 404465,
"sha256": "f4f87f464796ee6ff7c80fb1fbc5753ac191138b6aa6b1a30c1b55252b3bf0a8"
},
{
"filename": "InventoryHud_[1.16.2-1.16.5].forge-3.3.0.jar",
"id": 3296748,
"project": "inventory-hud-forge",
"project_id": 357540,
"sha256": "2b3a4f02fe84b717c9273ea14cea0912267c2c093fc2cdfcde2b6f032c9762e7"
},
{
"filename": "MouseTweaks-2.14-mc1.16.2.jar",
"id": 3202662,
"project": "mouse-tweaks",
"project_id": 60089,
"sha256": "9d7e1aaee9f814c26d896e084e6e86930ab99e19fe547a1d350a6e25e4267092"
},
{
"filename": "namepain-1.4.0 forge-1.16.x.jar",
"id": 3356725,
"project": "name-pain",
"project_id": 366263,
"sha256": "5cc9e83b6d06810cbfcc155ddcfbe417cd4553a2665025affd1b71bee0138f68"
},
{
"filename": "overloadedarmorbar-5.1.0.jar",
"id": 3055679,
"project": "overloaded-armor-bar",
"project_id": 314002,
"sha256": "8aff59f170ef2c7598dc0f2367842f4384e57c13111507468da32498fc0ac4ea"
},
{
"filename": "shutupexperimentalsettings-1.0.3.jar",
"id": 3188120,
"project": "shutup-experimental-settings",
"project_id": 407174,
"sha256": "22ce84a0d424c2d48e483cb873909ac5c8c322bc793d09365ad44b901f43de62"
},
{
"filename": "Toast-Control-1.16.4-4.3.1.jar",
"id": 3172881,
"project": "toast-control",
"project_id": 271740,
"sha256": "b1cb36b7615c846f08c72423b2b52417b55eea91ca812bb7629a8f3060f5efae"
}
]

View file

@ -1,625 +0,0 @@
[
{
"filename": "AI-Improvements-1.16.2-0.3.0.jar",
"id": 3031978,
"project": "ai-improvements",
"project_id": 233019,
"sha256": "47526292ea2f11dd18a8da8863b40ba81a93601f03aa4abcc742ac62ea599c69"
},
{
"filename": "alexsmobs-1.11.1.jar",
"id": 3371504,
"project": "alexs-mobs",
"project_id": 426558,
"sha256": "4daf19a04317c5a399d38c2c397ead8cce9a9eb6c09fdb5bd7bd6dec8c911167"
},
{
"filename": "Apotheosis-1.16.4-4.6.1.jar",
"id": 3332235,
"project": "apotheosis",
"project_id": 313970,
"sha256": "a15e9faf743d237063221c0d9ab0b75acf86ba5c3bfde08a42922c3b108bca80"
},
{
"filename": "appleskin-forge-mc1.16.x-2.1.0.jar",
"id": 3395800,
"project": "appleskin",
"project_id": 248787,
"sha256": "d98f34b1a97a66ea5e33eda7e744f1382d325c7de51db57285d1a0888c0e8496"
},
{
"filename": "architectury-1.20.28-forge.jar",
"id": 3385660,
"project": "architectury-forge",
"project_id": 419699,
"sha256": "0a89b6a6d12596bf288411fd740cbc44f3fe63c3f4665f7fd3f46f65f52cf138"
},
{
"filename": "Artifacts-1.16.5-2.10.0.jar",
"id": 3374317,
"project": "artifacts",
"project_id": 312353,
"sha256": "70e2945f8200f7ad3cb46436a998acd37ebec318d08e7a578ca39e8115414b1c"
},
{
"filename": "AttributeFix-1.16.5-10.1.3.jar",
"id": 3348562,
"project": "attributefix",
"project_id": 280510,
"sha256": "aabf99d65e4ccfc08a67dc378f447eef613ac50924587a33aef68d4467e1a7c0"
},
{
"filename": "AutoRegLib-1.6-49.jar",
"id": 3326041,
"project": "autoreglib",
"project_id": 250363,
"sha256": "2760b765dccf1fad36e74f747ee9b1a2923e2d09eb281c72258c15bb4ed427d5"
},
{
"filename": "bedspreads-forge-1.16.5-5.1.0.2.jar",
"id": 3258439,
"project": "bedspreads",
"project_id": 308653,
"sha256": "fa823abf9efef6818079d1c0cf123e9edccdac81fddf09b2ef931f21f4c58e9d"
},
{
"filename": "BetterBurning-1.16.5-6.0.7.jar",
"id": 3348573,
"project": "better-burning",
"project_id": 353434,
"sha256": "4b089ce99e48cf72bf817cbc26a0e23b297b5b451bbd80b46091cd5a290524ff"
},
{
"filename": "BetterCaves-Forge-1.16.4-1.1.2.jar",
"id": 3307879,
"project": "yungs-better-caves",
"project_id": 340583,
"sha256": "5182379427440bb4198790856c01f28c085365cc37ad3a05a9cd82dfdf068454"
},
{
"filename": "BetterMineshafts-Forge-1.16.4-2.0.4.jar",
"id": 3344719,
"project": "yungs-better-mineshafts-forge",
"project_id": 389665,
"sha256": "19b9b7f87da2bb76574e9f3e3d18d445189a4627cfd0d8188ae88eb681b578b8"
},
{
"filename": "BetterPortals-1.16.4-0.3.7.jar",
"id": 3396844,
"project": "yungs-better-portals",
"project_id": 443723,
"sha256": "4695da7e9212d79c9fc8350e9b4ec2600631ff858ee10d146d4a69f20dfc9c6e"
},
{
"filename": "Bookshelf-1.16.5-10.2.15.jar",
"id": 3402183,
"project": "bookshelf",
"project_id": 228525,
"sha256": "0674174797835d3371d1421cbf6232276451edca0b6f16b85bb3519e65622ea4"
},
{
"filename": "bwncr-1.16.4-3.9.16.jar",
"id": 3101531,
"project": "bad-wither-no-cookie-reloaded",
"project_id": 261251,
"sha256": "91c4df24466b958d36d41ce886e5d8b0839a07b73d58248a0dcb84a67279b81f"
},
{
"filename": "byg-1.2.9.jar",
"id": 3337158,
"project": "oh-the-biomes-youll-go",
"project_id": 247560,
"sha256": "13007c914d142b4e19f92213970edf22094ad9f48e1e7e7c27e1355eb7248086"
},
{
"filename": "callablehorses-1.16.3-1.2.1.4.jar",
"id": 3090832,
"project": "callable-horses",
"project_id": 331746,
"sha256": "639778fd58667aa560d333a2490352e34c1c32e897d9f8204e52df305ca5e879"
},
{
"filename": "citadel-1.7.1-1.16.5.jar",
"id": 3346836,
"project": "citadel",
"project_id": 331936,
"sha256": "2977c084dcbd23c4fa1ea00ea152f1792b38781eff8f0234de4d67b1ee35b849"
},
{
"filename": "cloth-config-4.11.26-forge.jar",
"id": 3311352,
"project": "cloth-config-forge",
"project_id": 348521,
"sha256": "815ba5d61416d9bbd53b830509b9f3d74d59c1720cf9a6b002a3e66eb1453196"
},
{
"filename": "Clumps-6.0.0.25.jar",
"id": 3348509,
"project": "clumps",
"project_id": 256717,
"sha256": "1039d9ae78873107ee82c799e586c71dfe284d5bb58f89895a3a510f8f33c765"
},
{
"filename": "flywheel-1.16-0.1.1.jar",
"id": 3389159,
"project": "flywheel",
"project_id": 486392,
"sha256": "ac0cc92d6ef491cc88ca3fbc3cb2c3180fe58ad1ce1c6f91dcfb996324d7331e"
},
{
"filename": "expandability-2.0.1-forge.jar",
"id": 3277762,
"project": "expandability",
"project_id": 465066,
"sha256": "0959cffb3a545730e6b2e1377bb89b59ff96e7f9142f54cc8035ab4fa2fc76e1"
},
{
"filename": "CodeChickenLib-1.16.5-4.0.2.429-universal.jar",
"id": 3398096,
"project": "codechicken-lib-1-8",
"project_id": 242818,
"sha256": "0254c780c5f20653cab34f6bc8178b1de1ce44de082dcd42ff1e1ee9ba9d5e3a"
},
{
"filename": "CookingForBlockheads_1.16.5-9.3.3.jar",
"id": 3368022,
"project": "cooking-for-blockheads",
"project_id": 231484,
"sha256": "6adc6a882c2647ecda2345321ec77572a7f0a3fcdeadae24fa5dc71f0e5af9bb"
},
{
"filename": "CosmeticArmorReworked-1.16.5-v4.jar",
"id": 3398000,
"project": "cosmetic-armor-reworked",
"project_id": 237307,
"sha256": "83a24d226acd7c86b94b4a8eac716b8a306c96e7d76a1a06bdcc2e2be9df9b21"
},
{
"filename": "craftingstation-4.1.1.jar",
"id": 3084325,
"project": "crafting-station",
"project_id": 318551,
"sha256": "a3516650a1c5e76b47b9efd69a4cfa9cda4f85250bf217fa7186f74ef375a7e4"
},
{
"filename": "create-mc1.16.5_v0.3.2b.jar",
"id": 3386319,
"project": "create",
"project_id": 328085,
"sha256": "7b0180bf62abe862f7dcb83a4281447b00fd7a26d488cfc17e4d6f590782cc8f"
},
{
"filename": "CreativeCore_v2.2.0_mc1.16.5.jar",
"id": 3338971,
"project": "creativecore",
"project_id": 257814,
"sha256": "8155f7a84695a68fd2e8b8f6fab0377b9d78cfbab9d8c125e6a9b58238d1eacc"
},
{
"filename": "curios-forge-1.16.5-4.0.5.2.jar",
"id": 3343065,
"project": "curios",
"project_id": 309927,
"sha256": "08d7558df6c621fca29758c349b95b137d2977cf1f3f61323fff4d85630d0641"
},
{
"filename": "dankstorage-3.16.jar",
"id": 3250771,
"project": "dank-storage",
"project_id": 335673,
"sha256": "bd5734d8ee8caf3a20574699d91f95b9e53df6b4d13f196f087d3f4bfe867621"
},
{
"filename": "decorative_blocks-1.16.4-1.7.2.jar",
"id": 3166283,
"project": "decorative-blocks",
"project_id": 362528,
"sha256": "f12dbfe76e36cdec65b8a575fc671f0291323a0de5ff420ff196d16bd19e6f84"
},
{
"filename": "DoggyTalents-1.16.5-2.0.1.10.jar",
"id": 3399830,
"project": "doggy-talents",
"project_id": 271050,
"sha256": "dab81029d8e1155749ec7144b39e578980456fd8b59461e218ed930d72e80cbd"
},
{
"filename": "easy_piglins-1.16.5-1.0.2.jar",
"id": 3309363,
"project": "easy-piglins",
"project_id": 419372,
"sha256": "66ac62e343203ed217a27a9038155192d4b3ee87908f7000347c5ee50526e5b5"
},
{
"filename": "easy_villagers-1.16.5-1.0.11.jar",
"id": 3327024,
"project": "easy-villagers",
"project_id": 400514,
"sha256": "845e937a59e1c3b2423aff0129248b82ae9bdd3a618f43645cc7be6fe974c183"
},
{
"filename": "EnchantmentDescriptions-1.16.5-7.0.14.jar",
"id": 3363585,
"project": "enchantment-descriptions",
"project_id": 250419,
"sha256": "60405ac61dbfb1e3c5d90479c2248f3e9408ca1089c524cefd021760c152f50c"
},
{
"filename": "EnderStorage-1.16.5-2.8.0.168-universal.jar",
"id": 3361748,
"project": "ender-storage-1-8",
"project_id": 245174,
"sha256": "31725d5af63fda688f38c7546a1e210332339fadd5fedc3144f9fb0b643bf8d2"
},
{
"filename": "extlights-3.3.jar",
"id": 3144281,
"project": "extended-lights-mod",
"project_id": 335051,
"sha256": "7f210f8e8bc451df301a6a2c22f81e434dd1835699444e5c0ed2bb2620847a6b"
},
{
"filename": "ExtraStorage-1.16.5-1.4.1.jar",
"id": 3336746,
"project": "extrastorage",
"project_id": 410168,
"sha256": "0c3ecafbcc4c7f8a91479d389add57d0db2943cf182352065535d6b5511bce4f"
},
{
"filename": "FarmingForBlockheads_1.16.5-7.3.1.jar",
"id": 3332379,
"project": "farming-for-blockheads",
"project_id": 261924,
"sha256": "94668c62457b655cf4bb2ff651adc43a2c2379e1ee4d545c57ff0d01c45db61e"
},
{
"filename": "FastLeafDecay-v25.jar",
"id": 3052146,
"project": "fast-leaf-decay",
"project_id": 230976,
"sha256": "0abd12217bd7e83d5427a4aca6acec27241bb4a7272ef79958a692bd60fe1d86"
},
{
"filename": "FastWorkbench-1.16.4-4.5.1.jar",
"id": 3245271,
"project": "fastworkbench",
"project_id": 288885,
"sha256": "99488d96c13fb062fc7d1281957d72f69fca0f1fa07f54c480337282a5092f23"
},
{
"filename": "fishingreal-1.16.3-1.0.0.jar",
"id": 3074201,
"project": "fishing-real",
"project_id": 348834,
"sha256": "1c2f868ee221e59407f6c8f1ec07fa7ccca49a819559dad818713a6778291fc5"
},
{
"filename": "HardcoreRevival_1.16.5-6.0.1.jar",
"id": 3344257,
"project": "hardcore-revival",
"project_id": 274036,
"sha256": "4a76642dd343070261f9151a37c2deb7e2c9efc031d4127f91b8b6d9b7614670"
},
{
"filename": "iceandfire-2.1.8-1.16.5.jar",
"id": 3361256,
"project": "ice-and-fire-dragons",
"project_id": 264231,
"sha256": "37d849bc66e32b1de6ff52c2002714a49673b08f4fd84f36a7e1a6fdbf20f69e"
},
{
"filename": "iChunUtil-1.16.5-10.4.1.jar",
"id": 3346209,
"project": "ichunutil",
"project_id": 229060,
"sha256": "d5a1be183d5f68ff520ddfa6a5db55dfe7d76f327fa98fd0a82209330815b5d9"
},
{
"filename": "ironchest-1.16.5-11.2.13.jar",
"id": 3405717,
"project": "iron-chests",
"project_id": 228756,
"sha256": "535b48cc3f12acacf42c2daff8709e45131d34bcc218a05203f62ce091e92a11"
},
{
"filename": "ironfurnaces-1.16.5-2.6.9.jar",
"id": 3387531,
"project": "iron-furnaces",
"project_id": 237664,
"sha256": "f9347a04dece94e645b581091f94cd33396e93a91209eb55cc6933e09196b0a1"
},
{
"filename": "jei-1.16.5-7.7.1.116.jar",
"id": 3401260,
"project": "jei",
"project_id": 238222,
"sha256": "d2c8b8e08646e060a053cb9eaba70229540a7fc0204287e561dfd91bbff2c29b"
},
{
"filename": "jeiintegration_1.16.5-7.0.1.15.jar",
"id": 3202331,
"project": "jei-integration",
"project_id": 265917,
"sha256": "0b45fe2858a8e9f97bf10fb218975a48a7d228ca27d274194c4dfaa91534bdfd"
},
{
"filename": "JustEnoughResources-1.16.5-0.12.1.121.jar",
"id": 3336760,
"project": "just-enough-resources-jer",
"project_id": 240630,
"sha256": "1fa5dce078ff98fb172ca658aa7c70345fb8af969c506d5125b419da93448d61"
},
{
"filename": "Kiwi-1.16.5-3.5.2.jar",
"id": 3377053,
"project": "kiwi",
"project_id": 303657,
"sha256": "1a175d5f6ca5329c5ef92c853b3112a6a4d4284b7896aeb4b60c21381f2c8caf"
},
{
"filename": "Lollipop-1.16.5-3.2.9.jar",
"id": 3232534,
"project": "lollipop",
"project_id": 347954,
"sha256": "bba84ef5f76510595f1ee693f650d4ee4202cea290b4139233ca26060a14e12b"
},
{
"filename": "lottaterracotta-1.16.5-1.3.2.jar",
"id": 3364628,
"project": "lotta-terracotta",
"project_id": 351060,
"sha256": "2a305378e261dee335fb680b4ac1cc362bed0b599a9fce6e248decbe1fa56c84"
},
{
"filename": "mcw-doors-1.0.3-mc1.16.5.jar",
"id": 3340793,
"project": "macaws-doors",
"project_id": 378646,
"sha256": "fb23ffda5f8407a01bbb8a1ec5b08dff1a8772a6e7a726dd085920be62337982"
},
{
"filename": "mcw-furniture-2.0.1-mc1.16.5.jar",
"id": 3182349,
"project": "macaws-furniture",
"project_id": 359540,
"sha256": "7f81b95c128ce97f3c41e29a4e98618c591f96321b53b718b5c3b6b8d3cb619e"
},
{
"filename": "metalbarrels-3.3a.jar",
"id": 3055811,
"project": "metal-barrels",
"project_id": 324985,
"sha256": "9bec62579ec71be41a303519e3b7944df0f3ee23a5b03ac7c0d0b27fe7c66150"
},
{
"filename": "overworld_two-1.0-Forge-1.16.4.jar",
"id": 3149167,
"project": "overworld-two-forge",
"project_id": 431157,
"sha256": "4995b774537ab31de6b98eb15aad3fbbfe6d3aa4e57108a9b3fe3abbe3d8da59"
},
{
"filename": "pamhc2crops-1.16.3-1.0.2.jar",
"id": 3276350,
"project": "pams-harvestcraft-2-crops",
"project_id": 361385,
"sha256": "5ebb51293d3e56ccf93875b7a4943577d78c1ee79401115230bb28cebbc7e832"
},
{
"filename": "pamhc2foodcore-1.16.3-1.0.2.jar",
"id": 3190867,
"project": "pams-harvestcraft-2-food-core",
"project_id": 372534,
"sha256": "e4414d35013e746e5b06256a08dd957a814b17cebcb035899a84a3692d08b544"
},
{
"filename": "pamhc2foodextended-1.16.3-1.0.2.jar",
"id": 3260454,
"project": "pams-harvestcraft-2-food-extended",
"project_id": 402231,
"sha256": "886ec5e6dca66382b99765b0033d17e270b792171a75dd8eb41fcfd86a5641e9"
},
{
"filename": "pamhc2trees-1.16.3-1.0.1.jar",
"id": 3281234,
"project": "pams-harvestcraft-2-trees",
"project_id": 365460,
"sha256": "e0f38f6a61e1da87981a249d520f2a8e43c4cefd29693076caf74ab8c5fe697f"
},
{
"filename": "PassableFoliage-1.16.5-2.3.1.jar",
"id": 3378277,
"project": "passable-foliage",
"project_id": 379887,
"sha256": "b18d228f6c8e34b8de54a0b0aa257e1be1eef7b65f8b7f75b3186e46f1b2118b"
},
{
"filename": "performant-1.16.2-5-3.72m.jar",
"id": 3401152,
"project": "performant",
"project_id": 354143,
"sha256": "cb3ef5fbedc6c9d7a0e379f7da400e22893a82425f27bd00bfd62e8cd8b35e20"
},
{
"filename": "Placebo-1.16.4-4.5.0.jar",
"id": 3331459,
"project": "placebo",
"project_id": 283644,
"sha256": "4a1bebf13a3dde1870fee6da242598f9a1c8005161fdd795052506e0c38fd5da"
},
{
"filename": "Platter-1.16-1.0.0.jar",
"id": 3115114,
"project": "platter",
"project_id": 381581,
"sha256": "6e4aee987ac4efa41a1b9cc26a4e4588c79a56bb200402b9fee71e43ab45a533"
},
{
"filename": "Powah-1.16.5-2.3.16.jar",
"id": 3232535,
"project": "powah",
"project_id": 352656,
"sha256": "78b652caa055f67f0479bac9a44e3ed67704bf4e59a48d06c7fd3cfe9ecb2b72"
},
{
"filename": "QuarkOddities-1.16.3.jar",
"id": 3088871,
"project": "quark-oddities",
"project_id": 301051,
"sha256": "5eafd942f2eb9b13edde3bff451ee968c1d0fe549c8decd2f8551e59a079711d"
},
{
"filename": "Quark-r2.4-316.jar",
"id": 3394265,
"project": "quark",
"project_id": 243121,
"sha256": "e5cea2e0aa0c229913dfb2735cc52c3889ad8d448bc1bdd64aa0dda3077b3676"
},
{
"filename": "refinedstorage-1.9.15.jar",
"id": 3400575,
"project": "refined-storage",
"project_id": 243076,
"sha256": "d49fc8ff38b973517e60bc5d17a1e98bc8b4c6870ec58d3df7a36ac780474180"
},
{
"filename": "RepairChests-1.16.5-1.7.jar",
"id": 3211620,
"project": "repair-chests",
"project_id": 401644,
"sha256": "d25687ae8c7a9caf7491b506852eb7a6edc827230794dca4ddd45628b5674df9"
},
{
"filename": "rsgauges-1.16.4-1.2.11.jar",
"id": 3390492,
"project": "redstone-gauges-and-switches",
"project_id": 296686,
"sha256": "65e6e7a7fac64130de455b8b8e3ec1a16ee48411df0ab3963790038019f69a25"
},
{
"filename": "selene-1.16.5-1.3.jar",
"id": 3377212,
"project": "selene",
"project_id": 499980,
"sha256": "49a08a86b9f63170fb1a9bf9c81d6a91157eecfbf150ac04bb010207a0133485"
},
{
"filename": "SnowRealMagic-1.16.4-2.5.8.jar",
"id": 3391417,
"project": "snow-real-magic",
"project_id": 308663,
"sha256": "153ba7328acbc0818361bb6f84fe4546aa1e9ddcd350ab5b6c97c6f7209b36b5"
},
{
"filename": "snowundertrees-1.16.5-v1.1.4.jar",
"id": 3247710,
"project": "snow-under-trees",
"project_id": 353942,
"sha256": "66cf77b4f9b654648e890fe6c55a3be9b3693f1be505d1c1e7b6ff1b91a1a54d"
},
{
"filename": "SoL-Carrot-1.16.5-1.10.0.jar",
"id": 3355731,
"project": "spice-of-life-carrot-edition",
"project_id": 277616,
"sha256": "b92f394d72b58e59e14d6cc337edf93d79617b02169ac44a3ec2a68820543d3a"
},
{
"filename": "spark-forge.jar",
"id": 3337641,
"project": "spark",
"project_id": 361579,
"sha256": "a162f9caf81073429bcb8df4844ef8eb43828c57d2956f55675499bc004e4802"
},
{
"filename": "StorageDrawers-1.16.3-8.3.0.jar",
"id": 3402515,
"project": "storage-drawers",
"project_id": 223852,
"sha256": "79ab53ab8d46aa517025fc4ecbb05b8492daff5f252aa4884ba46e8fefc3b794"
},
{
"filename": "supplementaries-1.16.5-0.14.3.jar",
"id": 3377218,
"project": "supplementaries",
"project_id": 412082,
"sha256": "42e91d1c58b9bd292263410e75971de8a59ce0c1f2d7979a2222591fc55eba28"
},
{
"filename": "sweetconcrete-1.16.5-1.7.2.jar",
"id": 3364624,
"project": "sweet-concrete",
"project_id": 351052,
"sha256": "6836f7f2a6f04edf6fe1efd4a6341c3c486c6c1ff824a858927375a45a121e33"
},
{
"filename": "swingthroughgrass-1.16.4-1.5.3.jar",
"id": 3103028,
"project": "swingthroughgrass",
"project_id": 264353,
"sha256": "d47132c8e97989f6f1b4c3c2c0736bf9e16e9a72970b3953fc80dcf8b1a4e31d"
},
{
"filename": "the_bumblezone-1.16.5-2.4.10-forge.jar",
"id": 3404007,
"project": "the-bumblezone-forge",
"project_id": 362479,
"sha256": "71fb56ddca8d5f671b1c5e588b60e352bb80fba135aab74056b4daa0ed44cefd"
},
{
"filename": "The_Undergarden-1.16.5-0.5.4.jar",
"id": 3361666,
"project": "the-undergarden",
"project_id": 379849,
"sha256": "b596836a5c1d50cf1c65c50ea728b0e295965cf9a4091a8eb1caac517aad5c50"
},
{
"filename": "towers_of_the_wild-1.16.4-2.0.1.jar",
"id": 3103750,
"project": "towers-of-the-wild",
"project_id": 386415,
"sha256": "fcd0e3f808569f0e547313a1ea3563c9a5d2fa8fbb638678eed6e46c1d8cfaf1"
},
{
"filename": "TravelersBackpack-1.16.5-5.4.2.jar",
"id": 3316664,
"project": "travelers-backpack",
"project_id": 321117,
"sha256": "e07aad8653f037ad96639a602fa260684f89757c905d6a47e1193154d274875e"
},
{
"filename": "weirdinggadget-1.16.(2-4)-2.2.7.jar",
"id": 3116235,
"project": "the-weirding-gadget",
"project_id": 258914,
"sha256": "fe9b2d4f39020a4239a19ea0e7229beec29eb8f1ef2b2b198b9aa5aad0b13318"
},
{
"filename": "Wither-Skeleton-Tweaks-1.16.4-5.3.0.jar",
"id": 3172803,
"project": "wither-skeleton-tweaks",
"project_id": 255902,
"sha256": "e6375312aeb188cda4951a4c4935343a64785303129dbb47f49f59768d0865d3"
},
{
"filename": "Xaeros_Minimap_21.14.1_Forge_1.16.5.jar",
"id": 3405505,
"project": "xaeros-minimap",
"project_id": 263420,
"sha256": "97278ddc89fe70b81387fc2ae45d986eb07e373b49977de5d358b8addf1103a2"
},
{
"filename": "XaerosWorldMap_1.16.0_Forge_1.16.5.jar",
"id": 3405517,
"project": "xaeros-world-map",
"project_id": 317780,
"sha256": "b4bceb6ebebf9a6c67a2e750e98d5cf2c1fe53fc66e487a79ac0d7a0664a8a12"
},
{
"filename": "YungsApi-1.16.4-Forge-11.jar",
"id": 3386962,
"project": "yungs-api",
"project_id": 421850,
"sha256": "d280edabd1f83ff45831e8c79dfdc5e9ca17158fa2ed1d05025afcea23ad83a9"
}
]

View file

@ -1,156 +0,0 @@
import argparse
import json
import hashlib
import pathlib
from copy import deepcopy
from datetime import datetime
from enum import Enum
from typing import Any, Dict, Generator, List, NamedTuple, Optional, Union
import requests
from dateutil import parser
API = "https://addons-ecs.forgesvc.net/api/v2"
JSON = Union[List[Dict[str, Any]], Dict[str, Any]]
class ModLoader(Enum):
FORGE = 1
FABRIC = 4
class File(NamedTuple):
id: int
gameVersions: List[str]
name: str
modLoader: Optional[ModLoader]
date: datetime
@classmethod
def from_json(cls, f: JSON):
assert isinstance(f, dict)
assert isinstance(f.get("gameVersion"), list)
assert isinstance(f.get("id"), int)
assert isinstance(f.get("fileName"), str)
assert isinstance(f.get("fileDate"), str)
modLoader = (
ModLoader.FORGE
if "Forge" in f["gameVersion"]
else ModLoader.FABRIC
if "Fabric" in f["gameVersion"]
else None
)
return cls(
f["id"],
f["gameVersion"],
f["fileName"],
modLoader,
parser.isoparse(f["fileDate"]),
)
class CurseAPI:
def __init__(self):
self._session = requests.Session()
self._session.headers[
"User-Agent"
] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0"
def get_latest_files(self, mod_id: int) -> Generator[File, None, None]:
res = self._session.get(f"{API}/addon/{mod_id}/files")
res.raise_for_status()
latest_files = res.json()
return (File.from_json(f) for f in latest_files)
def get_file_url(self, mod_id: int, file_id: int) -> str:
res = self._session.get(f"{API}/addon/{mod_id}/file/{file_id}/download-url")
res.raise_for_status()
return res.text.rstrip("\n")
def download_file(self, mod_id: int, file_id: int) -> bytes:
url = self.get_file_url(mod_id, file_id)
file_ = self._session.get(url)
file_.raise_for_status()
return file_.content
def main():
parser = argparse.ArgumentParser()
parser.add_argument("version", help="The minecraft version to limit updates to")
parser.add_argument(
"--mod-loader", choices=["none", "forge", "fabric"], default="forge"
)
parser.add_argument("--infile", type=pathlib.Path)
args = parser.parse_args()
if args.mod_loader == "forge":
mod_loader = ModLoader.FORGE
elif args.mod_loader == "fabric":
mod_loader = ModLoader.FABRIC
else:
raise AssertionError("Unreachable")
update(args.infile, args.version, mod_loader)
def update(infile: pathlib.Path, version: str, mod_loader: ModLoader):
with open(infile) as mods_json:
mods = json.load(mods_json)
curse = CurseAPI()
new_mods = []
for mod in mods:
print(f"Checking for updates to {mod['project']}...")
try:
latest_files = list(curse.get_latest_files(mod["project_id"]))
except requests.HTTPError as err:
print(f"WARNING: Could not access curse API for {mod['project']}: {err}")
latest_files = [_ for _ in []]
def compatible(file_: File) -> bool:
return (
mod_loader is None
or file_.modLoader is None
or file_.modLoader == mod_loader
) and any(
file_version.startswith(version) for file_version in file_.gameVersions
)
compatible_files = list(filter(compatible, latest_files))
if compatible_files:
latest = max(compatible_files, key=lambda f: f.date)
if latest.id != mod["id"]:
print(
f"Updating {mod['project']} {mod['filename']} -> {latest.name}..."
)
contents = curse.download_file(mod["project_id"], latest.id)
sha256 = hashlib.sha256(contents).hexdigest()
new_mod = deepcopy(mod)
new_mod.update(
{"filename": latest.name, "id": latest.id, "sha256": sha256}
)
new_mods.append(new_mod)
else:
new_mods.append(mod)
else:
print(f"WARNING: No compatible files found for {mod['project']}")
print(
f"Versions available: {[(f.name, f.gameVersions) for f in latest_files]}"
)
new_mods.append(mod)
with open("temp.json", "w") as out:
json.dump(new_mods, out, sort_keys=True, indent=2)
if __name__ == "__main__":
main()