Java Code Examples for ch.njol.skript.lang.Condition#parse()

The following examples show how to use ch.njol.skript.lang.Condition#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExprFilter.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	try {
		parsing = this;
		objects = LiteralUtils.defendExpression(exprs[0]);
		rawCond = parseResult.regexes.get(0).group();
		condition = Condition.parse(rawCond, "Can't understand this condition: " + rawCond);
	} finally {
		parsing = null;
	}
	return condition != null && LiteralUtils.canInitSafely(objects);
}
 
Example 2
Source File: ExprTernary.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	ifTrue = LiteralUtils.defendExpression(exprs[0]);
	ifFalse = LiteralUtils.defendExpression(exprs[1]);
	if (ifFalse instanceof ExprTernary<?> || ifTrue instanceof ExprTernary<?>) {
		Skript.error("Ternary operators may not be nested!");
		return false;
	}
	String cond = parseResult.regexes.get(0).group();
	condition = Condition.parse(cond, "Can't understand this condition: " + cond);
	return condition != null && LiteralUtils.canInitSafely(ifTrue, ifFalse);
}
 
Example 3
Source File: EffAssert.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"null", "unchecked"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	String cond = parseResult.regexes.get(0).group();
	condition = Condition.parse(cond, "Can't understand this condition: " + cond);
	errorMsg = (Expression<String>) exprs[0];
	return condition != null;
}
 
Example 4
Source File: EvtTestCase.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"null", "unchecked"})
@Override
public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseResult parseResult) {
	name = (Expression<String>) args[0];
	if (!parseResult.regexes.isEmpty()) { // Do not parse or run unless condition is met
		String cond = parseResult.regexes.get(0).group();
		condition = Condition.parse(cond, "Can't understand this condition: " + cond);
	}
	return true;
}
 
Example 5
Source File: EffDoIf.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	String eff = parseResult.regexes.get(0).group();
	String cond = parseResult.regexes.get(1).group();
	effect = Effect.parse(eff, "Can't understand this effect: " + eff);
	if (effect instanceof EffDoIf) {
		Skript.error("Do if effects may not be nested!");
		return false;
	}
	condition = Condition.parse(cond, "Can't understand this condition: " + cond);
	return effect != null && condition != null;
}