BME PLUS API

Valid from version 1.2.0

Starting with BME Plus

Import the jar file into maven or gradle like every other plugin does. I do not provide a repo for it so here is a small example:

<dependency>
  <groupId>MCGBluemapEssentialsplus</groupId>
  <artifactId>MCGBluemapEssentials</artifactId>
  <version>1.2.0</version>
  <scope>system</scope>
  <systemPath>PATHTOJARFILE</systemPath>
</dependency>

Making a Module

Making a module must be done on every startup a good idea is to check if both BMEPlus and BlueMap are enabled and loaded and do exist: Bluemap is being checked by BMEPlus so you only have to check if the BME plugin is fully loaded. if not then something went wrong during startup as BMEPlus disables itself when bluemap isnt there or errors out

Plugin BME = Bukkit.getPluginManager().getPlugin("BluemapEssentialsPlus");
if(BME != null && BME .isEnabled()){
 //BME is loaded and exists
}

Next is prepairing the data you will need to generate the areas tiles or poi icons.

//For poi's
HashMap<Location,List<String>> mydata;
//For area's
HashMap<List<Location>,List<String>> mydata;
//For Chunks
HashMap<String,List<String>> mydata;



Lets see what they need: A poi just needs a location A area needs a list with a starting Location and Ending location like 2 opposites of a square. A Chunk needs a string with the X and Z of the chunk location Example: 2/5 And they all need a List of string that contains the baloondata like so:

// values are for labeling ("option/loc/title/x/y/z/world" Or
// "option/data/title/value" Or "option/pdata/value" or "option/head/title")
//!!! first item must always be a label for the icons !!!

List<String> mylist;
mylist.add("My poi label");
mylist.add("showspawn/pdata/The spawn for my poi");
mylist.add("showspawn/data/MyPoiSpawn/The spawn for my poi");
mylist.add("showspawn/head/MyPoiSpawn");
mylist.add("showspawn/loc/MyPoiSpawn/0/0/0/myworld");

A small example would be

HashMap<Location,List<String>> mydata = new HashMap<Location,List<String>>();
HashMap<Location,List<String>> mydata2 = new HashMap<Location,List<String>>();

Location spawnlocation = getmyspawnlocation;
Location portallocation = getmyportallocation;
List<String> mylist;
mylist.add("My poi label");
mylist.add("showspawn/pdata/The spawn for my poi");
mylist.add("showspawn/data/MyPoiSpawn/The spawn for my poi");
mylist.add("showspawn/head/MyPoiSpawn");
mylist.add("showspawn/loc/MyPoiSpawn/0/0/0/myworld");

List<String> mylist2;
mylist2.add("My portal label");
mylist2.add("showportal/pdata/The portal for my poi");
mylist2.add("showportal/data/portal/The Portal for my poi");
mylist2.add("showportal/head/portal");
mylist2.add("showportal/loc/portal/0/0/0/myworld");


mydata.put(Spawnlocation,mylist);
mydata2.put(portallocation ,mylist2);

Like said this is a small example you can implement looping and such to prepair the data for claims and other data lists if you know coding you know how to do that. Now its time for making the module:

BMEAPI api = BME.getBMEAPI(modulename, options, markersets);

Lets go over the arguments: Modulename = the name of your module. options a List<String> containing the name of the config options u can use when making the baloons this is a list for the entire module Markersets this is a List<String> of the markersets you want to provide in the end. this counts for the entire module. here is a small example:

List<String> myoptions = new ArrayList<String>();
List<String> Mysets = new ArrayList<String>();

myoptions.add("showportal");
myoptions.add("showspawn");

mysets.add("portals");
mysets.add("spawns");

BMEAPI api = BME.getBMEAPI(MyModuleName, myoptions, mysets);

Now you have made your module it automatically created the config file for it and loaded functions in for you to use.

api.generatepoi(hashmapdata,setname); //for pois
api.generatepoiareas(hashmapdata,setname,areacoloringlist); //for areas
api.generatechunkareas(hashmapdata,setname,areacoloringlist,world); // for chunks

i explained the hashmap data types before so you know which type to use in which function however as you can see the areas need a coloring list and the chunks also need a world. The coloring list can be generated using:

List<Integer> generateareacoloring(int fillr,int fillg, int fillb, int stroker,int strokeg, int strokeb)

It returns a Integer list that u can provide as argument on the spot. if you dont want to u can use the default coloring by setting it to NULL in the argument field. The coloring provides the looks of the infill and outline(stroke) of the area or chunk on the map The world must be the world that the chunk is in this is important for the generation of the locations.

Thats it! once you do that the sets should become visible and icons should pop up!

The data doesnt update itself you need to send the hashmap again after a while thats updated with the latest data. keep in mind the faster you send it the more lag you generate so i would keep a 15 minutes timer between updates if its large and at least 5 minutes if its small.

Some tips and tricks

Using options

Sometimes a POI or other marker has multiple details that can be shown however to give the user options for it you provide a list of options when creating the module. these options can be found back in the lines you add to the list:

mylist.add("showspawn/data/MyPoiSpawn/The spawn for my poi");

As you can see the first text is showspawn this is the option name from the config and the same as one in the list you provide on creating the module. If its false in the config it skips this line to be added to the balloon. (by default all are true)

Using multiple types of markers in one set?

This is possible by providing the same setname for both generate functions.

How to delete data?

Simply restart the server and all markers and sets are gone until you create the module again.

What not to do?

Creating multiple modules for the same plugin is not needed always use the same instance of the api when adding data never create a new instance for every update or datalist as this will create a new module in memory over and over creating a leak.

Never use the api without checking if the api exists if BME isnt loaded crashed or not exists using the api forcefully would crash the server or generate massive errors.

Never generate to quickly after the last generation. providing the generator again in a short timeframe causes huge cpu spikes to occeur as it will loop through your hashlist while the list is small this isnt a huge problem but once the data becomes bigger it becomes a load bearing problem for the server.

Last updated