Hook into OreAnnouncer

OreAnnouncer offers a developer API to handle OreAnnouncer data and information about players and blocks. Whenever something will change in the future it will be deprecated then deleted with future updates, so never use deprecated methods.


Importing OreAnnouncer

To add the API to your project you can use use Maven, Gradle or manual adding in classpath.

Maven

<repositories>
  <repository>
    <id>alessiodp-repo</id>
    <url>https://repo.alessiodp.com/releases/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.alessiodp.oreannouncer</groupId>
    <artifactId>oreannouncer-api</artifactId>
    <version>2.7.2</version>
  </dependency>
</dependencies>

Gradle

repositories {
    maven {
        name = 'alessiodp-repo'
        url = 'https://repo.alessiodp.com/releases/'
    }
}

dependencies {
    compileOnly group: 'com.alessiodp.oreannouncer', name: 'oreannouncer-api', version: '2.7.2'
}

Usage

Your plugin must loaded after OreAnnouncer so you have to define this behavior in plugin.yml of your plugin by inserting OreAnnouncer as depend (or soft-depend):

depend: [OreAnnouncer]
soft-depend: [OreAnnouncer]

Before hook into it, be sure its enabled!

if (getServer().getPluginManager().getPlugin("OreAnnouncer") != null) {
    if (getServer().getPluginManager().getPlugin("OreAnnouncer").isEnabled()) {
        // OreAnnouncer is enabled
    }
}

Then you can take the instance of OreAnnouncer:

OreAnnouncerAPI api = OreAnnouncer.getApi();

API Methods

OreAnnouncer offers a class called OreAnnouncerAPI, you can declare it to call API methods. This is how you can use it:

OreAnnouncerAPI api = OreAnnouncer.getApi();
OAPlayer player = api.getOAPlayer(simplePlayer.getUniqueId()); // Get the player
if (player.haveAlertsOn()) {
  // Alerts enabled
} else {
  // Alers disabled
}

JavaDoc

You can find the JavaDoc here.

© AlessioDP 2015-2021