API
Project setup
To add selectors or modifier to schematic brush some project setup is required.
Dependency
First add the dependency to your project.
Gradle
Maven
Configure Project
Now you have the schematic brush api in your project with the eldo-util. These are needed in order to register and parse new stuff. Schematic brush also provides the adventure api and a message blocker api. If you want to you them, you will have to relocate them as well
Please do not include the utilities in your project, but you will need to relocate them, since you will use the one shaded into schematic brush.
In gradle we use the shadowPlugin for this.
If you use maven you have to figure this out by yourself. It's a bit more complex.
Add SchematicBrushReborn as dependency to your plugin.yml
Adding stuff to Schematic Brush
First we need to retrieve the instance of the plugin.
Adding a new Setting
To add a new Setting you will need the BrushSettingsRegistry, a Setting and a Provider for this setting.
Adding a Selector
Lets look at how to create a new Selector. First we need a provider. For this we extend the Selector provider and implement all methods.
This selector will return all schematics which match a name. Of course this already exists.
If you have a look at the code and the commands it's really obvious.
The most essential stuff is the parse and complete method which will return your implemented selector.
Implementing the selector is already more easy. The important point here is that the selector needs to be serialized. The eldo util contain various utils to make this really easy.
The most important method is the select method, which returns the schematics which match the selector. You can use the methods provided by the SchematicCache to return schematics or write your own or even implement your own cache.
Quite simpel. Now we need to register the selector provider to make it available.
Adding a Schematic or Placement modifier
Adding those is quite similar to the selector.
You will need a again a provider, but instead off a SelectorProvider you use the ModifierProvider.
It really is quite similar. You will need to implement the complete and parse function again, but instead of a Selector you return a Mutator.
A mutator is used to change the paste process of the brush. The mutator is the same to a Selector but instead of a select method it has a invoke method.
You will also encounter one additional Interface to implement which is called Shiftable. This interface is used to provide changing values. If you want that the value change after each paste you will need to implement the valueProvider method to return different values. If you want it persistent just let the method return always the same value.
Lets take a look at two types of modifiers. The fixed offset and the rotation list.
The fixed offset is simple. It gets a single value. The valueProvider always returns this single value.
The invoke method changes the PasteMutation to add a offset on schematic paste.
A changing modifier is a bit but noch much more complex. The List modifier will always yield the next rotation and applies it to the PasteMutation.
We now need to create a provider for our two settings. These are completely equal to the SelectorProvider you jsut extend the ModifierProvider this time.
Once you have done this you can finally register them. We use the predfined SchematifModifier types. You can also add you own SchematicModifier type. This will cause your modifier to appear in a own section in the text uis.
Schematic modifier are set per schematic set. Placement modifier are set per brush.
Registering your own Schematic Cache
This is quite simple. Implement the Schematic Cache interface and register it.
Once you have done this you just need to register it with a key. This key can then be used in your Selector to retrieve the instance of your registered SchematicCache.