protected boolean interact(Interactable target) {
Pattern action = this.getVar(InteractVar.ACTION);
Pattern name = this.getVar(InteractVar.NAME);
this.ctx.logger.fine(this.status("Action: " + action + " -> Target: " + target));
MenuItem item = null;
if (!Menu.isOpen() || ((item = Menu.getItem(target, action, name)) == null && Menu.close())) {
if (this.<Boolean>getVar(InteractVar.CLICK_ENABLED) && this.<Boolean>getVar(InteractVar.CLICK_ATTEMPT) && (target.contains(Mouse.getPosition()) || target.hover())) {
if (Menu.indexOf(action, name) == 0) {
if (target.click() && this.ctx.profile.reacting()) {
this.ctx.logger.fine(this.status("Left Click: " + target));
return true;
}
this.setVar(InteractVar.CLICK_ATTEMPT, false, Lifespan.TRANSIENT);
return false;
}
this.setVar(InteractVar.CLICK_ATTEMPT, false, Lifespan.TRANSIENT);
}
if ((target.contains(Mouse.getPosition()) || target.hover())) {
if (Mouse.click(Mouse.Button.RIGHT) && (Menu.isOpen() || Execution.delayUntil(Menu::isOpen, this.ctx.profile.rest(50, 100, 200)))) {
item = Menu.getItem(target instanceof ActionBar.Slot ? null : target, action, name);
}
}
}
if (item != null && (item.isVisible() || Execution.delayUntil(item::isVisible, this.ctx.profile.rest(300, 600, 900)))) {
Execution.delay(this.ctx.profile.decision(Menu.getItemCount()));
if ((item.contains(Mouse.getPosition()) || item.hover()) && item.isVisible()) {
if (Mouse.click(Mouse.Button.LEFT) && Mouse.wasClickSuccessful(target) && this.ctx.profile.reacting()) {
this.ctx.logger.fine(this.status("Right Click: " + action + " -> " + target));
return true;
}
}
}
return false;
}