[ci skip] Update README

dependabot/gradle/net.kyori-adventure-api-4.14.0
William 2 years ago committed by GitHub
parent cc8e1113ae
commit 7c7311bc35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,8 @@
# DesertWell # DesertWell
[![Discord](https://img.shields.io/discord/818135932103557162?color=7289da&logo=discord)](https://discord.gg/tVYhJfyDWG) [![Discord](https://img.shields.io/discord/818135932103557162?color=7289da&logo=discord)](https://discord.gg/tVYhJfyDWG)
[![](https://jitpack.io/v/net.william278/DesertWell.svg)](https://jitpack.io/#net.william278/DesertWell) [![JitPack](https://jitpack.io/v/net.william278/DesertWell.svg)](https://jitpack.io/#net.william278/DesertWell)
DesertWell is a simple library providing various utilities to aid Minecraft plugin development. Requires Java 11+. **DesertWell** is a simple library providing various utilities to aid Minecraft plugin development on Adventure platforms. Requires Java 11+.
![Example of an about menu](images/about-menu-screenshot.png) ![Example of an about menu](images/about-menu-screenshot.png)
@ -10,33 +10,36 @@ DesertWell is a simple library providing various utilities to aid Minecraft plug
### About menus ### About menus
`AboutMenu.class` allows for the generation of plugin about menus, as seen above. `AboutMenu.class` allows for the generation of plugin about menus, as seen above.
To create an about menu, use `AboutMenu#create(title)` with the resource name, then use the various builder methods to To create an about menu, use `AboutMenu#create(title)` with the resource name, then use the various builder methods to build out the menu.
build out the menu.
<details> <details>
<summary>Code snippet</summary> <summary>Displaying an AboutMenu</summary>
```java ```java
public class ExamplePlugin extends JavaPlugin { public class ExamplePlugin extends JavaPlugin {
// Displays the about menu to the player and logs it to console // Displays the about menu to the player and logs it to console
public void showAboutMenu(Player player) { public void showAboutMenu(Player player) {
final AboutMenu menu = AboutMenu.create("Example")
.withDescription("A powerful, intuitive and flexible teleportation suite") final AboutMenu menu = AboutMenu.builder()
.withVersion(Version.fromString(plugin.getDescription().getVersion())) .title(Component.text("Example"))
.addAttribution("Author", .description(Component.text("An example plugin"))
AboutMenu.Credit.of("William278").withDescription("Click to visit website").withUrl("https://william278.net")) .version(plugin.getVersion())
.addAttribution("Contributors", .credits("Author",
AboutMenu.Credit.of("Contributor 1").withDescription("Code, refactoring") AboutMenu.Credit.of("William278").description("Click to visit website").url("https://william278.net"))
.addAttribution("Translators", .credits("Contributors",
AboutMenu.Credit.of("Translator 1").withDescription("Spanish (es-es)"), AboutMenu.Credit.of("Contributor 1").description("Code, refactoring"))
AboutMenu.Credit.of("Translator 2").withDescription("Italian (it-it)") .credits("Translators",
.addButtons( AboutMenu.Credit.of("FreeMonoid").description("Italian (it-it)"),
AboutMenu.Link.of("https://william278.net/").withText("Wesbite").withIcon("⛏"), AboutMenu.Credit.of("4drian3d").description("Coding"))
AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").withText("Discord").withIcon("⭐").withColor("#6773f5")))); .buttons(
AboutMenu.Link.of("https://william278.net/docs/velocitab").text("Docs").icon("⛏"),
// Display the menu to the player AboutMenu.Link.of("https://discord.gg/tVYhJfyDWG").text("Discord").icon("⭐").color(TextColor.color(0x6773f5)))
player.spigot().sendMessage(menu.toMineDown().toComponents()); .build();
// 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 // Use #toString to get a console-friendly version of the menu
getLogger().info(AboutMenu.toString()); getLogger().info(AboutMenu.toString());
@ -47,25 +50,24 @@ public class ExamplePlugin extends JavaPlugin {
</details> </details>
### Version ### Version
`Version.class` provides a simple way to compare semantic plugin and Minecraft versions. `VersionChecker.class` provides `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.
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.
<details> <details>
<summary>Code snippet</summary> <summary>Checking for updates</summary>
```java ```java
public class ExamplePlugin extends JavaPlugin { public class ExamplePlugin extends JavaPlugin {
// Checks for updates and logs to console // Checks for updates and logs to console
public void checkForUpdates() { public void checkForUpdates() {
final int spigotResourceId = 97144; final UpdateChecker checker = UpdateChecker.builder()
final UpdateChecker updateChecker = UpdateChecker.create(Version.fromString("1.0.0"), spigotResourceId); .currentVersion(getVersion())
updateChecker.isUpToDate().thenAccept(upToDate -> { .endpoint(UpdateChecker.Endpoint.MODRINTH)
if (upToDate) { .resource("velocitab")
getLogger().info("Running the latest version (" + updateChecker.getCurrentVersion() + ")."); .build();
} else { checker.check().thenAccept(checked => {
getLogger().info("An update is available! Download from: https://www.spigotmc.org/resources/" + spigotResourceId); if (!checked.isUpToDate()) {
getLogger().info("A new update is available: " + checked.getLatestVersion());
} }
}); });
} }
@ -74,36 +76,28 @@ public class ExamplePlugin extends JavaPlugin {
``` ```
</details> </details>
## Installation ## Usage
DesertWell is available on JitPack. You can browse the Javadocs [here](https://javadoc.jitpack.io/net/william278/DesertWell/latest/javadoc/). DesertWell is available on JitPack and requires Adventure. 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).
<details> <details>
<summary>Maven</summary> <summary>Adding the library to your project</summary>
To include the library with Maven, in your `pom.xml` file, first add the JitPack repository: First, add the JitPack repository to your `build.gradle`:
```xml ```groovy
<repositories> repositories {
<repository> maven { url 'https://jitpack.io' }
<id>jitpack.io</id> }
<url>https://jitpack.io</url>
</repository>
</repositories>
``` ```
Then, add the dependency in your `<dependencies>` section. Remember to replace `Tag` with the current DesertWell version. Then add the dependency:
```xml ```groovy
<dependency> dependencies {
<groupId>net.william278</groupId> implementation 'net.william278:PAPIProxyBridge:1.2'
<artifactId>DesertWell</artifactId> }
<version>Tag</version>
<scope>compile</scope>
</dependency>
``` ```
</details> </details>
### Gradle & others ### Maven & others
JitPack has a [handy guide](https://jitpack.io/#net.william278/DesertWell/#How_to) for how to use the dependency with other build platforms. JitPack has a [handy guide](https://jitpack.io/#net.william278/DesertWell/#How_to) for how to use the dependency with other build platforms.
## License ## License

Loading…
Cancel
Save