ch.njol.skript.lang.util.SimpleExpression Java Examples

The following examples show how to use ch.njol.skript.lang.util.SimpleExpression. 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: EndermanData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean match(final Enderman entity) {
	return hand == null || SimpleExpression.check(hand, new Checker<ItemType>() {
		@SuppressWarnings("null")
		@Override
		public boolean check(final @Nullable ItemType t) {
			// TODO {Block/Material}Data -> Material conversion is not 100% accurate, needs a better solution
			if (useBlockData)
				return t != null && t.isOfType(entity.getCarriedBlock().getMaterial());
			else
				return t != null && t.isOfType(entity.getCarriedMaterial().getItemType());
		}
	}, false, false);
}
 
Example #2
Source File: SheepData.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean match(final Sheep entity) {
	return (sheared == 0 || entity.isSheared() == (sheared == 1))
			&& (colors == null || SimpleExpression.check(colors, c -> c != null && entity.getColor() == c.asDyeColor(), false, false));
}
 
Example #3
Source File: WrapperExpression.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
public WrapperExpression(final SimpleExpression<? extends T> expr) {
	this.expr = expr;
}
 
Example #4
Source File: Variable.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Event e, final Checker<? super T> c, final boolean negated) {
	return SimpleExpression.check(getAll(e), c, negated, getAnd());
}
 
Example #5
Source File: Variable.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Event e, final Checker<? super T> c) {
	return SimpleExpression.check(getAll(e), c, false, getAnd());
}
 
Example #6
Source File: VariableString.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Event e, final Checker<? super String> c, final boolean negated) {
	return SimpleExpression.check(getAll(e), c, negated, false);
}
 
Example #7
Source File: VariableString.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(final Event e, final Checker<? super String> c) {
	return SimpleExpression.check(getAll(e), c, false, false);
}
 
Example #8
Source File: EffColorItems.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
	items = (Expression<ItemType>) exprs[0];
	if (matchedPattern == 0) {
		color = (Expression<Color>) exprs[1];
	} else {
		color = new SimpleExpression<Color>() {
			
			private Expression<Number> red;
			private Expression<Number> green;
			private Expression<Number> blue;
			
			@Override
			public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
				red = (Expression<Number>) exprs[0];
				green = (Expression<Number>) exprs[1];
				blue = (Expression<Number>) exprs[2];
				return true;
			}
			
			@Nullable
			@Override
			protected Color[] get(Event e) {
				Number r = red.getSingle(e),
					g = green.getSingle(e),
					b = blue.getSingle(e);
				
				if (r == null || g == null || b == null)
					return null;
				
				return CollectionUtils.array(new ColorRGB(r.intValue(), g.intValue(), b.intValue()));
			}
			
			@Override
			public boolean isSingle() {
				return true;
			}
			
			@Override
			public Class<? extends Color> getReturnType() {
				return ColorRGB.class;
			}
			
			@Override
			public String toString(@Nullable Event e, boolean debug) {
				return "RED: " + red.toString(e, debug) + ", GREEN: " + green.toString(e, debug) + "BLUE: " + blue.toString(e, debug);
			}
		};
		color.init(CollectionUtils.array(exprs[1], exprs[2], exprs[3]), 0, isDelayed, parser);
	}
	return true;
}