Botre Posted March 21, 2016 Share Posted March 21, 2016 (edited) Example: Event event = new SpellOnItemEvent(NormalSpells.LVL_2_ENCHANT, "Emerald ring"); execute(event); if(event.getStatus() == EventStatus.FINISHED) { casts++; } Code: public class SpellOnItemEvent extends Event { private MagicSpell spell; private String item; public SpellOnItemEvent(MagicSpell spell, String item) { this.spell = spell; this.item = item; } @Override public int execute() throws InterruptedException { if(getMagic().isSpellSelected()) { int slot = getInventory().getSlot(item); long count = getInventory().getAmount(item); if(getMouse().click(new InventorySlotDestination(getBot(), slot))) { if(new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return getInventory().getAmount(item) != count; } }.sleep()) { setFinished(); } else { setFailed(); } } } else if(getMagic().castSpell(spell)) { if(!new ConditionalSleep(2400, 200) { @Override public boolean condition() throws InterruptedException { return getTabs().getOpen() == Tab.INVENTORY; } }.sleep()) { setFailed(); } } return MethodProvider.random(50, 150); } } Edited March 21, 2016 by Botre 6 Quote Link to comment Share on other sites More sharing options...
Harry Posted March 21, 2016 Share Posted March 21, 2016 Daddy Quote Link to comment Share on other sites More sharing options...
Deceiver Posted March 21, 2016 Share Posted March 21, 2016 hot snippet, might use Quote Link to comment Share on other sites More sharing options...