Jump to content

Malcolm

Global Moderator
  • Posts

    139825
  • Joined

  • Last visited

  • Days Won

    21
  • Feedback

    100%

Everything posted by Malcolm

  1. I much prefer to create a class that implements the runnable interface. This way it makes it much cleaner (at least imo). Here is an example for my V2 slayer cannon shot listener. private Thread cannonThread; private CannonListener cannonListener; public void startCannonListener() { cannonListener = new CannonListener(this); cannonThread = new Thread(cannonListener); cannonThread.start(); } and the CannonListener class public class CannonListener implements Runnable { private final Main script; private int shots = 0; private final ArrayList<Integer> loopList = new ArrayList<Integer>(); public CannonListener(final Main script) { this.script = script; } @Override public void run() { script.log("Starting cannon listener..."); while (script.getBot().getScriptExecutor().isRunning() || script.getBot().getScriptExecutor().isPaused()) { if (script.getClassProvider().getFighting().getCombatMaintenance().hasPlacedCannon()) { final List<Projectile> list = script.getProjectiles().filter(f -> f.getId() == 53); for (Projectile proj : list) { if (!loopList.contains(proj.getLoopCycle())) { shots += 1; loopList.add(proj.getLoopCycle()); } } } Timing.waitCondition(() -> false, 100); } } public int getShots() { return shots; } public void resetShots() { this.shots = 0; } }
×
×
  • Create New...