registering transforms

This commit is contained in:
Jesse Boyd 2017-05-09 10:24:33 +10:00
parent 69f4b7abd6
commit 6fba806cda
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.factory.DefaultMaskParser; import com.sk89q.worldedit.extension.factory.DefaultMaskParser;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
import com.sk89q.worldedit.extension.factory.HashTagPatternParser; import com.sk89q.worldedit.extension.factory.HashTagPatternParser;
import com.sk89q.worldedit.extension.platform.CommandManager; import com.sk89q.worldedit.extension.platform.CommandManager;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -110,6 +111,18 @@ public class FaweAPI {
return parser != null; return parser != null;
} }
/**
* Add a custom transform for use in
* @see com.sk89q.worldedit.command.TransformCommands
* @param methods The class with a bunch of transform methods
* @return true if the transform was registered
*/
public static boolean registerTransforms(Object methods) {
DefaultTransformParser parser = Fawe.get().getTransformParser();
if (parser != null) parser.register(methods);
return parser != null;
}
public static <T> T getParser(Class<T> parserClass) { public static <T> T getParser(Class<T> parserClass) {
try { try {
Field field = AbstractFactory.class.getDeclaredField("parsers"); Field field = AbstractFactory.class.getDeclaredField("parsers");