Skip to content

PointsOfInterestAPI

crussell52 edited this page Sep 2, 2011 · 5 revisions

Who is it for?

Plugin Developers who want to write a plugin which interacts with the PointsOfInterest plugin for bukkit. If you are a strictly a server admin, then you do not need the API -- You can get the plugin here.

What is it?

The Points of Interest API is a jar file which allows your code to interact with my code.

Where is it?

The source is here and the download is there.

How do I use it?

If you are not familiar with implementing Interfaces in Java or including jars as libraries in Eclipse, you should brush up on these topics before attempting this.

1. Include PointsOfInterestAPI.jar as a library in your Eclipse project

Exactly how you do this is up to you, but I typically include it as an external jar through the "Build Path" dialog.

2. Create a class which implements crussell52.poi.api.IPoiListener

There is currently only one method to implement:

onEvent(crussell52.poi.api.PoiEvent event)

This will receive and react to a PoiEvent whenever one occurs. There are currently two event types:

// when player selects a POI or current poi is unselected
// crussell52.poi.api.IPoi getPoi() will represent the selected POI or have
// a value of null in the case of deselection.
PoiEvent.Type.SELECTION_CHANGE

// when player crosses the range boundary of their selected POI.
// Boolean inRange() will contain their current state.
// crussell52.poi.api.IPoi getPoi() will represent the related POI.
PoiEvent.Type.IN_RANGE_CHANGE

PoiEvent.getType() should be used to take action as necessary, based on which one of the above types it returns.

You will also have access to the related org.bukkit.entity.Player instance through PoiEvent.getPlayer().

3. Register your IPoiListener instance(s)

You can register any implementer of IPoiListener using the following code:

Plugin plugin = getServer().getPluginManager().getPlugin("PointsOfInterest");

if (plugin instanceof IPointsOfInterest) {
  ((IPointsOfInterest)plugin).registerPoiListener(PoiEvent.Type, IPoiListener);
}

4. Building your Plugin jar

You will need to include the PointsOfInterestAPI classes in your exported jar. Use your favorite technique to do this.

I use an ant script. You can find my ant script as well as a template for building your own in the PointsOfInterest project in my BukkitPlugins repository. Hopefully it helps!

5. Contact me

Feel free to contact me with any questions, comments, or suggestions! I will help in any way I can.

Enjoy!