mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-22 18:46:53 +01:00
Updated Registering Custom Masks (markdown)
parent
41eac3ebb4
commit
31f3bc5cee
11
Registering-Custom-Masks,-Patterns-and-Transforms.md
Normal file
11
Registering-Custom-Masks,-Patterns-and-Transforms.md
Normal file
@ -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);
|
||||
```
|
Loading…
Reference in New Issue
Block a user