Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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<WebElement> {
- private Expression<SearchType> searchType;
- private Expression<String> parameter;
- private Expression<GWebDriver> driver;
- public Class<? extends WebElement> getReturnType() {
- return WebElement.class;
- }
- public boolean isSingle() {
- return true;
- }
- public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, SkriptParser.ParseResult arg3) {
- this.searchType = (Expression<SearchType>) expr[0];
- this.parameter = (Expression<String>) expr[1];
- this.driver = (Expression<GWebDriver>) 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};
- }
- }
Add Comment
Please, Sign In to add comment