ch.njol.skript.lang.SkriptParser Java Examples

The following examples show how to use ch.njol.skript.lang.SkriptParser. 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: ExprBookPages.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "null"})
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
	if (matchedPattern == 0 || matchedPattern == 1){
		book = (Expression<ItemType>) exprs[0];
	}else{
		if (matchedPattern == 2){
			page =(Expression<Number>) exprs[0];
			book = (Expression<ItemType>) exprs[1];
		}else{
			book = (Expression<ItemType>) exprs[0];
			page = (Expression<Number>) exprs[1];
		}
	}
	return true;
}
 
Example #2
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 #3
Source File: CondisTimeZone.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) {
  str = (Expression<String>) e[0];
  setNegated(i == 1);
  return true;
}
 
Example #4
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 #5
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 #6
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 #7
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 #8
Source File: CondFileExists.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 #9
Source File: CondIsFile.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: EffZipFiles.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) {
  files = (Expression<String>) e[0];
  zip = (Expression<String>) e[1];
  return true;
}
 
Example #11
Source File: EffUnzip.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) {
  zip = (Expression<String>) e[0];
  file = (Expression<String>) e[1];
  return true;
}
 
Example #12
Source File: CondIsDirectory.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 #13
Source File: EffDeleteFile.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];
  ty = p.mark;
  return true;
}
 
Example #14
Source File: ExprFile.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] arg0, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
  if (!ScriptLoader.isCurrentEvent(EvtRunApp.class, EvtFileDownload.class, EvtFileCreation.class, EvtFileDeletion.class, EvtFileMove.class, EvtFileCopy.class, EvtFileRename.class, EvtFileWipe.class, EvtFileWrite.class, EvtUnzip.class, EvtFileZip.class)) {
    skUtilities.prSysE("Cannot use 'file' outside of file events!", getClass().getSimpleName());
    return false;
  }
  return true;
}
 
Example #15
Source File: CondisOS.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;
  setNegated(i == 1);
  return true;
}
 
Example #16
Source File: VisualEffect.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
public static VisualEffect parse(final String s) {
	final SyntaxElementInfo<VisualEffect> info = VisualEffect.info;
	if (info == null)
		return null;
	return SkriptParser.parseStatic(Noun.stripIndefiniteArticle(s), new SingleItemIterator<>(info), null);
}
 
Example #17
Source File: CondYamlExists.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) {
  yaml = (Expression<String>) e[0];
  path = (Expression<String>) e[1];
  setNegated(i == 1);
  return true;
}
 
Example #18
Source File: EffLoadServerIcon.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) {
	if (!PAPER_EVENT_EXISTS) {
		Skript.error("The load server icon effect requires Paper 1.12.2 or newer");
		return false;
	}
	path = (Expression<String>) exprs[0];
	return true;
}
 
Example #19
Source File: EffScriptFile.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) {
	mark = parseResult.mark;
	fileName = (Expression<String>) exprs[0];
	return true;
}
 
Example #20
Source File: EffContinue.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) {
	List<Loop> loops = ScriptLoader.currentLoops;
	if (loops.isEmpty()) {
		Skript.error("Continue may only be used in loops");
		return false;
	}
	Loop loop = loops.get(loops.size() - 1); // The most recent loop
	assert loop != null;
	this.loop = loop;
	return true;
}
 
Example #21
Source File: EffMakeSay.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) {
	players = (Expression<Player>) exprs[0];
	messages = (Expression<String>) exprs[1];
	return true;
}
 
Example #22
Source File: CondIsExecutable.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 #23
Source File: EffCancelCooldown.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 (!ScriptLoader.isCurrentEvent(ScriptCommandEvent.class)) {
		Skript.error("The cancel cooldown effect may only be used in a command", ErrorQuality.SEMANTIC_ERROR);
		return false;
	}
	cancel = matchedPattern == 0;
	return true;
}
 
Example #24
Source File: EffBreakNaturally.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 SkriptParser.ParseResult parser) {
	blocks = (Expression<Block>) exprs[0];
	tool = (Expression<ItemType>) exprs[1];
	return true;
}
 
Example #25
Source File: EffActionBar.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 SkriptParser.ParseResult parser) {
	message = (Expression<String>) exprs[0];
	recipients = (Expression<Player>) exprs[1];
	return true;
}
 
Example #26
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 #27
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 #28
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 #29
Source File: EffFunctionCall.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
public static EffFunctionCall parse(final String line) {
	final FunctionReference<?> function = new SkriptParser(line, SkriptParser.ALL_FLAGS, ParseContext.DEFAULT).parseFunction((Class<?>[]) null);
	if (function != null)
		return new EffFunctionCall(function);
	return null;
}
 
Example #30
Source File: ExprAllGroups.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 (!VaultHook.permission.hasGroupSupport()) {
		Skript.error(VaultHook.NO_GROUP_SUPPORT);
		return false;
	}
	return true;
}