gorilla-devs / ferium

Fast and multi-source CLI program for managing Minecraft mods and modpacks from Modrinth, CurseForge, and GitHub Releases
Mozilla Public License 2.0
1.15k stars 49 forks source link

Folder based profiles #322

Open tippfehlr opened 1 year ago

tippfehlr commented 1 year ago

The Problem

Having to switch between profiles doesn’t go well with different mod folders. Also, upgrading all profiles at once can only be achieved when ferium knows what profile is supposed to be active in another mod folder. (#277)

Your Solution(s)

A solution would be to operate on the current folder. That way it is clear to the user on which folder ferium is operating and switching folders is not a hassle at all. While not an issue for me, a downside to this is that the user has to navigate to the mod folder.

Another option would be to have an extra stage in profile selection, where a working profile is selected, but profiles in other folders stay active. Here it would be beneficial to print the folder and profile at the beginning of commands.

theRookieCoder commented 1 year ago

Having to switch between profiles doesn’t go well with different mod folders.

May I know how?

Also, upgrading all profiles at once can only be achieved when ferium knows what profile is supposed to be active in another mod folder.

Why is that so? All the profile information is stored externally so this isn't a problem.

tippfehlr commented 1 year ago

May I know how?

My point is that there can be multiple profiles in active use, e.g. I have a server and a client profile. Though I admit that there is not much reason to change that because ferium still needs to know on which folder and profile to operate. My second solution seems appropriate to me here.

Why is that so? All the profile information is stored externally so this isn't a problem.

Say I have folder A with 2 profiles and folder B with 2 profiles, total 4 profiles, the current profile is A1. Now I want to upgrade all profiles, but ferium doesn’t know which profile in folder B it should upgrade (which profile was active last)

EDIT: I just read your reply here. The plan is to let GDLauncher manage the profiles and ferium manage the mods?

T3sT3ro commented 1 year ago

Folder based profiles have to be implemented carefully to grant benefits and avoid caching problems later. I think that the more robust way would be to depend on file system's features a little bit more than on arbitrary configuration files:

With this way the whole ferium configuration system file structure would look as follows:

.
├── current-modpack -> modpacks/Fabulously Optimized-4.9.3.mrpack
├── current-profile -> profiles/profileA/
├── mod-cache
│   └── e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
├── modpacks
│   └── Fabulously Optimized-4.9.3.mrpack
└── profiles
    ├── profileA
    │   ├── ferium-profile.json
    │   └── mods
    │       └── SomeMod-v1.0.jar -> ../../../mod-cache/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
    └── profileB
        ├── ferium-profile.json
        ├── mods
        │   ├── SomeMod-v1.0.jar -> ../../../mod-cache/e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
        │   └── UserMod-v5.2.jar -> ../user-mods/UserMod-v5.2.jar
        └── user-mods
            └── UserMod-v5.2.jar

In this concept, current profile and modpack are referenced by symlink at the top directory (current-profile/modpack), mod-cache serves a purpose of a global mod storage optimized for size, and each file in cache is named after a SHA256 hash of a jar file (thus reducing duplication). User mods are stored alongside profiles and profiles/<profilename>/mods is a directory holding only symlinks to real mods. This way, mounting a profile and changing active profile instance would be as simple as changing a symlink to appropriate mods/ directory in the profile (for example link .minecraft/mods to .ferium/profiles/profileA/mods). This relates to #109 and #219 (just delete/create symlink to enable/disable). #142 and #90 would benefit from this change. #321 would benefit, because import and export would be trivial.

And the biggest benefit, imo, would be the centralization of the files. I'm not a fan of having many different directories with mods all over my system. This would enforce the structure and would make it simpler to browse — everything is in one place. And if someone wants to get rid of all the mods and ferium all together, it's as simple as purging a directory.

This would also extend to other project types, for example plugins/, shaders/, resourcepacks/ etc.

I have also noticed, that the symlink to active profile would prevent from accidental active profile switches if someone was to manually tinker with the config.json. Currently active profile is stored as an index of profiles, which means that if the order was somehow changed (e.g. someone copy-pasted a profile into their json at the beginning), then the active profile would switch as well.