-
Notifications
You must be signed in to change notification settings - Fork 16
API
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.
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);
}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.
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...
Feel like you can make HoloAPI better? Got something awesome to contribute? We're always looking for help! Feel free to place a fork in this repository and submit a pull request!
Setting up Images and Animations
Using the API - Step by Step Code Examples
Got something to share? Or just want to talk with the creators of HoloAPI? Come join us in IRC - #dsh105 @ irc.esper.net