package fuzzyscripts.api; import bot.script.BotScript; import fuzzyscripts.api.gui.Gui; import fuzzyscripts.api.gui.GuiTab; import javax.swing.*; import java.awt.*; /** * @Author Josef */ public abstract class Script extends BotScript { private final Timer timer = new Timer(0); private final int[] skills = {Skills.SMITHING}; private final int index = nl.wbot.bot.a.get().getIndex(); private final SkillData sd = new SkillData(); private Gui gui; private GuiTab tab; private Object[][] data; @Override public int loop() { return 0; } @Override public boolean onStart() { if (start()) { gui = getGui(); if (gui != null) { } else return false; return true; } return false; } public boolean start() { getGui(); return true; } @Override public void onFinish() { if (getGui() != null) { getGui().removeTab(getIndex()); } } @Override public void paint(Graphics g) { getGui().getTabFor(this).updateRows(getData()); } public Gui getGui() { if (gui == null) { for (Frame f : JFrame.getFrames()) { if (f instanceof Gui) { return (Gui) f; } } return new Gui(); } return gui; } public int getIndex() { return index; } private Object[][] getData() { return data; } private void setData(Object[][] data) { Object[][] prepend = new Object[][]{{"Runtime:", timer.toElapsedString()}}; Object[][] combined = new Object[prepend.length + data.length][prepend.length + data.length]; System.arraycopy(prepend, 0, combined, 0, prepend.length); System.arraycopy(data, 0, combined, prepend.length, data.length); this.data = combined; } }