GravitLauncher Documentation

website·Indexed 31 days ago

https://gravitlauncher.com/

Technical documentation for GravitLauncher, covering initial setup, client configuration, and server binding. Includes detailed guides on the HTTP Auth Module API, AuthCoreProvider interface for authentication methods (Memory, SQL, http, FileAuthSystem), runtime settings, and support for Minecraft versions from 1.7.10 to 1.20.

Tokens
15.2K
Snippets
75
Records
102
Agent score
51%

What's inside GravitLauncher

  1. Overview of the GravitLauncher Runtime

    The Runtime is a module for the Launcher consisting of resources (FXML, CSS, PNG) that handle user interaction. It is built on JavaFX. Key tools for development include Scene Builder for FXML editing and the OpenJFX API and CSS reference guides.
  2. Implement security and protection in GravitLauncher

    GravitLauncher provides support for several security and protection mechanisms, including native protection, runtime encryption, ProGuard obfuscation, and signing of .jar and .exe files.
  3. Configure triggers for optional mods

    Triggers allow optional mods to be enabled automatically based on the user's environment, such as Operating System, Java version, or CPU architecture.
    "triggersList": [
      // OS Trigger: LINUX, MUSTDIE (Windows), MACOSX
      {
        "type": "os",
        "os": "MACOSX",
        "required": false,
        "inverted": false
      },
      // Java Version Trigger
      {
        "type": "java",
        "minVersion": 8,
        "maxVersion": 11,
        "required": true, // Mod is useless without this trigger
        "inverted": false
      },
      // Architecture Trigger
      {
        "type": "arch",
        "arch": "X86_64",
        "required": true,
        "inverted": false
      }
    ]
  4. Alternative authorization methods

    Besides SQL, GravitLauncher supports other authorization methods:

    • HTTP: Use a custom script or OAuth implementation.
    • FileAuthSystem: A module that allows storing logins and passwords in a file system without requiring a full database (DBMS).
  5. Customize GravitLauncher UI and behavior

    GravitLauncher is developed using Java and JavaFX, which allows for extensive customization of the launcher's interface and functionality.
  6. Install a Minecraft client via CLI

    Follow these steps to install a client. Note that MirrorHelper and workspace application are one-time setup tasks.
    # 1. Load MirrorHelper (one-time)
    modules load MirrorHelper_module
    
    # 2. Apply workspace (one-time)
    applyworkspace
    
    # 3. Download Forge/NeoForge installer (one-time per version, for 1.18+)
    downloadinstaller NEOFORGE 1.21.8
    
    # 4. Install the client
    installclient MyGreatClient 1.21.8 NEOFORGE
  7. Install LaunchServer using Docker

    LaunchServer is the core service responsible for launcher/client builds, authorization, and CMS integration. It can be installed via Docker.
    # Ubuntu/Debian/CentOS/Fedora
    curl -sSL https://get.docker.com/ | bash
    
    # ArchLinux
    pacman -S docker
    
    # Start Docker
    systemctl enable --now docker
  8. Add a server to the client server list

    To add a server to the distributed client list, manually configure it in a running client and then sync the data file to the LaunchServer.
    # Windows path example:
    # %appdata%/<Project-Name>/updates/<Client-Name>/servers.dat
  9. Customize Runtime Themes

    Themes are applied by virtually replacing standard theme files. To override a specific style file, place the modified version in the corresponding theme directory. For example, to replace styles/variables.css for the dark theme, place the file at themes/dark/styles/variables.css.
  10. Implement Two-Factor Authentication (2FA) flow

    To implement 2FA in the HTTP Auth Module:

    1. If 2FA is enabled for the user, return the error auth.require2fa during the initial authorization request.
    2. The client will prompt the user for a code and resend the request including the totpCode field.
    3. Verify the TOTP code on the server to complete the authorization process.
  11. Bind Velocity proxy to ServerWrapper

    Since Velocity does not use authlib, it must be patched manually using the provided patch file before being integrated with ServerWrapper.
    # 1. Patch Velocity
    git clone git@github.com:VelocityPowered/Velocity.git ./velocity
    wget https://mirror.gravitlauncher.com/5.7.x/patches/Velocity.patch
    cd ./velocity
    git am -3 ../Velocity.patch
    ./gradlew assemble
    cd ..
    mv ./velocity/proxy/build/libs/velocity-*-all.jar ./velocity.jar
    
    # 2. Setup ServerWrapper in the Velocity directory
    wget https://github.com/GravitLauncher/Launcher/releases/latest/download/ServerWrapper.jar
    java -jar ServerWrapper.jar setup
    # Then follow the installer instructions
  12. Create custom server buttons for specific profiles

    You can define unique serverButton layouts for specific profiles by creating FXML files named after the profile's UUID. Because these files are located in a subfolder, relative paths to images and CSS files in the FXML must be updated to account for the additional directory level.
    1. Create folder: components/serverButton
    2. Copy serverButton.fxml to this folder
    3. Rename it to: PROFILE_UUID.fxml (where PROFILE_UUID is the profile's UUID)
    
    Update FXML paths as follows:
    - Image: "@../../images/servers/example.png" (instead of "@../images/servers/example.png")
    - Components CSS: "@../components.css" (instead of "@components.css")
    - Global CSS: "@../../styles/global.css" (instead of "@../styles/global.css")
    - Variables CSS: "@../../styles/variables.css" (instead of "@../styles/variables.css")