Java Code Examples for ch.njol.util.Kleenean#TRUE

The following examples show how to use ch.njol.util.Kleenean#TRUE . 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: EffCancelEvent.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
	if (isDelayed == Kleenean.TRUE) {
		Skript.error("Can't cancel an event anymore after it has already passed", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	cancel = matchedPattern == 0;
	final Class<? extends Event>[] es = ScriptLoader.getCurrentEvents();
	if (es == null)
		return false;
	for (final Class<? extends Event> e : es) {
		if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e))
			return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed)
	}
	if (ScriptLoader.isCurrentEvent(PlayerLoginEvent.class))
		Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR);
	else
		Skript.error(Utils.A(ScriptLoader.getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR);
	return false;
}
 
Example 2
Source File: SimpleExpressionFork.java    From skript-yaml with MIT License 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 3
Source File: SimpleExpressionFork.java    From skript-yaml with MIT License 5 votes vote down vote up
protected final boolean setTime(final int time, final Class<? extends Event> applicableEvent, final Expression<?>... mustbeDefaultVars) {
	if (ScriptLoader.hasDelayBefore == Kleenean.TRUE && time != 0) {
		Skript.error("Can't use time states after the event has already passed");
		return false;
	}
	if (!ScriptLoader.isCurrentEvent(applicableEvent))
		return false;
	for (final Expression<?> var : mustbeDefaultVars) {
		if (!var.isDefault()) {
			return false;
		}
	}
	this.time = time;
	return true;
}
 
Example 4
Source File: SimpleExpressionFork.java    From skript-yaml with MIT License 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 5
Source File: EntityData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("null")
@Override
public final boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
	this.matchedPattern = matchedPattern;
	// plural bits (0x3): 0 = singular, 1 = plural, 2 = unknown
	final int pluralBits = parseResult.mark & 0x3;
	this.plural = pluralBits == 1 ? Kleenean.TRUE : pluralBits == 0 ? Kleenean.FALSE : Kleenean.UNKNOWN;
	// age bits (0xC): 0 = unknown, 4 = baby, 8 = adult
	final int ageBits = parseResult.mark & 0xC;
	this.baby = ageBits == 4 ? Kleenean.TRUE : ageBits == 8 ? Kleenean.FALSE : Kleenean.UNKNOWN;
	return init(Arrays.copyOf(exprs, exprs.length, Literal[].class), matchedPattern, parseResult);
}
 
Example 6
Source File: ExprTimeState.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) {
	final Expression<?> expr = exprs[0];
	if (isDelayed == Kleenean.TRUE) {
		Skript.error("Cannot use time states after the event has already passed", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	if (!expr.setTime(matchedPattern >= 2 ? 1 : -1)) {
		Skript.error(expr + " does not have a " + (matchedPattern >= 2 ? "future" : "past") + " state", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	setExpr(expr);
	return true;
}
 
Example 7
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 8
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 Class<? extends Event> applicableEvent, final Expression<?>... mustbeDefaultVars) {
	if (ScriptLoader.hasDelayBefore == Kleenean.TRUE && time != 0) {
		Skript.error("Can't use time states after the event has already passed");
		return false;
	}
	if (!ScriptLoader.isCurrentEvent(applicableEvent))
		return false;
	for (final Expression<?> var : mustbeDefaultVars) {
		if (!var.isDefault()) {
			return false;
		}
	}
	this.time = time;
	return true;
}
 
Example 9
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 10
Source File: EffHidePlayerFromServerList.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
	boolean isServerPingEvent = ScriptLoader.isCurrentEvent(ServerListPingEvent.class) ||
			(PAPER_EVENT_EXISTS && ScriptLoader.isCurrentEvent(PaperServerListPingEvent.class));
	if (!isServerPingEvent) {
		Skript.error("The hide player from server list effect can't be used outside of a server list ping event");
		return false;
	} else if (isDelayed == Kleenean.TRUE) {
		Skript.error("Can't hide players from the server list anymore after the server list ping event has already passed");
		return false;
	}
	players = (Expression<Player>) exprs[0];
	return true;
}
 
Example 11
Source File: EffPlayerInfoVisibility.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, ParseResult parseResult) {
	if (!PAPER_EVENT_EXISTS) {
		Skript.error("The player info visibility effect requires Paper 1.12.2 or newer");
		return false;
	} else if (!ScriptLoader.isCurrentEvent(PaperServerListPingEvent.class)) {
		Skript.error("The player info visibility effect can't be used outside of a server list ping event");
		return false;
	} else if (isDelayed == Kleenean.TRUE) {
		Skript.error("Can't change the player info visibility anymore after the server list ping event has already passed");
		return false;
	}
	shouldHide = matchedPattern == 0;
	return true;
}
 
Example 12
Source File: EffScriptOptionLoops.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, ParseResult parseResult) {
	if(!ScriptLoader.isCurrentEvent(ScriptEvent.class) || isDelayed == Kleenean.TRUE){
		Skript.error("Current event is not Script Event or you have a delay before the script option. Defaulting to 2.2 loops.", ErrorQuality.SEMANTIC_ERROR);
		ScriptOptions.getInstance().setUsesNewLoops(ScriptLoader.currentScript.getFile(), true);
		return false;
	}
	ScriptOptions.getInstance().setUsesNewLoops(ScriptLoader.currentScript.getFile(), parseResult.mark == 2);
	return true;
}