Esempio n. 1
0
 /**
  * Types a sequence of text
  *
  * @param text The text to type
  * @param minDelay The minimum delay between each key in milliseconds
  * @param maxDelay The maximum delay between each key in milliseconds
  */
 public void type(String text, int minDelay, int maxDelay) {
   final char[] chars = text.toCharArray();
   for (char c : chars) {
     type(c);
     Utils.sleep(Utils.random(minDelay, maxDelay));
   }
 }
Esempio n. 2
0
 /**
  * Types a sequence of text
  *
  * @param text The text to type
  */
 public void type(String text) {
   final char[] chars = text.toCharArray();
   for (char c : chars) {
     type(c);
     Utils.sleep(Utils.random(60, 250));
   }
 }
Esempio n. 3
0
 public boolean close() {
   if (!isOpen()) {
     return true;
   }
   Widget close =
       ctx.widgets
           .getValidated(
               new Filter<Widget>() {
                 @Override
                 public boolean accept(Widget element) {
                   return element.getParentId() == WIDGET_ID && element.getId() == CLOE_COMP_ID;
                 }
               })
           .get(0);
   if (close != null) {
     Point p = getCenter(close.getBounds());
     ctx.mouse.click(p.x, p.y);
     Timer t = new Timer(3000);
     while (isOpen() && t.isRunning()) {
       Utils.sleep(Utils.random(100, 200));
     }
   }
   return !isOpen();
 }
Esempio n. 4
0
 public boolean deposit(int itemId, int amt) {
   int[] ids =
       ctx.widgets
           .getValidated(
               new Filter<Widget>() {
                 @Override
                 public boolean accept(Widget element) {
                   return element.getParentId() == WIDGET_ID && element.getId() == ITEM_COMP_ID;
                 }
               })
           .get(0)
           .getSlotContents();
   int count = 0;
   boolean stack = false;
   if (ctx.inventory.getItem(itemId).getAmount() > 1) {
     count = ctx.inventory.getCount(true, itemId);
     stack = true;
   } else {
     count = ctx.inventory.getCount(false, itemId);
   }
   int index = -1;
   for (int i = 0; i < ids.length; i++) {
     if (ids[i] == itemId) {
       index = i;
       break;
     }
   }
   if (index == -1) {
     return false;
   }
   DepositBoxSlot[] slots = DepositBoxSlot.values();
   DepositBoxSlot slot = null;
   for (DepositBoxSlot slot1 : slots) {
     if (slot1.getInvIndex() == index) {
       slot = slot1;
       break;
     }
   }
   if (slot == null) {
     return false;
   }
   switch (amt) {
     case 1:
     case 5:
     case 10:
       if (ctx.menu.getBounds() == null) {
         ctx.mouse.move(slot.getRandomPoint().x, slot.getRandomPoint().y);
         Utils.sleep(Utils.random(100, 250));
         Timer t = new Timer(3000);
         while (ctx.menu.getBounds() == null && t.isRunning()) {
           Utils.sleep(100);
         }
       }
       if (ctx.menu.getBounds() != null) {
         Point p = ctx.menu.getClickPoint(ctx.menu.getIndex("Deposit " + amt));
         ctx.mouse.click(p.x, p.y);
         Utils.sleep(Utils.random(100, 250));
       }
       break;
     default:
       if (ctx.menu.getBounds() == null) {
         ctx.mouse.move(slot.getRandomPoint().x, slot.getRandomPoint().y);
         Utils.sleep(Utils.random(100, 250));
         Timer t = new Timer(3000);
         while (ctx.menu.getBounds() == null && t.isRunning()) {
           Utils.sleep(100);
         }
       }
       if (amt >= ctx.inventory.getItem(itemId).getAmount() || amt == 0) {
         if (ctx.menu.getBounds() != null) {
           Point p = ctx.menu.getClickPoint(ctx.menu.getIndex("Deposit " + amt));
           ctx.mouse.click(p.x, p.y);
           Utils.sleep(Utils.random(100, 250));
         }
       } else {
         if (ctx.menu.getBounds() != null) {
           Point p = ctx.menu.getClickPoint(ctx.menu.getIndex("Deposit-X"));
           ctx.mouse.click(p.x, p.y);
           Utils.sleep(Utils.random(100, 250));
         }
       }
       break;
   }
   if (stack) {
     return ctx.inventory.getItem(itemId).getAmount() == count - amt;
   }
   return ctx.inventory.getCount(false, itemId) == count - amt;
 }
Esempio n. 5
0
 /**
  * Holds a key down for a random time between min and max millis
  *
  * @param keycode The keycode, such as KeyEvent.VK_X
  * @param minMillis The minimum time to hold the key down for in milliseconds
  * @param maxMillis The maximum time to hold the key down for in milliseconds
  */
 public void hold(int keycode, int minMillis, int maxMillis) {
   hold(keycode, Utils.random(minMillis, maxMillis));
 }
Esempio n. 6
0
 /** Simulates pressing the 'enter' or 'return' key on the keyboard */
 public void enter() {
   ctx.keyboard.hold(KeyEvent.VK_ENTER, Utils.random(20, 50));
 }