-
Notifications
You must be signed in to change notification settings - Fork 112
uSkyBlock API
dutchy edited this page Jun 15, 2016
·
8 revisions
uSkyBlock has an API
First off, add the following to your pom.xml
<repositories>
<repository>
<id>uSkyBlock-mvn-repo</id>
<url>https://raw.github.com/rlf/uSkyBlock/mvn-repo/</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.6.4</version>
</dependency>
If you are not using maven, grab the api-jar from the Releases, 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
}
}
}