Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.FlowLayout;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.Polygon;
- import java.awt.RenderingHints;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.text.NumberFormat;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Properties;
- import javax.swing.BorderFactory;
- import javax.swing.BoxLayout;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JTextField;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSCharacter;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSModel;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.util.GlobalConfiguration;
- /**
- * Change log:
- * v0.94: Fixed eating.
- * v0.93: Hide paint by clicking it.
- * v0.92: Loot support, mainly. Many small changes.
- * v0.91: Oops, forgot to add mouse speed settings!
- * v0.9: Initial release
- */
- @ScriptManifest(name = "TFighter", authors = "!@!@!", keywords = {"universal", "fighter", "!@!@!"}, version = 0.94)
- public class TFighter extends Script implements PaintListener, MouseListener {
- private final static ScriptManifest mani = TFighter.class.getAnnotation(ScriptManifest.class);
- private final Util u = new Util();
- private RSTile startTile;
- private long nextAntiban = 0;
- private int startTime = 0;
- private int mouseSpeedMin = 4, mouseSpeedMax = 7;
- private boolean startScript, showPaint;
- private boolean onlyInRadius = false;
- private boolean utilizeMultiwayCombat = false;
- public boolean onStart() {
- if(!game.isLoggedIn()) {
- log("Start logged in.");
- return false;
- }
- showPaint = true;
- startScript = false;
- FighterGUI gui = new FighterGUI();
- while(!startScript) {
- if(!gui.isVisible())
- return false;
- sleep(100);
- }
- startTile = getMyPlayer().getLocation();
- u.sw.poll();
- startTime = (int)System.currentTimeMillis();
- return true;
- }
- @Override
- public int loop() {
- if(random(0, 3) == 0 || mouse.getSpeed() < mouseSpeedMin || mouse.getSpeed() > mouseSpeedMax) {
- mouse.setSpeed(random(mouseSpeedMin, mouseSpeedMax));
- }
- if(u.eat.needEat()) {
- if(u.eat.haveFood()) {
- u.eat.eatFood();
- } else if(u.eat.haveB2pTab() && u.eat.haveBones()) {
- u.eat.breakB2pTab();
- return random(2600, 3000);
- } else {
- log("You ran out of food! Stopping.");
- stopScript();
- }
- return random(1200, 1600);
- }
- if(!walking.isRunEnabled() && walking.getEnergy() > random(60, 90)) {
- walking.setRun(true);
- return random(1200, 1600);
- }
- if(u.npcs.isInCombat()) {
- antiban();
- return random(50, 200);
- }
- RSGroundItem loot = u.loot.getLoot();
- if(loot != null) {
- int origCount = inventory.getCount(true);
- String name = loot.getItem().getName();
- int count = loot.getItem().getStackSize();
- int result = u.loot.takeItem(loot);
- if(result == 0) {
- waitWhileMoving();
- if(waitForInvChange(origCount)) {
- u.loot.addItem(name, count);
- }
- } else if(result == 1) {
- waitWhileMoving();
- }
- return random(50, 200);
- }
- RSNPC inter = u.npcs.getInteracting();
- RSNPC n = inter != null ? inter : u.npcs.getNPC();
- if(n != null) {
- int result = u.npcs.clickNPC(n, "Attack " + n.getName());
- if(result == 0) {
- waitWhileMoving();
- return random(300, 500);
- } else if(result == 1) {
- waitWhileMoving();
- return random(0, 200);
- }
- } else {
- if(calc.distanceTo(startTile) > 5) {
- walking.walkTileMM(walking.getClosestTileOnMap(startTile));
- waitWhileMoving();
- } else {
- antiban();
- }
- }
- return random(50, 300);
- }
- /**
- * Waits until we are no longer moving.
- */
- private void waitWhileMoving() {
- long start = System.currentTimeMillis();
- while(System.currentTimeMillis() - start < 1500 && !getMyPlayer().isMoving()) {
- sleep(random(50, 200));
- }
- while(getMyPlayer().isMoving()) {
- sleep(random(20, 50));
- }
- }
- /**
- * Waits until the inventory count changes
- */
- private boolean waitForInvChange(int origCount) {
- long start = System.currentTimeMillis();
- while(inventory.getCount(true) == origCount && System.currentTimeMillis() - start < 2000) {
- sleep(random(20, 70));
- }
- return inventory.getCount(true) != origCount;
- }
- /**
- * Performs a random action, always.
- * Actions: move mouse, move mouse off screen, move camera.
- */
- private void antiban() {
- if(System.currentTimeMillis() > nextAntiban) {
- nextAntiban = System.currentTimeMillis() + random(2000, 40000);
- } else {
- return;
- }
- switch(random(0, 4)) {
- case 0:
- mouse.moveOffScreen();
- break;
- case 1:
- mouse.move(random(0, game.getWidth()), random(0, game.getHeight()));
- break;
- case 2:
- camera.setAngle(camera.getAngle() + random(-100, 100));
- break;
- case 3:
- camera.setAngle(camera.getAngle() + random(-100, 100));
- break;
- }
- }
- @Override
- public void onRepaint(Graphics g) {
- if(!showPaint)
- return;
- final NumberFormat nf = NumberFormat.getIntegerInstance();
- ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- //Variables
- RSComponent inter = interfaces.get(137).getComponent(0);
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- //Counters
- int runTime = (int)System.currentTimeMillis() - startTime;
- //Background
- g.setColor(Color.BLACK);
- g.fillRect(x, y, inter.getWidth() + 5, inter.getHeight() + 5);
- //Simple things
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.PLAIN, 18));
- g.drawString("TFighter by !@!@! (v" + mani.version() + ")", x + 10, y += g.getFontMetrics().getMaxAscent() + 10);
- g.setFont(new Font("Arial", Font.PLAIN, 12));
- g.drawString("Run time: " + millisToTime(runTime), x + 20, y += g.getFontMetrics().getMaxAscent() + 5);
- //Exp gains
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Experience gained:", x + 20, y += g.getFontMetrics().getMaxAscent() + 15);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- for(Map.Entry<String, Integer> entry : u.sw.getExpGainedMap().entrySet()) {
- double expPerSec = entry.getValue() / (double)(runTime / 1000);
- int expPerHour = (int)Math.round(expPerSec * 3600);
- g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
- " (p/hr: " + nf.format(expPerHour) + ")", x + 25, y += g.getFontMetrics().getMaxAscent());
- }
- //Loot
- y = inter.getLocation().y;
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Loot taken:", x + 280, y += g.getFontMetrics().getMaxAscent() + 15);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- Map<String, Integer> loot = u.loot.getLootTaken();
- for(Map.Entry<String, Integer> entry : loot.entrySet()) {
- g.drawString(entry.getKey() + " x" + entry.getValue(), x + 285, y += g.getFontMetrics().getMaxAscent());
- }
- }
- /**
- * Formats the given value into a clock format
- * that follows the form of 00:00:00
- *
- * @param millis The total millis to be evaluated
- * @return A String representation of millis, formatted as a clock
- */
- private String millisToTime(int millis) {
- int hours = millis / (60 * 1000 * 60);
- int minutes = (millis - (hours * 60 * 1000 * 60)) / (60 * 1000);
- int seconds = (millis - (hours * 60 * 1000 * 60) - (minutes * 60 * 1000)) / 1000;
- return (hours >= 10 ? hours + ":" : "0" + hours + ":")
- + (minutes >= 10 ? minutes + ":" : "0" + minutes + ":")
- + (seconds >= 10 ? seconds : "0" + seconds);
- }
- private class Util {
- private final NPCs npcs = new NPCs();
- private final Eating eat = new Eating();
- private final Loot loot = new Loot();
- private final SkillWatcher sw = new SkillWatcher();
- }
- private class NPCs {
- private int[] npcIDs = new int[0];
- private String[] npcNames = new String[0];
- private int maxRadius = 10;
- /**
- * Checks if we are in combat.
- * @return True if we are in combat.
- */
- private boolean isInCombat() {
- return getMyPlayer().getInteracting() instanceof RSNPC;
- }
- /**
- * Clicks an NPC based on its model.
- * @param npc The NPC to click.
- * @param action The action to perform.
- * @return 0 if the NPC was clicked, 1 if we walked to it, or -1 if nothing happened.
- */
- private int clickNPC(RSNPC npc, String action) {
- for(int i = 0; i < 10; i++) {
- if(isPartiallyOnScreen(npc.getModel())) {
- Point p = getPointOnScreen(npc.getModel(), false);
- if(!calc.pointOnScreen(p)) {
- continue;
- }
- mouse.move(p);
- if(menu.getItems()[0].contains(action)) {
- mouse.click(true);
- return 0;
- } else if(menu.contains(action)) {
- mouse.click(false);
- sleep(random(100, 200));
- for(int x = 0; x < 4; x++) {
- if(!menu.contains(action)) {
- break;
- }
- if(menu.doAction(action)) {
- return 0;
- }
- }
- }
- } else {
- walking.walkTileMM(closerTile(npc.getLocation() , 1), 2, 2);
- return 1;
- }
- }
- return -1;
- }
- /**
- * Checks if a model is partially on screen.
- * @param m The RSModel to check.
- * @return True if any point on the model is on screen.
- */
- private boolean isPartiallyOnScreen(RSModel m) {
- return getPointOnScreen(m, true) != null;
- }
- /**
- * Gets a point on a model that is on screen.
- * @param m The RSModel to test.
- * @param first If true, it will return the first point that it finds on screen.
- * @return A random point on screen of an object.
- */
- private Point getPointOnScreen(RSModel m, boolean first) {
- if(m == null)
- return null;
- ArrayList<Point> list = new ArrayList<Point>();
- Polygon[] tris = m.getTriangles();
- for(int i = 0; i < tris.length; i++) {
- Polygon p = tris[i];
- for(int j = 0; j < p.xpoints.length; j++) {
- Point pt = new Point(p.xpoints[j], p.ypoints[j]);
- if(calc.pointOnScreen(pt)) {
- if(first)
- return pt;
- list.add(pt);
- }
- }
- }
- return list.size() > 0 ? list.get(random(0, list.size())) : null;
- }
- /**
- * Gets a closer tile to us within dist.
- * @param t The tile to start with.
- * @param dist The max dist.
- * @return A closer tile.
- */
- private RSTile closerTile(RSTile t, int dist) {
- RSTile loc = getMyPlayer().getLocation();
- int newX = t.getX(), newY = t.getY();
- for(int i = 1; i < dist; i++) {
- newX = t.getX() != loc.getX() ? (t.getX() < loc.getX() ? newX-- : newX++) : newX;
- newY = t.getY() != loc.getY() ? (t.getY() < loc.getY() ? newY-- : newY++) : newY;
- }
- return new RSTile(newX, newY);
- }
- /**
- * Returns the nearest NPC.
- * @return The nearest NPC that matches the filter.
- */
- private RSNPC getNPC() {
- return npcs.getNearest(npcFilter);
- }
- /**
- * Returns the interacting NPC that matches our description, if any.
- * @return The closest interacting NPC that matches the filter.
- */
- private RSNPC getInteracting() {
- RSNPC npc = null;
- int dist = 20;
- for(RSNPC n : npcs.getAll()) {
- if(!isOurNPC(n))
- continue;
- RSCharacter inter = n.getInteracting();
- if(inter != null && inter instanceof RSPlayer && inter.equals(getMyPlayer()) && calc.distanceTo(n) < dist) {
- dist = calc.distanceTo(n);
- npc = n;
- }
- }
- return npc;
- }
- private boolean isOurNPC(RSNPC t) {
- int id = t.getID();
- String name = t.getName();
- boolean good = false;
- for(int i : npcIDs) {
- if(id == i)
- good = true;
- }
- for(String s : npcNames) {
- if(name.toLowerCase().contains(s.toLowerCase()))
- good = true;
- }
- return good;
- }
- /**
- * The filter we use!
- */
- private final Filter<RSNPC> npcFilter = new Filter<RSNPC>() {
- public boolean accept(RSNPC t) {
- if(!isOurNPC(t))
- return false;
- return (t.isValid() && (!onlyInRadius || calc.distanceBetween(t.getLocation(), startTile) < maxRadius) && (utilizeMultiwayCombat || !t.isInCombat() && t.getInteracting() == null) && t.getHPPercent() != 0);
- }
- };
- }
- private class Eating {
- private final int[] B2P_TAB_ID = new int[] { 8015 };
- private final int[] BONES_ID = new int[] { 526, 532, 530, 528, 3183, 2859 };
- /**
- * Checks if we have at least one B2P tab.
- * @return True if we have a tab.
- */
- private boolean haveB2pTab() {
- return inventory.getCount(B2P_TAB_ID) > 0;
- }
- /**
- * Breaks a B2P tab.
- */
- private void breakB2pTab() {
- RSItem i = inventory.getItem(B2P_TAB_ID);
- if(i != null)
- i.doClick(true);
- }
- /**
- * Checks if the inventory contains bones, for B2P.
- * @return True if we have bones.
- */
- private boolean haveBones() {
- return inventory.getCount(BONES_ID) > 0;
- }
- /**
- * Checks if we have food.
- * @return True if we have food.
- */
- private boolean haveFood() {
- return getFood() != null;
- }
- /**
- * Finds food based on inventory actions.
- * @return The RSItem of food, or null if none was found.
- */
- private RSItem getFood() {
- for(RSItem i : inventory.getItems()) {
- if(i == null || i.getID() == -1)
- continue;
- if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null)
- continue;
- if (i.getComponent().getActions()[0].contains("Eat"))
- return i;
- }
- return null;
- }
- /**
- * Attempts to eat food.
- * @return True if we ate.
- */
- private boolean eatFood() {
- RSItem i = getFood();
- for(int j = 0; j < 3; j++) {
- if(i == null)
- break;
- if(i.doAction("Eat")) {
- return true;
- }
- }
- return false;
- }
- /**
- * Checks whether you need to eat or not.
- * @return True if we need to eat.
- */
- private boolean needEat() {
- return combat.getLifePoints() < ((skills.getRealLevel(Skills.CONSTITUTION) * 10) / 2);
- }
- }
- private class Loot {
- private int[] lootIDs = new int[0];
- private String[] lootNames = new String[0];
- private Map<String, Integer> lootTaken = new HashMap<String, Integer>();
- /**
- * Gets the nearest loot, based on the filter
- * @return The nearest item to loot, or null if none.
- */
- private RSGroundItem getLoot() {
- return groundItems.getNearest(lootFilter);
- }
- /**
- * Attempts to take an item.
- * @param item The item to take.
- * @return -1 if error, 0 if taken, 1 if walked
- */
- private int takeItem(RSGroundItem item) {
- if(item == null)
- return -1;
- String action = "Take " + item.getItem().getName();
- if(item.isOnScreen()) {
- for(int i = 0; i < 5; i++) {
- if(menu.isOpen())
- mouse.moveRandomly(300, 500);
- Point p = calc.tileToScreen(item.getLocation());
- if(!calc.pointOnScreen(p))
- continue;
- mouse.move(p, 3, 3);
- if(menu.contains(action)) {
- if(menu.getItems()[0].contains(action)) {
- mouse.click(true);
- return 0;
- } else {
- mouse.click(false);
- sleep(random(100, 200));
- if(menu.doAction(action))
- return 0;
- }
- }
- }
- } else {
- walking.walkTileMM(walking.getClosestTileOnMap(item.getLocation()));
- return 1;
- }
- return -1;
- }
- private void addItem(String name, int count) {
- if(lootTaken.get(name) != null) {
- int newCount = count + lootTaken.get(name);
- lootTaken.remove(name);
- lootTaken.put(name, newCount);
- } else {
- lootTaken.put(name, count);
- }
- }
- private Map<String, Integer> getLootTaken() {
- HashMap<String, Integer> m = new HashMap<String, Integer>();
- m.putAll(lootTaken);
- return m;
- }
- private final Filter<RSGroundItem> lootFilter = new Filter<RSGroundItem>() {
- public boolean accept(RSGroundItem t) {
- //Skip if we can't hold it
- RSItem i;
- if(inventory.isFull() && ((i = inventory.getItem(t.getItem().getID())) == null || i.getStackSize() <= 1)) {
- return false;
- }
- //Skip if its out of radius or far away
- if(onlyInRadius && calc.distanceBetween(t.getLocation(), startTile) > u.npcs.maxRadius
- || calc.distanceTo(t.getLocation()) > 25) {
- return false;
- }
- //Check ID/name
- boolean good = false;
- int id = t.getItem().getID();
- for(int iD : lootIDs) {
- if(iD == id)
- good = true;
- }
- String name = t.getItem().getName();
- for(String s : lootNames) {
- if(name != null && name.toLowerCase().contains(s.toLowerCase()))
- good = true;
- }
- return good;
- }
- };
- }
- private class SkillWatcher {
- private Map<Integer, Integer> startExpMap = new HashMap<Integer, Integer>();
- private final int[] SKILLS_TO_WATCH = new int[] { Skills.CONSTITUTION, Skills.ATTACK, Skills.STRENGTH, Skills.DEFENSE, Skills.RANGE, Skills.MAGIC };
- /**
- * Basically sets start exp for all skills we are watching.
- */
- private void poll() {
- for(int skill : SKILLS_TO_WATCH) {
- if(startExpMap.containsKey(skill))
- startExpMap.remove(skill);
- startExpMap.put(skill, skills.getCurrentExp(skill));
- }
- }
- /**
- * Returns the amount of exp gained in the specified skill.
- * @param skill The skill see Skills.*
- * @return
- */
- private int getExpGainedIn(int skill) {
- if(startExpMap.get(skill) == null)
- return -1;
- return skills.getCurrentExp(skill) - startExpMap.get(skill);
- }
- /**
- * Returns a map of skill names and exp gained.
- * @return A map of exp gains and skill names.
- */
- private Map<String, Integer> getExpGainedMap() {
- Map<String, Integer> map = new HashMap<String, Integer>();
- for(int i : SKILLS_TO_WATCH) {
- int gained = getExpGainedIn(i);
- if(gained != 0)
- map.put(Skills.SKILL_NAMES[i], gained);
- }
- return map;
- }
- }
- @SuppressWarnings("serial")
- private class FighterGUI extends JFrame {
- private final File file = new File(GlobalConfiguration.Paths.getSettingsDirectory() + System.getProperty("file.separator") + "TFighterProps.txt");
- private JCheckBox useMulti, useRadius;
- private JTextField npcBox, lootBox, mouseSpeedBox;
- private FighterGUI() {
- init();
- pack();
- setVisible(true);
- }
- private void init() {
- Properties props = loadProperties();
- JPanel north = new JPanel(new FlowLayout());
- north.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JLabel title = new JLabel("TFighter by !@!@!");
- title.setFont(new Font("Arial", Font.PLAIN, 28));
- north.add(title);
- }
- add(north, BorderLayout.NORTH);
- JPanel center = new JPanel();
- center.setLayout(new BoxLayout(center, BoxLayout.Y_AXIS));
- center.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- mouseSpeedBox = new JTextField("4,7");
- useMulti = new JCheckBox("Utilize multiway combat");
- useRadius = new JCheckBox("Only attack within a radius");
- npcBox = new JTextField("2,5,1,Chicke");
- lootBox = new JTextField("arrow,feather");
- if(props.getProperty("mouseSpeed") != null) {
- mouseSpeedBox.setText(props.getProperty("mouseSpeed"));
- }
- if(props.getProperty("useMulti") != null) {
- if(props.getProperty("useMulti").equals("true"))
- useMulti.setSelected(true);
- }
- if(props.getProperty("useRadius") != null) {
- if(props.getProperty("useRadius").equals("true"))
- useRadius.setSelected(true);
- }
- if(props.getProperty("npcBox") != null) {
- npcBox.setText(props.getProperty("npcBox"));
- }
- if(props.getProperty("lootBox") != null) {
- lootBox.setText(props.getProperty("lootBox"));
- }
- center.add(new JLabel("Enter your desired mouse speed (max,min)"));
- center.add(mouseSpeedBox);
- center.add(useMulti);
- center.add(useRadius);
- center.add(new JLabel(" "));
- center.add(new JLabel("Enter the IDs and/or names of the NPCs to fight."));
- center.add(new JLabel("You can mix and match these, all in the same box!"));
- center.add(npcBox);
- center.add(new JLabel("Enter the IDs and/or names of items to loot."));
- center.add(lootBox);
- }
- add(center, BorderLayout.CENTER);
- JPanel south = new JPanel(new FlowLayout());
- south.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JButton start = new JButton("Start script!");
- start.addActionListener(onStart);
- south.add(start);
- }
- add(south, BorderLayout.SOUTH);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setTitle("TFighter GUI");
- }
- private Properties loadProperties() {
- try {
- if(!file.exists())
- file.createNewFile();
- Properties p = new Properties();
- p.load(new FileInputStream(file));
- return p;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- private void saveProperties() {
- Properties p = new Properties();
- p.put("mouseSpeed", mouseSpeedBox.getText());
- p.put("useMulti", Boolean.toString(useMulti.isSelected()));
- p.put("useRadius", Boolean.toString(useRadius.isSelected()));
- p.put("npcBox", npcBox.getText());
- p.put("lootBox", lootBox.getText());
- try {
- p.store(new FileOutputStream(file), "");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private ActionListener onStart = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- saveProperties();
- startScript = true;
- mouseSpeedMin = Integer.parseInt(mouseSpeedBox.getText().split(",")[0]);
- mouseSpeedMax = Integer.parseInt(mouseSpeedBox.getText().split(",")[0]);
- utilizeMultiwayCombat = useMulti.isSelected();
- onlyInRadius = useRadius.isSelected();
- if(onlyInRadius) {
- u.npcs.maxRadius = Integer.parseInt(JOptionPane.showInputDialog("Enter the max radius. Example: 10"));
- }
- String[] ids = npcBox.getText().split(",");
- ArrayList<Integer> idList = new ArrayList<Integer>();
- ArrayList<String> nameList = new ArrayList<String>();
- for(int i = 0; i < ids.length; i++) {
- if(ids[i] != null && !ids[i].equals("")) {
- try {
- int id = Integer.parseInt(ids[i]);
- idList.add(id);
- } catch (Exception e1) {
- nameList.add(ids[i]);
- }
- }
- }
- u.npcs.npcIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[0])) : new int[0];
- u.npcs.npcNames = nameList.size() > 0 ? nameList.toArray(new String[0]) : new String[0];
- ids = lootBox.getText().split(",");
- idList = new ArrayList<Integer>();
- nameList = new ArrayList<String>();
- for(int i = 0; i < ids.length; i++) {
- if(ids[i] != null && !ids[i].equals("")) {
- try {
- int id = Integer.parseInt(ids[i]);
- idList.add(id);
- } catch (Exception e1) {
- nameList.add(ids[i]);
- }
- }
- }
- u.loot.lootIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[0])) : new int[0];
- u.loot.lootNames = nameList.size() > 0 ? nameList.toArray(new String[0]) : new String[0];
- dispose();
- }
- };
- private int[] toIntArray(Integer[] ints) {
- int[] done = new int[ints.length];
- for(int i = 0; i < done.length; i++) {
- done[i] = ints[i].intValue();
- }
- return done;
- }
- }
- @Override
- public void mouseClicked(MouseEvent e) {
- RSComponent inter = interfaces.get(137).getComponent(0);
- if(inter.getArea().contains(e.getPoint())) {
- showPaint = !showPaint;
- }
- }
- @Override
- public void mousePressed(MouseEvent e) { }
- @Override
- public void mouseReleased(MouseEvent e) { }
- @Override
- public void mouseEntered(MouseEvent e) { }
- @Override
- public void mouseExited(MouseEvent e) { }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement