The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

AIO Fishing Source



  • It might now be the best code, but it is something that you can learn from if you are new.

    Main.java

    package org.roma;
    
    import org.roma.logic.Bank;
    import org.roma.logic.Find;
    import org.roma.logic.Fish;
    import org.roma.logic.Location;
    import org.roma.logic.Traverse;
    import org.rspeer.runetek.api.component.tab.Skill;
    import org.rspeer.runetek.api.component.tab.Skills;
    import org.rspeer.runetek.api.movement.position.Area;
    import org.rspeer.runetek.event.listeners.RenderListener;
    import org.rspeer.runetek.event.types.RenderEvent;
    import org.rspeer.script.ScriptCategory;
    import org.rspeer.script.ScriptMeta;
    import org.rspeer.script.task.Task;
    import org.rspeer.script.task.TaskScript;
    
    import java.awt.*;
    
    @ScriptMeta(developer = "Roma", name = "Fast Fish", desc = "Find and Drops fish in all locations.", category = ScriptCategory.FISHING)
    public class Main extends TaskScript implements RenderListener {
    
    private GUI gui = new GUI();
    public static boolean isRunning = false;
    
    private int beginningXP;
    private long startTime;
    long runTime;
    
    public static Fish fish;
    public static Location location;
    
    public static Area FISH_AREA;
    public static Area BANK_AREA;
    
    public static boolean dropFish = false;
    
    public static final Task[] TASKS = { new Find(), new Traverse(), new Bank() };
    
    @Override
    public void onStart() {
         gui = new GUI();
         gui.open();
       
       location = gui.getSelectedLocation();
      if (isRunning) {
      	FISH_AREA = location.getFishArea();
      	BANK_AREA = location.getBankArea();
      	submit(TASKS);
      }
      startTime = System.currentTimeMillis();
      beginningXP = Skills.getExperience(Skill.FISHING);
    }
    
    private final Color color1 = new Color(46, 46, 46);
    private final Color color2 = new Color(254, 254, 254);
    
    private final Font font1 = new Font("Consolas", 0, 12);
    private final Font font2 = new Font("Consolas", 0, 11);
    
    public final String formatTime(final long ms) {
         long s = ms / 1000, m = s / 60, h = m / 60;
      s %= 60;
      m %= 60;
      h %= 24;
      return String.format("%02d:%02d:%02d", h, m, s);
    }
    
    @Override
    public void notify(RenderEvent renderEvent) {
       int currentXp = Skills.getExperience(Skill.FISHING);
      runTime = System.currentTimeMillis() - startTime;
      Graphics g = renderEvent.getSource();
      int xpGained = currentXp - beginningXP;
      g.setColor(color1);
      g.fillRect(3, 304, 516, 36);
      g.setFont(font1);
      g.setColor(color2);
      g.drawString("Experience Gained: " + xpGained, 11, 329);
      g.drawString("Elapsed Time: " + formatTime(runTime), 219, 329);
      g.setFont(font2);
      g.drawString("Fast Fish | Roma", 411, 329);
         }
    }
    

    Find.java

    package org.roma.logic;
    
    import org.roma.Main;
    import org.rspeer.runetek.adapter.component.Item;
    import org.rspeer.runetek.adapter.scene.Npc;
    import org.rspeer.runetek.api.commons.Time;
    import org.rspeer.runetek.api.component.Dialog;
    import org.rspeer.runetek.api.component.tab.Inventory;
    import org.rspeer.runetek.api.scene.Npcs;
    import org.rspeer.runetek.api.scene.Players;
    import org.rspeer.script.task.Task;
    import org.rspeer.ui.Log;
    
    public class Find extends Task {
    
       @Override
      public int execute() {
      	Log.info(Main.fish.getAction());
      	Npc fishSpot = Npcs.getNearest(Main.fish.getSpot().toString());
      	if (Dialog.canContinue()) {
      		if (Dialog.processContinue()) {
      			Time.sleep(1000);
      		}
      	}
    
      	if (Inventory.isFull()) {
      		for (Item item : Inventory.getItems()) {
      			if (item.getName().equals(Main.fish.getEquiptment())) {
      				// Don't do anything
      			} else if (item.getName().equals(Main.fish.getBait())) {
      				// Do nothing
      			} else {
      				item.interact("Drop");
      				Time.sleep(500, 1500);
      			}
      		}
      	} else {
      		if (fishSpot != null && !Players.getLocal().isAnimating()) {
      			fishSpot.interact(Main.fish.getAction());
      			Time.sleepUntil(() -> Players.getLocal().isAnimating() || Dialog.isOpen(), 1000);
      		}
    
      	}
      	return 300;
      }
    
      @Override
      public boolean validate() {
      	return !Players.getLocal().isAnimating() && !Inventory.isFull() && Main.FISH_AREA.contains(Players.getLocal())
      			&& Inventory.contains(Main.fish.getBait());
      }
    
    }
    

    GUI.java

    	package org.roma;
    	
    	import javax.swing.BoxLayout;
    	import javax.swing.DefaultComboBoxModel;
    	import javax.swing.JButton;
    	import javax.swing.JComboBox;
    	import javax.swing.JDialog;
    	import javax.swing.JLabel;
    	import javax.swing.JPanel;
    	import javax.swing.border.EmptyBorder;
    	
    	import org.roma.logic.Fish;
    	import org.roma.logic.Location;
    	
    	import java.awt.*;
    	import java.awt.event.ActionEvent;
    	import java.awt.event.ActionListener;
    	
    	public class GUI {
    		private final JDialog mainDialog;
    		private final JComboBox<Fish> fishSelector;
    		private final JComboBox<Location> locationSelector;
    	
    		private boolean started;
    	
    		public GUI() {
    	
    			mainDialog = new JDialog();
    			mainDialog.setTitle("Roma's Fast Fish");
    			mainDialog.setModal(true);
    			mainDialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    			mainDialog.setLocationRelativeTo(null);
    	
    			JPanel mainPanel = new JPanel();
    			mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
    			mainPanel.setBorder(new EmptyBorder(20, 20, 20, 20));
    			mainDialog.getContentPane().add(mainPanel);
    	
    			// Location
    	
    			JPanel locationSelectionPanel = new JPanel();
    			locationSelectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    	
    			JLabel locationSelectionLabel = new JLabel("Location:");
    			locationSelectionPanel.add(locationSelectionLabel);
    	
    			locationSelector = new JComboBox<>(Location.values());
    			locationSelectionPanel.add(locationSelector);
    	
    			mainPanel.add(locationSelectionPanel);
    	
    			JPanel fishSelectionPanel = new JPanel();
    			fishSelectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    	
    			JLabel fishSelectionLabel = new JLabel("Pick Fish:");
    			fishSelectionPanel.add(fishSelectionLabel);
    	
    			fishSelector = new JComboBox<>(Fish.values());
    			fishSelectionPanel.add(fishSelector);
    	
    			mainPanel.add(fishSelectionPanel);
    	
    			JButton startButton = new JButton("Start");
    			startButton.addActionListener(e -> {
    				started = true;
    				Main.isRunning = true;
    				close();
    			});
    			mainPanel.add(startButton);
    	
    			mainDialog.pack();
    	
    			locationSelector.addActionListener(new ActionListener() {
    	
    				@Override
    				public void actionPerformed(ActionEvent e) {
    					Location location = (Location) locationSelector.getSelectedItem();
    					fishSelector.setModel(new DefaultComboBoxModel<>(location.getFish()));
    				}
    			});
    			
    			startButton.addActionListener(new ActionListener() {
    				
    				@Override
    				public void actionPerformed(ActionEvent e) {
    					Main.location = (Location) locationSelector.getSelectedItem();
    					Main.fish = (Fish) fishSelector.getSelectedItem();
    				}
    			});
    			
    		}
    	
    		public boolean isStarted() {
    			return started;
    		}
    	
    		public Fish getSelectedTree() {
    			return (Fish) fishSelector.getSelectedItem();
    		}
    	
    		public Location getSelectedLocation() {
    			return (Location) locationSelector.getSelectedItem();
    		}
    	
    		public void open() {
    			mainDialog.setVisible(true);
    		}
    	
    		public void close() {
    			mainDialog.setVisible(false);
    			mainDialog.dispose();
    		}
    	}
    

    Fish.java

    	package org.roma.logic;
    	
    	import org.rspeer.runetek.api.component.tab.Skill;
    	import org.rspeer.runetek.api.component.tab.Skills;
    	
    	public enum Fish {
    		
    		SHRIMP("Small fishing net", "Fishing spot", "Net", "", 1),
    		SARDINE("Sardine", "Raw sardine", "Fishing rod", "Bait", 5),
    		KARAMBWANJI("Karambwanji", "Raw karambwanji", "Net", "", 5),
    		HERRING("Herring", "Raw herring", "Fishing rod", "Bait", 10),
    		ANCHOVIES("Anchovies", "Raw anchovies", "Net", "", 15),
    		MACKEREL("Mackerel", "Raw mackerel", "Big net", "", 16),
    		TROUT("Fly fishing rod", "Rod fishing spot", "Lure", "Feather", 20),
    		COD("Cod", "Raw cod", "Big net", "Bait", 23),
    		PIKE("Pike", "Raw pike", "Fishing rod", "Bait", 25),
    		SLIMY_EEL("Slimy eel", "Slimy eel", "Fishing rod", "Bait", 28),
    		SALMON("Salmon", "Raw salmon", "Fly fishing rod", "Feather", 30),
    		FROG_SPAWN("Frog spawn", "Frog spawn", "Net", "", 33),
    		TUNA("Tuna", "Raw tuna", "Harpoon", "", 35),
    		RAW_RAINBOW_FISH("Rainbow fish", "Raw rainbow fish", "Fly fishing rod", "", 38),
    		CAVE_EEL("Cave eel", "Raw cave eel", "Fishing rod", "Bait", 38),
    		LOBSTER("Lobster", "Raw lobster", "Lobster cage", "", 40),
    		BASS("Bass", "Raw bass", "Big net", "", 46),
    		SWORDFISH("Swordfish", "Raw swordfish", "Harpoon", "", 50),
    		MONKFISH("Monk fish", "Raw monkfish", "Net", "", 62),
    		KARAMBWAN("Karambwan", "Raw karambwan", "Karambwan vessel", "", 65),
    		SHARK("Shark", "Raw shark", "Harpoon", "", 76);
    		
    		@Override
    		public String toString() {
    			@SuppressWarnings("unused")
    			String name;
    			return name = name().substring(0,1).toUpperCase() + name().substring(1).toLowerCase().replaceAll("_", " ");
    	
    		}
    		
    		private final String equiptment, spot, action, bait;
    		private final int requiredLevel;
    		
    		Fish(final String equiptment, final String spot, final String action, final String bait, final int requiredLevel) {
    			this.equiptment = equiptment;
    			this.spot = spot;
    			this.requiredLevel = requiredLevel;
    			this.action = action;
    			this.bait = bait;
    		}
    		
    		public String getEquiptment() { return equiptment; }
    		
    		public String getSpot() { return spot; }
    		
    		public String getAction() { return action; }
    		
    		public String getBait() { return bait; }
    		
    		public int getRequiredLevel() { return requiredLevel; }
    		
    		public boolean isAccessible() {
    			return Skills.getCurrentLevel(Skill.FISHING) >= requiredLevel;
    		}
    	}
    

    Location.java

    package org.roma.logic;
    
    import org.rspeer.runetek.api.movement.position.Area;
    import org.rspeer.runetek.api.movement.position.Position;
    
    public enum Location {
    	POWERFISH(null, null, Fish.values()),
    	LUMBRIDGE_SWAMP(Area.rectangular(new Position(3236, 3153, 0), new Position(3246, 3139, 0)),
    			Area.rectangular(new Position(3241, 3146, 0), new Position(3249, 3146, 0)), Fish.SHRIMP),
    	LUMBRIDGE(Area.rectangular(new Position(3237, 3256, 0), new Position(3243, 3237, 0)),
    			Area.rectangular(new Position(3205, 3225, 2), new Position(3212, 3212, 0)), Fish.TROUT);;
    
    	@Override
    	public String toString() {
    		@SuppressWarnings("unused")
    		String name;
    		return name = name().substring(0,1).toUpperCase() + name().substring(1).toLowerCase().replaceAll("_", " ");
    
    	}
    
    	private final Area bankArea, fishArea;
    	private final Fish[] fish;
    
    	Location(final Area fishArea, final Area bankArea, final Fish... fish) {
    		this.bankArea = bankArea;
    		this.fishArea = fishArea;
    		this.fish = fish;
    	}
    
    	public Area getBankArea() {
    		return bankArea;
    	}
    
    	public Area getFishArea() {
    		return fishArea;
    	}
    
    	public Fish[] getFish() {
    		return fish;
    	}
    }
    

    Traverse.java

    package org.roma.logic;
    
    import org.roma.Main;
    import org.rspeer.runetek.api.component.tab.Inventory;
    import org.rspeer.runetek.api.movement.Movement;
    import org.rspeer.runetek.api.scene.Players;
    import org.rspeer.script.task.Task;
    import org.rspeer.ui.Log;
    
    public class Traverse extends Task {
    
    	@Override
    	public int execute() {
    		Log.info("Passed Walk");
    		Movement.walkTo(traverseToBank() ? Main.BANK_AREA.getCenter() : Main.FISH_AREA.getCenter());
    		return 300;
    	}
    
    	@Override
    	public boolean validate() {
    		return traverseToBank() || traverseToFish();
    	}
    
    	public boolean traverseToBank() {
    		return Inventory.isFull() && !Main.BANK_AREA.contains(Players.getLocal());
    	}
    	
    	public boolean traverseToFish() {
    		return !Inventory.isFull() && !Main.FISH_AREA.contains(Players.getLocal());
    	}
    }
    

    Bank.java

    package org.roma.logic;
    
    import org.roma.Main;
    import org.rspeer.runetek.api.commons.Time;
    import org.rspeer.runetek.api.component.tab.Inventory;
    import org.rspeer.runetek.api.scene.Players;
    import org.rspeer.script.task.Task;
    import org.rspeer.ui.Log;
    
    public class Bank extends Task {
    
    	@Override
    	public int execute() {
    		Log.info("Trying to depsoit");
    		String eq = Main.fish.getEquiptment();
    		String ba = Main.fish.getBait();
    		if (org.rspeer.runetek.api.component.Bank.isOpen()) {
    				org.rspeer.runetek.api.component.Bank.depositAllExcept(item -> item.getName().equalsIgnoreCase(eq) 
    						|| item.getName().equalsIgnoreCase(ba));
    		} else {
    			Log.info("Trying to open bank");
    			org.rspeer.runetek.api.component.Bank.open();
    			Time.sleepUntil(() -> org.rspeer.runetek.api.component.Bank.isOpen(), 1000);
    		}
    		return 300;
    	}
    
    	@Override
    	public boolean validate() {
    		return Inventory.isFull() && Main.BANK_AREA.contains(Players.getLocal());
    	}
    
    }
    


  • public Fish getSelectedTree() {
    return (Fish) fishSelector.getSelectedItem();
    }

    Lol wut



  • Good source script, can tell it's based off the tutorial which is honestly a good thing. This code structure rocks!



  • Why do you return 300? What is done with the return value?


 

47
Online

14.3k
Users

1.3k
Topics

17.6k
Posts