-
-
Notifications
You must be signed in to change notification settings - Fork 1
Rewrite: API Creating your own Region Types
To create a new region type you must create a class that extends digital.murl.aurora.regions.Region
The region constructor should call super(id, world, "REGION TYPE NAME")
and set up its own data.
Region types must override the collisionCheck
and populateMap
functions
collisionCheck
should return true if the specified location is inside the area and false if it isn't.
populateMap
should fill the passed map with all the information that you want to be stored in the regions.json
file
To register the region use Aurora.registerRegionType("REGION TYPE NAME", CLASS::MAPCONSTRUCTOR, CLASS::PARAMETERCONSTRUCTOR, CLASS::PARAMETERCOMPLETER)
The 'mapConstructor' function is used to call the constructor using the data from the regions.json
file
This is how RegionWorld
constructs a region from the map:
public static Region mapConstructor(Map<String, Object> data) {
String id = (String)data.get("id");
String world = (String)data.get("world");
return new RegionWorld(id, world);
}
The 'parameterConstructor' function is used to call the constructor using parameters from chat commands
This is how RegionWorld
constructs a region from the string list
public static RegionParameterConstructor.Result parameterConstructor(Player sender, String[] params) {
if (params.length != 2)
return RegionParameterConstructor.Result.WRONG_SYNTAX;
Regions.addRegion(new RegionWorld(params[0], sender.getLocation().getWorld().getName()));
Regions.save();
return RegionParameterConstructor.Result.SUCCESS;
}
The 'parameterCompleter' function returns an array of strings that are used for chat command tab completion.