Updated Registering Custom Masks (markdown)

Jesse Boyd 2017-05-09 10:26:51 +10:00
parent 41eac3ebb4
commit 31f3bc5cee
2 changed files with 11 additions and 41 deletions

@ -0,0 +1,11 @@
With FAWE you can register your own custom masks, patterns and transforms.
```Java
FaweAPI.registerMasks(maskMethods);
FaweAPI.registerPatterns(patternMethods);
FaweAPI.registerTransforms(transformMethods);
```
Where
- `maskMethods` is a class like [this](https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/sk89q/worldedit/command/MaskCommands.java)
- `patternMethods` is a class like [this](https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/sk89q/worldedit/command/PatternCommands.java)
- `transformMethods` is a class like [this](https://github.com/boy0001/FastAsyncWorldedit/blob/master/core/src/main/java/com/sk89q/worldedit/command/TransformCommands.java)

@ -1,41 +0,0 @@
With FAWE you can register your own custom masks to be used in commands.
```Java
FaweAPI.registerMask(String name, Class<? extends CustomMask> mask)
```
Here's an example of a CustomMask implementation
```Java
/**
* A mask that only applies to blocks with NBT
*/
public class NBTMask extends CustomMask {
private final Extent extent;
/**
* Constructor for custom mask
* When used in commands, use #custom:<input>
*
* @param masks Any previous masks set (usually from //mask [previous] [thismask]
* @param input The input to parse
* @param context The context (for extent, player etc)
*/
public NBTMask(List<Mask> masks, String input, ParserContext context) {
super(masks, input, context);
this.extent = context.getExtent();
}
@Override
public String description() {
return null;
}
@Override
public boolean test(Vector vector) {
return extent.getBlock(vector).hasNbtData();
}
}
// Will be used in commands e.g. `//gmask #nbt`
FaweAPI.registerMask("nbt", NBTMask.class);
```