package com.gamebuster19901.GameBuSK.expressions; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.util.SimpleExpression; import ch.njol.util.Kleenean; import com.gamebuster19901.GameBuSK.effects.GWebDriver; import com.gamebuster19901.GameBuSK.types.SearchType; import org.bukkit.event.Event; import org.openqa.selenium.WebElement; public class ExprGetElement extends SimpleExpression { private Expression searchType; private Expression parameter; private Expression driver; public Class getReturnType() { return WebElement.class; } public boolean isSingle() { return true; } public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, SkriptParser.ParseResult arg3) { this.searchType = (Expression) expr[0]; this.parameter = (Expression) expr[1]; this.driver = (Expression) expr[2]; if (this.driver == null){ System.out.println("driver is null"); return false; } return true; } public String toString(Event e, boolean arg1) { return "element found by " + searchType.getSingle(e) + " in " + driver.getSingle(e); } protected WebElement[] get(Event e) { SearchType finalType = this.searchType.getSingle(e); String finalParameter = this.parameter.getSingle(e); GWebDriver finalDriver = this.driver.getSingle(e); if (finalDriver == null){ System.out.println("THE DRIVER IS NULL THIS IS IMPOSSIBLE"); } WebElement element = finalDriver.GetElement(finalType, finalParameter); return new WebElement[]{element}; } }