Coder Social home page Coder Social logo

mod-update-checker's Introduction

Update Checker for mods hosted on Modrinth.

How to use:

  • Add the update-checker to your project:
    • Maven:
<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependencies>
  ...
  <dependency>
    <groupId>com.github.lunatic-gh</groupId>
    <artifactId>mod-update-checker</artifactId>
    <version>%VERSION%</version>
  </dependency>
</dependencies>
  • Gradle:
repositories {
  maven { url = uri("https://jitpack.io") } // Kotlin
  maven { url "https://jitpack.io" } // Groovy
}

dependencies {
  implementation("com.github.lunatic-gh:mod-update-checker:%VERSION%")
}
  • Here's a basic example:
        // Create a new Update checker, in this example for the mod "modmenu", available at https://modrinth.com/mod/modmenu
        UpdateChecker updateChecker = new UpdateChecker("modmenu");
        // Set a filter.
        updateChecker.setFilter(version -> {
            // This will only queue versions that support the quilt loader. Only for the sake of the example, please don't use quilt :(
            boolean supportsQuilt = version.loaders().contains("quilt");
            // This will only queue versions that support 1.20.4.
            boolean supports_1_20_4 = version.gameVersions().contains("1.20.4");
            // return the filter result.
            return supportsQuilt && supports_1_20_4;
        });
        // Run a check. This will send an HTTP-Request via the modrinth api, to the given mod. It will run the below action for every version that matches the above filter.
        System.out.println("Checking for updates...");
        List<Version> versions = updateChecker.checkNow();
        if (!versions.isEmpty()) {
            System.out.println("Found the following matching versions:");
            versions.forEach(version -> System.out.println(version.fileVersion() + " | " + version.gameVersions() + " | " + version.loaders()));
        }

mod-update-checker's People

Contributors

lunatic-gh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.