diff --git a/README.md b/README.md index b44b083..aab5fd6 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,54 @@ implementation 'de.griefed:versionchecker:$VERSION' For available versions, see the [sonatype repo](https://search.maven.org/artifact/de.griefed/versionchecker/) -# Example +# Examples See [UpdateCheckerTests](src/test/java/de/griefed/versionchecker/UpdateCheckerTests.java) +The simplest way to acquire update information is to call `.check(...)` of your GitHub- or GitHubChecker instances with your current version. +This will return an instance of [Update](https://github.com/Griefed/VersionChecker/blob/main/src/main/java/de/griefed/versionchecker/Update.java) which contains +details about the available update. It is wrapped in an Optional, so you can conveniently check via `.isPresent()` if an update is available. + +Once an instance of [Update](https://github.com/Griefed/VersionChecker/blob/main/src/main/java/de/griefed/versionchecker/Update.java) has been retrieved, +you can access information about it via any of the available methods. + +Example: + +```java +GitHubChecker GITHUB = new GitHubChecker("Griefed/ServerPackCreator"); + +Optional gitHubUpdate = GITHUB.check("3.0.1",false); +if (gitHubUpdate.isPresent()) { + + // Gets the version of this update as a String. + gitHubUpdate.get().version(); + + // Check whether the update has a description + if (gitHubUpdate.get().description().isPresent()) { + + // Get the description + gitHubUpdate.get().description().get(); + } + + // Get the url to the release page of this update + gitHubUpdate.get().url(); + + // Get the date at which this update has been released. + gitHubUpdate.get().releaseDate(); + + // Check if the update has any assets attached to it + if (gitHubUpdate.get().assets().isPresent()) { + + // Get the available assets of this update + gitHubUpdate.get().assets().get(); + } + + // Get the available source-archives of this update + gitHubUpdate.get().sources(); +} + +``` + ```java public class UpdateChecker { diff --git a/src/main/java/de/griefed/versionchecker/Update.java b/src/main/java/de/griefed/versionchecker/Update.java index cf28f11..fcfffd2 100644 --- a/src/main/java/de/griefed/versionchecker/Update.java +++ b/src/main/java/de/griefed/versionchecker/Update.java @@ -146,9 +146,9 @@ public Source sourceZip() { } /** - * Get the ZIP-archive-source of this update. + * Get the tar.gz-archive-source of this update. * @author Griefed - * @return {@link Source} of {@link ArchiveType#ZIP} of this update. + * @return {@link Source} of {@link ArchiveType#TAR_GZ} of this update. */ public Source sourceTarGz() { for (Source source : SOURCES) { @@ -160,9 +160,10 @@ public Source sourceTarGz() { } /** - * Get the ZIP-archive-source of this update. + * Get the tar-archive-source of this update. A tar-archive is usually only available for GitLab updates. GitHub typically + * only provides zip- and tar.gz-archives. * @author Griefed - * @return {@link Source} of {@link ArchiveType#ZIP} of this update, wrapped in an {@link Optional}. + * @return {@link Source} of {@link ArchiveType#TAR} of this update, wrapped in an {@link Optional}. */ public Optional sourceTar() { for (Source source : SOURCES) { @@ -174,9 +175,10 @@ public Optional sourceTar() { } /** - * Get the ZIP-archive-source of this update. + * Get the tar.bz2-archive-source of this update. A tar.bz2-archive is usually only available for GitLab updates. GitHub typically + * only provides zip- and tar.gz-archives. * @author Griefed - * @return {@link Source} of {@link ArchiveType#ZIP} of this update, wrapped in an {@link Optional}. + * @return {@link Source} of {@link ArchiveType#TAR_BZ2} of this update, wrapped in an {@link Optional}. */ public Optional sourceTarBz2() { for (Source source : SOURCES) {