use of com.sk89q.worldedit.extension.input.ParserContext in project PlotSquared by IntellectualSites.
the class PatternUtil method parse.
public static Pattern parse(PlotPlayer<?> plotPlayer, String input, boolean allowLegacy) {
ParserContext context = new ParserContext();
if (plotPlayer != null) {
Actor actor = plotPlayer.toActor();
context.setActor(actor);
if (actor instanceof Player) {
context.setWorld(((Player) actor).getWorld());
}
context.setSession(WorldEdit.getInstance().getSessionManager().get(actor));
context.setRestricted(true);
} else {
context.setRestricted(false);
}
context.setPreferringWildcard(false);
context.setTryLegacy(allowLegacy);
try {
return WorldEdit.getInstance().getPatternFactory().parseFromInput(input, context);
} catch (InputParseException e) {
throw new Command.CommandException(TranslatableCaption.of("invalid.not_valid_block"), Template.of("value", e.getMessage()));
}
}
Aggregations