-
Notifications
You must be signed in to change notification settings - Fork 112
uSkyBlock API
Muspah edited this page May 29, 2019
·
8 revisions
uSkyBlock has an API
First off, add the following to your pom.xml
<repositories>
<repository>
<id>github-uskyblock-api</id>
<url>https://raw.githubusercontent.com/uskyblock/uskyblock-repo/master/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
And in your dependency-section:
<dependency>
<groupId>com.github.rlf</groupId>
<artifactId>uSkyBlock-API</artifactId>
<version>2.7.7</version>
</dependency>
If you are not using maven, grab the api-jar and put it in your classpath.
Write some code along these lines:
Plugin plugin = Bukkit.getPluginManager().getPlugin("uSkyBlock");
if (plugin instanceof uSkyBlockAPI && plugin.isEnabled()) {
uSkyBlockAPI usb = (uSkyBlockAPI) plugin;
player.sendMessage(String.format(
"\u00a79Your island score is \u00a74%5.2f!",
usb.getIslandLevel(player)
));
}
uSkyBlock fires events when it detects changes to the model, so if you want to integrate using the events, instead of polling, you are welcome.
/**
* Listener for catching uSkyBlock Events
*/
public class uSkyBlockListener implements Listener {
private static final Logger log = Logger.getLogger(uSkyBlockListener.class.getName());
@EventHandler
public void uSkyBlockEvent(uSkyBlockEvent e) {
log.log(Level.INFO, "Received uSkyBlockEvent: " + e);
if (e.getAPI() != null && e.getAPI().isEnabled()) {
// Access API
}
}
@EventHandler
public void uSkyBlockScoreChangedEvent(uSkyBlockScoreChangedEvent e) {
log.log(Level.INFO, "Received Score-Change Event: " + e);
IslandScore score = e.getScore();
if (score != null) {
// Do some magic here
}
}
}