ParkPlusMC
Search…
Custom
How to implement your own WayPoints

Create a Handler

First we need to create a new class extending IWayPointHandler this is what's going to fetch the information to display
CustomWayPointHandler.java
1
import nl.iobyte.parkplus.api.client.ClientConnection;
2
import nl.iobyte.parkplus.api.waypoint.enums.WayPointType;
3
import nl.iobyte.parkplus.api.waypoint.interfaces.IWayPointHandler;
4
import nl.iobyte.parkplus.api.waypoint.objects.RayData;
5
import nl.iobyte.parkplus.api.waypoint.objects.WayPoint;
6
7
public class CustomWayPointHandler implements IWayPointHandler {
8
9
public String getID() {
10
return "HANDLER_ID";
11
}
12
13
public WayPointType getType() {
14
return WayPointType.NO_UPDATE; // or UPDATE if the values change
15
}
16
17
public String getTitle(WayPoint point) {
18
return "Get the title here";
19
}
20
21
public String getDescription(WayPoint point, RayData data, ClientConnection client) {
22
return "Get the desciption here";
23
}
24
25
public String getCover(WayPoint point) {
26
return "http://example.com/cover.png";
27
}
28
29
}
30
Copied!
The description provides data about the WayPoint and Client

Register Hanlder

In order for us to use our custom handler we have to register it, this goes as follows:
1
WayPointService service = ParkPlus.getInstance().getAPI().getWayPointService();
2
service.addWayPointHandler(new CustomWayPointHandler())
Copied!
And that's it, you can now use your custom waypoint. Either by adding the waypoint in waypoints.yml or loading them in yourself. Example waypoints.yml:
waypoints.yml
1
waypoints:
2
<id>:
3
handler: HANDLER_ID
4
obstruct: <true/false>
5
range: <number of blocks>
6
location: '<world name>:<x>:<y>:<z>'
7
#Your data goes here
Copied!
The waypoints are loaded without any data, so you have to load the data yourself in the handler if you want to use the waypoints.yml for your custom handler. Or you can load your waypoints as follows:
1
WayPointService service = ParkPlus.getInstance().getAPI().getWayPointService();
2
service.addWayPoint(new WayPoint(
3
<id>,
4
<handler_id>,
5
<true/false>,
6
<number of blocks>,
7
location,
8
null //or class extending IWayPointData<T>
9
));
Copied!

Extending IWayPointData<T>

You can also pass a class instance to a handler using the IWayPointData<T> interface. See example:
1
import nl.iobyte.parkplus.api.waypoint.interfaces.IWayPointData;
2
3
public class CustomWayPointData implements IWayPointData<MyClass> {
4
5
public MyClass getValue() {
6
return null; //Return the instance of MyClass here
7
}
8
9
}
Copied!
Last modified 4mo ago