Skip to content
DSH105 edited this page Mar 4, 2014 · 27 revisions

As A Maven Dependency

If you're familiar with Maven, you'll be able to automatically download HoloAPI as a dependency using the following repository.

<repositories>
    <repository>
        <id>hawk-repo</id>
        <url>http://ci.hawkfalcon.com/plugin/repository/everything/</url>
    </repository>
<!-- And so on... -->
</repositories>
<dependencies>
    <dependency>
        <groupId>com.dsh105<groupId>
        <artifactId>HoloAPI</artifactId>
        <version>1.0.3</version>
    </dependency>
<!-- And so on... -->
</dependencies>

Note: Change the version to whatever you require (even if it is a snapshot build! ;D).

If you don't use Maven, include it as a dependency in your IDE.

Please don't include the entire plugin in your JAR file. Instead, instruct your users to install HoloAPI as a required dependency.

Access The API

The API can be accessed like so:

import com.dsh105.holoapi.HoloAPI;
// Other Bukkit imports

public HoloAPI getHoloAPI() {
    Plugin plugin = this.getServer().getPluginManager().getPlugin("HoloAPI");
    if (plugin == null || !(plugin instanceof HoloAPI)) {
        // HoloAPI isn't installed (or loaded) on this server - nag the server owner about this
        return null;
    }

    return ((HoloAPI) plugin);
}

Using the API

Note: Many of these features may not be included in your version of HoloAPI. This Wiki will (almost) always be updated to reflect the latest changes, of which can sometimes include snapshot builds.

Hologram Factory

The Hologram Factory is the most important class to developers using the API. Those familiar of the StringBuilder will find this easy to use.

Holograms can be created using something similar to the following:

new HologramFactory()
    .withLocation(new Vector(x, y, z), "myWorld")
    .withText(ChatColor.GOLD + "Hey there!")
    .withImage("myImageKey")
    .withText(ChatColor.RED + "Enjoy your stay!")
    .build();

The above example will return a Hologram. The methods available in the Hologram Factory are as follows:

  • withLocation(...) - Two different methods with different arguments. Sets the location to create the hologram at. If this is not given, HoloAPI will not be able to create the hologram.
    • Location - Uses the location coordinates and world name as the hologram location
    • Vector, String - Uses the vector coordinates and string (world name) as the hologram location
  • withText(String...) - Adds the given set of strings, in order, to the hologram
  • withImage(...) - Adds the given image to the hologram
    • ImageGenerator - See below for how to create a new ImageGenerator
    • String - Finds the image that corresponds with the given image id. If an image is not found, the hologram will not change.
  • build() - Builds and returns the hologram. This also shows the hologram to all nearby players and tracks it using the HoloManager (see below)

More content coming soon...

Clone this wiki locally