// Display the menu to the player (Depending on your platform, you may need to get the adventure audience for the Player here instead)
player.sendMessage(menu.toComponent());
// Use #toString to get a console-friendly version of the menu
getLogger().info(AboutMenu.toString());
@ -47,25 +50,24 @@ public class ExamplePlugin extends JavaPlugin {
</details>
### Version
`Version.class` provides a simple way to compare semantic plugin and Minecraft versions. `VersionChecker.class` provides
a utility for querying Spigot resources for the latest version of a plugin and comparing with the current version in
order to check for updates.
`Version.class` provides a simple way to compare semantic plugin and Minecraft versions. `VersionChecker.class` provides a utility for querying resources on different marketplaces (`SPIGOT`, `MODRINTH`, `POLYMART` and `GITHUB`) for the latest version of a plugin and comparing with the current version in order to check for updates.
<details>
<summary>Code snippet</summary>
<summary>Checking for updates</summary>
```java
public class ExamplePlugin extends JavaPlugin {
// Checks for updates and logs to console
public void checkForUpdates() {
final int spigotResourceId = 97144;
final UpdateChecker updateChecker = UpdateChecker.create(Version.fromString("1.0.0"), spigotResourceId);
getLogger().info("Running the latest version (" + updateChecker.getCurrentVersion() + ").");
} else {
getLogger().info("An update is available! Download from: https://www.spigotmc.org/resources/" + spigotResourceId);
final UpdateChecker checker = UpdateChecker.builder()
.currentVersion(getVersion())
.endpoint(UpdateChecker.Endpoint.MODRINTH)
.resource("velocitab")
.build();
checker.check().thenAccept(checked => {
if (!checked.isUpToDate()) {
getLogger().info("A new update is available: " + checked.getLatestVersion());
}
});
}
@ -74,36 +76,28 @@ public class ExamplePlugin extends JavaPlugin {
```
</details>
## Installation
DesertWell is available on JitPack. You can browse the Javadocs [here](https://javadoc.jitpack.io/net/william278/DesertWell/latest/javadoc/).
Note that your plugin will also need to shade (or shade a library that includes) [MineDown](https://github.com/Phoenix616/MineDown).
## Usage
DesertWell is available on JitPack and requires Adventure. You can browse the Javadocs [here](https://javadoc.jitpack.io/net/william278/DesertWell/latest/javadoc/).
<details>
<summary>Maven</summary>
To include the library with Maven, in your `pom.xml` file, first add the JitPack repository:
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<summary>Adding the library to your project</summary>
First, add the JitPack repository to your `build.gradle`:
```groovy
repositories {
maven { url 'https://jitpack.io' }
}
```
Then, add the dependency in your `<dependencies>` section. Remember to replace `Tag` with the current DesertWell version.