Java Code Examples for ch.njol.skript.lang.SkriptParser#ParseResult

The following examples show how to use ch.njol.skript.lang.SkriptParser#ParseResult . 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: EffUnloadYaml.java    From skript-yaml with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
	file = (Expression<String>) exprs[0];
	mark = parser.mark;
	return true;
}
 
Example 2
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 3
Source File: EffPlayerVisibility.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, SkriptParser.ParseResult parseResult) {
	reveal = matchedPattern == 1;
	players = (Expression<Player>) exprs[0];
	if (reveal && players instanceof ExprHiddenPlayers)
		targetPlayers = exprs.length > 1 ? (Expression<Player>) exprs[1] : ((ExprHiddenPlayers) players).getPlayers();
	else
		targetPlayers = exprs.length > 1 ? (Expression<Player>) exprs[1] : null;
	return true;
}
 
Example 4
Source File: ExprInventory.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) {
	// if we're dealing with a loop of just this expression
	Node n = SkriptLogger.getNode();
	inLoop = n != null && ("loop " + parseResult.expr).equals(n.getKey());
	holders = (Expression<InventoryHolder>) exprs[0];
	return true;
}
 
Example 5
Source File: ExprGroup.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings({"unchecked"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	if (!VaultHook.permission.hasGroupSupport()) {
		Skript.error(VaultHook.NO_GROUP_SUPPORT);
		return false;
	}
	players = (Expression<OfflinePlayer>) exprs[0];
	primary = parseResult.mark == 0;
	return true;
}
 
Example 6
Source File: EffRunOpCmd.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, SkriptParser.ParseResult p) {
  usr = (Expression<Player>) e[0];
  str = (Expression<String>) e[1];
  return true;
}
 
Example 7
Source File: ExprDamagedItem.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, SkriptParser.ParseResult parseResult) {
	setExpr((Expression<ItemType>) exprs[0]);
	damage = (Expression<Number>) exprs[1];
	return true;
}
 
Example 8
Source File: ExprMorse.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, SkriptParser.ParseResult p) {
  ty = p.mark;
  str = (Expression<String>) e[0];
  return true;
}
 
Example 9
Source File: CondIsSymbolic.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, SkriptParser.ParseResult p) {
  path = (Expression<String>) e[0];
  setNegated(i == 1);
  return true;
}
 
Example 10
Source File: ExprEncrypt.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, SkriptParser.ParseResult p) {
  if (p.mark == 0) {
    ty = Cipher.ENCRYPT_MODE;
  } else {
    ty = Cipher.DECRYPT_MODE;
  }
  str = (Expression<String>) e[0];
  cipher = (Expression<String>) e[1];
  key = (Expression<String>) e[2];
  return true;
}
 
Example 11
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 12
Source File: EffSendBlockChange.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) {
	if (!SUPPORTED) {
		Skript.error("The send block change effect is not supported on this version. " +
				"If Spigot has added a replacement method without magic values " +
				"please open an issue at https://github.com/SkriptLang/Skript/issues " +
				"and support will be added for it.");
		return false;
	}
	players = (Expression<Player>) exprs[0];
	blocks = (Expression<Block>) exprs[1];
	as = (Expression<ItemType>) exprs[2];
	return true;
}
 
Example 13
Source File: ExprTPS.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) {
	if (!SUPPORTED) {
		Skript.error("The TPS expression is not supported on this server software");
		return false;
	}
	expr = parseResult.expr;
	index = matchedPattern;
	return true;
}
 
Example 14
Source File: EffZipDirectory.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, SkriptParser.ParseResult p) {
  file = (Expression<String>) e[0];
  zip = (Expression<String>) e[1];
  return true;
}
 
Example 15
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;
}
 
Example 16
Source File: LitNewLine.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final SkriptParser.ParseResult parseResult) {
	return true;
}
 
Example 17
Source File: ExprSpecialNumber.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	this.value = parseResult.mark;
	return true;
}
 
Example 18
Source File: ExprGetRegion.java    From skUtilities with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int i, Kleenean k, SkriptParser.ParseResult p) {
  return true;
}
 
Example 19
Source File: ExprReversedList.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	list = (Expression<Object>) exprs[0];
	return true;
}
 
Example 20
Source File: EffDeleteYaml.java    From skript-yaml with MIT License 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parser) {
	file = (Expression<String>) exprs[0];
	return true;
}