ch.njol.util.Kleenean Java Examples

The following examples show how to use ch.njol.util.Kleenean. 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: ExprFurnaceSlot.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	isEvent = matchedPattern == 0;
	slot = parseResult.mark;
	if (isEvent && slot == RESULT && !ScriptLoader.isCurrentEvent(FurnaceSmeltEvent.class)) {
		Skript.error("Cannot use 'result slot' outside a fuel smelt event.");
		return false;
	} else if (isEvent && slot == FUEL && !ScriptLoader.isCurrentEvent(FurnaceBurnEvent.class)) {
		Skript.error("Cannot use 'fuel slot' outside a fuel burn event.");
		return false;
	}
	if (!isEvent)
		setExpr((Expression<Block>) exprs[0]);
	return true;
}
 
Example #2
Source File: ExprBlocks.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	switch (matchedPattern) {
		case 0:
			direction = (Expression<Direction>) exprs[0];
			from = exprs[1];
			break;
		case 1:
			from = exprs[0];
			direction = (Expression<Direction>) exprs[1];
			break;
		case 2:
		case 3:
			from = exprs[0];
			end = (Expression<Block>) exprs[1];
			break;
		default:
			assert false : matchedPattern;
			return false;
	}
	return true;
}
 
Example #3
Source File: ExprTimes.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	end = matchedPattern == 0 ? (Expression<Number>) exprs[0] : new SimpleLiteral<>(matchedPattern, false);
	
	if (end instanceof Literal) {
		int amount = ((Literal<Number>) end).getSingle().intValue();
		if (amount == 0 && isInLoop()) {
			Skript.warning("Looping zero times makes the code inside of the loop useless");
		} else if (amount == 1 & isInLoop()) {
			Skript.warning("Since you're looping exactly one time, you could simply remove the loop instead");
		} else if (amount < 0) {
			if (isInLoop())
				Skript.error("Looping a negative amount of times is impossible");
			else
				Skript.error("The times expression only supports positive numbers");
			return false;
		}
	}
	return true;
}
 
Example #4
Source File: ExprRandom.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	final Expression<?> expr = exprs[1].getConvertedExpression((((Literal<ClassInfo<?>>) exprs[0]).getSingle()).getC());
	if (expr == null)
		return false;
	this.expr = expr;
	return true;
}
 
Example #5
Source File: EffFileDownload.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int i, Kleenean k, ParseResult p) {
  url = (Expression<String>) e[0];
  path = (Expression<String>) e[1];
  return true;
}
 
Example #6
Source File: EffTimedClientSideHolo.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    text = (Expression<String>) exp[0];
    loc = (Expression<Location>) exp[1];
    player = (Expression<Player>) exp[2];
    time = (Expression<Timespan>) exp[3];
    return true;
}
 
Example #7
Source File: EffTitleV1_13_1.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    player = (Expression<Player>) exp[0];
    title = (Expression<String>) exp[1];
    subTitle = (Expression<String>) exp[2];
    time = (Expression<Timespan>) exp[3];
    fadeIn = (Expression<Timespan>) exp[4];
    fadeOut = (Expression<Timespan>) exp[5];
    return true;
}
 
Example #8
Source File: ExprMessage.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	type = MessageType.values()[matchedPattern];
	if (!ScriptLoader.isCurrentEvent(type.events)) {
		Skript.error("The " + type.name + " message can only be used in a " + type.name + " event", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	return true;
}
 
Example #9
Source File: EffEffectLibLine.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    start = exp[0];
    end = exp[1];
    id = (Expression<String>) exp[2];
    particle = (Expression<ParticleEffect>) exp[3];
    return true;
}
 
Example #10
Source File: ExprClicked.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	clickable = ClickableType.getClickable(parseResult.mark);
	switch (clickable) {
		case BLOCK_AND_ITEMS:
			final Object type = exprs[0] == null ? null : ((Literal<?>) exprs[0]).getSingle();
			if (type instanceof EntityData) {
				entityType = (EntityData<?>) type;
				if (!ScriptLoader.isCurrentEvent(PlayerInteractEntityEvent.class) && !ScriptLoader.isCurrentEvent(PlayerInteractAtEntityEvent.class)) {
					Skript.error("The expression 'clicked entity' may only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
					return false;
				}
			} else {
				itemType = (ItemType) type;
				if (!ScriptLoader.isCurrentEvent(PlayerInteractEvent.class)) {
					Skript.error("The expression 'clicked block' may only be used in a click event", ErrorQuality.SEMANTIC_ERROR);
					return false;
				}
			}
			break;
		case INVENTORY:
		case ACTION:
		case TYPE:
		case SLOT:
			if (!ScriptLoader.isCurrentEvent(InventoryClickEvent.class)) {
				Skript.error("The expression '" + clickable.getName() + "' may only be used in an inventory click event", ErrorQuality.SEMANTIC_ERROR);
				return false;
			}
			break;
	}
	return true;
}
 
Example #11
Source File: SimpleExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * <p>
 * This implementation sets the time but returns false.
 * 
 * @see #setTime(int, Class, Expression...)
 * @see #setTime(int, Expression, Class...)
 */
@Override
public boolean setTime(final int time) {
	if (ScriptLoader.hasDelayBefore == Kleenean.TRUE && time != 0) {
		Skript.error("Can't use time states after the event has already passed");
		return false;
	}
	this.time = time;
	return false;
}
 
Example #12
Source File: EffActionBarV1_12.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    player = (Expression<Player>) exp[0];
    text = (Expression<String>) exp[1];

    return true;
}
 
Example #13
Source File: EffToggle.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	blocks = (Expression<Block>) vars[0];
	toggle = matchedPattern - 1;
	return true;
}
 
Example #14
Source File: EffTabTitlesV1_10.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    player = (Expression<Player>) exp[2];
    coreHeader = (Expression<String>) exp[0];
    coreFooter = (Expression<String>) exp[1];
    return true;
}
 
Example #15
Source File: EffLeash.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, ParseResult parseResult) {
	leash = matchedPattern != 2;
	if (leash) {
		holder = (Expression<Entity>) exprs[1 - matchedPattern];
		targets = (Expression<LivingEntity>) exprs[matchedPattern];
	} else {
		targets = (Expression<LivingEntity>) exprs[0];
	}
	return true;
}
 
Example #16
Source File: ExprDamage.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	if (!ScriptLoader.isCurrentEvent(EntityDamageEvent.class, VehicleDamageEvent.class)) {
		Skript.error("The expression 'damage' may only be used in damage events", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	delay = isDelayed;
	return true;
}
 
Example #17
Source File: EffEditGroupIdScore.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    id = (Expression<String>) exp[0];
    newName = (Expression<String>) exp[1];
    newScore = (Expression<Number>) exp[2];

    return true;
}
 
Example #18
Source File: EffEquip.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	entities = (Expression<LivingEntity>) vars[0];
	types = (Expression<ItemType>) vars[1];
	return true;
}
 
Example #19
Source File: ExprInventorySlot.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, ParseResult parseResult) {
	if (matchedPattern == 0){
		 slots = (Expression<Number>) exprs[0];
		 invis = (Expression<Inventory>) exprs[1];
	} else {
		 slots = (Expression<Number>) exprs[1];
		 invis = (Expression<Inventory>) exprs[0];			
	}
	return true;
}
 
Example #20
Source File: EffCreateInteractiveStaticClientSideHolograms.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    id = (Expression<String>) exp[1];
    text = (Expression<String>) exp[0];
    loc = (Expression<Location>) exp[2];
    player = (Expression<Player>) exp[3];
    return true;
}
 
Example #21
Source File: EffParticlesV1_8_3.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    partNum = (Expression<Number>) exp[0];
    type = (Expression<String>) exp[1];
    location = (Expression<Location>) exp[2];
    xoffset = (Expression<Number>) exp[4];
    yoffset = (Expression<Number>) exp[5];
    zoffset = (Expression<Number>) exp[6];
    player = (Expression<Player>) exp[3];
    return true;
}
 
Example #22
Source File: EffSetScore.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    name = (Expression<String>) exp[0];
    player = (Expression<Player>) exp[1];
    num = (Expression<Number>) exp[2];
    return true;
}
 
Example #23
Source File: ExprBase64.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int i, Kleenean k, ParseResult p) {
  ty = p.mark;
  b64 = (Expression<String>) e[0];
  return true;
}
 
Example #24
Source File: EffSentryProtect.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    id = (Expression<Number>) exp[0];
    target = (Expression<Player>) exp[1];
    return true;
}
 
Example #25
Source File: EffEffectLibWave.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    target = exp[0];
    id = (Expression<String>) exp[1];
    particle = (Expression<ParticleEffect>) exp[2];
    return true;
}
 
Example #26
Source File: CondResourcePack.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	if (!ScriptLoader.isCurrentEvent(PlayerResourcePackStatusEvent.class)) {
		Skript.error("The resource pack condition can't be used outside of a resource pack response event");
		return false;
	}
	states = (Expression<Status>) exprs[0];
	setNegated(matchedPattern == 1);
	return true;
}
 
Example #27
Source File: EffToggleFlight.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	players = (Expression<Player>) exprs[0];
	allow = matchedPattern == 0;
	return true;
}
 
Example #28
Source File: EffNameOfScore.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exp, int arg1, Kleenean arg2, ParseResult arg3) {
    players = (Expression<Player>) exp[0];
    name = (Expression<String>) exp[1];
    return true;
}
 
Example #29
Source File: SimpleExpression.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
protected final boolean setTime(final int time, final Expression<?> mustbeDefaultVar, final Class<? extends Event>... applicableEvents) {
	if (ScriptLoader.hasDelayBefore == Kleenean.TRUE && time != 0) {
		Skript.error("Can't use time states after the event has already passed");
		return false;
	}
	if (!mustbeDefaultVar.isDefault())
		return false;
	for (final Class<? extends Event> e : applicableEvents) {
		if (ScriptLoader.isCurrentEvent(e)) {
			this.time = time;
			return true;
		}
	}
	return false;
}
 
Example #30
Source File: EffSuppressWarnings.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) {
	Config cs = ScriptLoader.currentScript;
	if (cs == null) {
		Skript.error("You can only suppress warnings for script files!");
		return false;
	}
	File scriptFile = cs.getFile();
	mark = parseResult.mark;
	switch (parseResult.mark) {
		case 1: { //Possible variable conflicts
			ScriptOptions.getInstance().setSuppressWarning(scriptFile, "conflict");
			break;
		}
		case 2: { //Variables cannot be saved
			ScriptOptions.getInstance().setSuppressWarning(scriptFile, "instance var");
			break;
		}
		case 3: { //Missing "and" or "or"
			ScriptOptions.getInstance().setSuppressWarning(scriptFile, "conjunction");
			break;
		}
		case 4: { //Variable starts with expression
			ScriptOptions.getInstance().setSuppressWarning(scriptFile, "start expression");
			break;
		}
		default: {
			throw new AssertionError();
		}
	}
	return true;
}