Basics

Adding the library to your project

The current version of UpdateLib is 4.0.0
Maven
Gradle
pom.xml
1
<repositories>
2
<repository>
3
<id>hypera-releases</id>
4
<url>https://repo.hypera.dev/releases/</url>
5
</repository>
6
</repositories>
7
8
<dependencies>
9
<dependency>
10
<groupId>dev.hypera</groupId>
11
<artifactId>UpdateLib</artifactId>
12
<version>VERSION</version>
13
</dependency>
14
</dependencies>
Copied!
1
allprojects {
2
repositories {
3
maven { url 'https://repo.hypera.dev/releases' }
4
}
5
}
6
7
dependencies {
8
implementation 'dev.hypera:UpdateLib:VERSION'
9
}
Copied!

Using the library

1
public final class ExamplePlugin extends JavaPlugin implements Listener {
2
3
private static final long RESOURCE_ID = 12345; // Replace '12345' with your Resource ID.
4
private UpdateLib updateLib;
5
6
@Override
7
public void onEnable() {
8
getLogger().info("Starting...");
9
updateLib = UpdateLib.builder().resource(RESOURCE_ID).version(getDescription().getVersion()).handler(status -> {
10
if(status.isAvailable())
11
getLogger().info("Version " + status.getDistributedVersion() + " is now available!");
12
}).build();
13
getLogger().info("Successfully started!");
14
}
15
16
@Override
17
public void onDisable() {
18
getLogger().info("Disabled.");
19
}
20
21
@EventHandler
22
public void onJoin(PlayerJoinEvent event) {
23
if(event.getPlayer().hasPermission("exampleplugin.update")) {
24
if(updateLib.getLastStatus().isAvailable()) {
25
event.getPlayer().sendMessage("[ExamplePlugin] Version " + updateLib.getLastStatus().getDistributedVersion() + " is available!");
26
}
27
}
28
}
29
30
}
Copied!