Advertisement
Gamebuster

EffOpenBrowser.class

Jan 12th, 2016
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. package com.gamebuster19901.GameBuSK.effects;
  2.  
  3. import org.bukkit.event.Event;
  4. import ch.njol.skript.lang.Effect;
  5. import ch.njol.skript.lang.Expression;
  6. import ch.njol.skript.lang.SkriptParser.ParseResult;
  7. import ch.njol.util.Kleenean;
  8.  
  9. import com.gamebuster19901.GameBuSK.exceptions.AlreadyExistsException;
  10. import com.gamebuster19901.GameBuSK.types.BrowserType;
  11.  
  12. public class EffOpenBrowser extends Effect{
  13.     private Expression<BrowserType> type;
  14.     private Expression<String> name;
  15.     private BrowserType finalType;
  16.  
  17.     @SuppressWarnings("unchecked")
  18.     @Override
  19.     public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean paramKleenean,
  20.             ParseResult paramParseResult) {
  21.         // TODO Auto-generated method stub
  22.         type = (Expression<BrowserType>) expr[0];
  23.         name = (Expression<String>) expr[1];
  24.        
  25.         if (BrowserType.convertString(type.toString()) == BrowserType.CHROME){
  26.             finalType = BrowserType.CHROME;
  27.         }
  28.         else if (BrowserType.convertString(type.toString()) == BrowserType.FIREFOX){
  29.             finalType = BrowserType.FIREFOX;
  30.         }
  31.         else if (BrowserType.convertString(type.toString()) == BrowserType.GHOST){
  32.             finalType = BrowserType.GHOST;
  33.         }
  34.         else{
  35.             finalType = null;
  36.         }
  37.         return true;
  38.     }
  39.  
  40.     @Override
  41.     public String toString(Event paramEvent, boolean paramBoolean) {
  42.         // TODO Auto-generated method stub
  43.         return "open window";
  44.     }
  45.  
  46.     @Override
  47.     protected void execute(Event paramEvent) {
  48.         // TODO Auto-generated method stub
  49.         try {
  50.             GWebDriver.create(finalType, name.getSingle(paramEvent));
  51.         } catch (AlreadyExistsException e) {
  52.             // TODO Auto-generated catch block
  53.             System.out.println("Window that is named this is already open");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement