Basics

Adding the library to your project

The current version of UpdateLib is 4.0.0

pom.xml
<repositories>
    <repository>
    <id>hypera-releases</id>
    <url>https://repo.hypera.dev/releases/</url>
  </repository>
</repositories>

<dependencies>
    <dependency>
    <groupId>dev.hypera</groupId>
    <artifactId>UpdateLib</artifactId>
    <version>VERSION</version>
  </dependency>
</dependencies>

Using the library

public final class ExamplePlugin extends JavaPlugin implements Listener {

	private static final long RESOURCE_ID = 12345; // Replace '12345' with your Resource ID.
	private UpdateLib updateLib;
	
	@Override
	public void onEnable() {
		getLogger().info("Starting...");
		updateLib = UpdateLib.builder().resource(RESOURCE_ID).version(getDescription().getVersion()).handler(status -> {
			if(status.isAvailable())
				getLogger().info("Version " + status.getDistributedVersion() + " is now available!");
		}).build();
		getLogger().info("Successfully started!");
	}

	@Override
	public void onDisable() {
		getLogger().info("Disabled.");
	}

	@EventHandler
	public void onJoin(PlayerJoinEvent event) {
		if(event.getPlayer().hasPermission("exampleplugin.update")) {
			if(updateLib.getLastStatus().isAvailable()) {
				event.getPlayer().sendMessage("[ExamplePlugin] Version " + updateLib.getLastStatus().getDistributedVersion() + " is available!");
			}
		}
	}

}

Last updated