Gamebuster

ExprGetElement.class

Mar 31st, 2016
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.80 KB | None | 0 0
  1. package com.gamebuster19901.GameBuSK.expressions;
  2.  
  3. import ch.njol.skript.lang.Expression;
  4. import ch.njol.skript.lang.SkriptParser;
  5. import ch.njol.skript.lang.util.SimpleExpression;
  6. import ch.njol.util.Kleenean;
  7. import com.gamebuster19901.GameBuSK.effects.GWebDriver;
  8. import com.gamebuster19901.GameBuSK.types.SearchType;
  9. import org.bukkit.event.Event;
  10. import org.openqa.selenium.WebElement;
  11.  
  12. public class ExprGetElement
  13. extends SimpleExpression<WebElement> {
  14.     private Expression<SearchType> searchType;
  15.     private Expression<String> parameter;
  16.     private Expression<GWebDriver> driver;
  17.  
  18.     public Class<? extends WebElement> getReturnType() {
  19.         return WebElement.class;
  20.     }
  21.  
  22.     public boolean isSingle() {
  23.         return true;
  24.     }
  25.  
  26.     public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, SkriptParser.ParseResult arg3) {
  27.         this.searchType = (Expression<SearchType>) expr[0];
  28.         this.parameter = (Expression<String>) expr[1];
  29.         this.driver = (Expression<GWebDriver>) expr[2];
  30.         if (this.driver == null){
  31.             System.out.println("driver is null");
  32.             return false;
  33.         }
  34.         return true;
  35.     }
  36.  
  37.     public String toString(Event e, boolean arg1) {
  38.         return "element found by " + searchType.getSingle(e) + " in " + driver.getSingle(e);
  39.     }
  40.  
  41.     protected WebElement[] get(Event e) {
  42.         SearchType finalType = this.searchType.getSingle(e);
  43.         String finalParameter = this.parameter.getSingle(e);
  44.         GWebDriver finalDriver = this.driver.getSingle(e);
  45.         if (finalDriver == null){
  46.             System.out.println("THE DRIVER IS NULL THIS IS IMPOSSIBLE");
  47.         }
  48.         WebElement element = finalDriver.GetElement(finalType, finalParameter);
  49.         return new WebElement[]{element};
  50.     }
  51. }
Add Comment
Please, Sign In to add comment