Som besökare på Hamsterpaj samtycker du till användandet av s.k. cookies för att förbättra din upplevelse hos oss. Jag förstår, ta bort denna ruta!
Annons

En kod.

Skapad av troll1, 2010-12-19 05:20 i Skräp & Spam

4 137
7 inlägg
0 poäng
troll1
Visningsbild
Hjälte 134 inlägg
0
Nu är det så att jag inte vet var denna ska ligga så om någon söt mod skulle kunna flytta den så skulle det vara super.

En kompis skicka mig en kod och frågade om jag kunde lista ut vad som var problemet, han har nämligen fått en kod (någon java grej) och när han klickade på complie-script så kom det upp: "Reached end of file while parsing" och så stod det 3311 (vilket vi antar är raden)

rad 3311 är: hasHatchet = false;
Och jag ser inte riktigt felet på det.

Hoppas ni kan lösa det, här har ni hela koden.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

import java.net.URL;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
//import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.ListSelectionModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;

import org.rsbot.event.events.MessageEvent;
import org.rsbot.event.listeners.MessageListener;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.script.Script;
import org.rsbot.script.ScriptManifest;
import org.rsbot.script.methods.Game;
import org.rsbot.script.methods.NPCs;
import org.rsbot.script.methods.Objects;
import org.rsbot.script.methods.Skills;
import org.rsbot.script.wrappers.RSCharacter;
import org.rsbot.script.wrappers.RSComponent;
import org.rsbot.script.wrappers.RSInterface;
import org.rsbot.script.wrappers.RSItem;
import org.rsbot.script.wrappers.RSNPC;
import org.rsbot.script.wrappers.RSObject;
import org.rsbot.script.wrappers.RSPlayer;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.util.GlobalConfiguration;
import org.rsbot.util.GlobalConfiguration.Paths;

@ScriptManifest(name = "ParaFishNCook", authors = {"Parameter"}, version = ParaFishNCook.VERSION,
keywords = "Fishing", description = "AiO Fisher and cooker.",
website = " http://www.powerbot.org/vb/showthread.php?244312-ParaFishNCook-PowerFisher-Cooker")
public class ParaFishNCook extends Script implements MouseListener, MouseMotionListener,
PaintListener, MessageListener {
public static final double VERSION = 1.291;
private static final int SETTINGS_VERSION = 8;

private static final int FISHING = 0, CHOPPING = 1,
FIRING = 2, COOKING = 3, DROPPING = 4;
private int status = FISHING;

private static final int TINDERBOX_ID = 590, FIRE_ID = 2732,
FIRING_ANIMATION = 733, COOKING_ANIMATION = 897;

private RSInterface magicIface, chatboxIface/*, musicPlayerIface*/;
private RSComponent cookingIface, amountDisplay, amountIncreaseButton, levelUpIface,
prayerIface, gameScreenIface;
private Rectangle cookingIfaceArea;
private static final Rectangle failCookingIfaceArea = new Rectangle(0, 0, 46, 81);

private RSNPC fishingSpot;
private RSTile fishingSpotTile;

private Set<Tree> trees = new HashSet<Tree>();
private final Set<Tree> unavailableTrees = new HashSet<Tree>();

private boolean update = true, hasHatchet = true, run, reversedFiremaking = random(0, 5) == 0;

// Antibans
private final AntibanAction[] antibans = {
// Mouse moving
new AntibanAction(500, 7500) {
protected void doAction() {
final int randInt = random(0, 15);
if(randInt < 10) {
//log("Gamescreen hover...");
if(!gameScreenIface.getArea().contains(mouse.getLocation()) &&
random(0, 4) != 0)
gameScreenIface.doHover();
else
mouse.moveRandomly(100);
} else if(randInt == 10) { // Chatbox text hover
//log("Chatbox text hover...");
final RSComponent lineComp = chatboxIface.getComponent(random(180, 188));
mouse.move(lineComp.getAbsoluteX() + random(0, lineComp.getText().length() * 5),
lineComp.getAbsoluteY() + random(0, lineComp.getHeight()));
} else if(randInt == 11) { // Common interface hover
//log("Common interface hover.");
commonHoverComponents[random(0, commonHoverComponents.length)].doHover();
} else if(randInt == 12) { // Inventory item hovering
//log("Inventory item hover....");
final List<RSItem> possible = new ArrayList<RSItem>();
for(final RSItem item : inventory.getItems()) {
if(item.getID() != -1)
possible.add(item);
}
if(!possible.isEmpty())
possible.get(random(0, possible.size())).getComponent().doHover();
} else { // Random mouse movement, longer
//log("Random hovering...");
mouse.moveRandomly(200);
}
}
},
// Examining
new AntibanAction(5000, 120000) {
protected void doAction() {
cameraAntiBan.setMode(CameraAntiBan.OFF);
switch(random(0, 2)) {
case 0: // Examine/hover objects
//log("Hovering/Examining objects.");
final RSObject obj = pickRandomObject(10);
if(obj != null) {
if(random(0, 3) == 0) {
obj.doAction("Examine");
} else {
mouse.move(calc.tileToScreen(obj.getLocation()));
}
}
break;
case 1: // Hover NPCs/Players
//log("Hovering NPCs/Players.");
final RSCharacter character = pickRandomCharacter();
if(character != null) {
try {
mouse.move(character.getScreenLocation());
} catch (final NullPointerException ignored) {
}
}
break;
}
cameraAntiBan.setMode(CameraAntiBan.RANDOMROTATING);
}

private RSObject pickRandomObject(final int range) {
final List<RSObject> objects = new ArrayList<RSObject>();

final RSTile l = getMyPlayer().getLocation();

for(int x = l.getX() - range; x <= l.getX() + range; x++) {
for(int y = l.getY() - range; y <= l.getY() + range; y++) {
final RSObject curObj = ParaFishNCook.this.objects.getTopAt(new RSTile(x, y));
if(curObj != null && curObj.getType() == RSObject.Type.INTERACTABLE &&
curObj.isOnScreen()) {
objects.add(curObj);
}
}
}

return objects.isEmpty() ? null : objects.get(random(0, objects.size()));
}

private RSCharacter pickRandomCharacter() {
final RSNPC[] npcs = ParaFishNCook.this.npcs.getAll();
final RSPlayer[] players = ParaFishNCook.this.players.getAll();
return npcs.length != 0 && random(0, 2) == 0 ?
npcs[random(0, npcs.length)] :
(players.length == 0 ? null : players[random(0, players.length)]);
}
},
// Stat hovering
new AntibanAction(2500, 180000) {
private final Map<Integer, Integer> statIfaceMap = new HashMap<Integer, Integer>(4);
{
statIfaceMap.put(Skills.FISHING, 38);
statIfaceMap.put(Skills.COOKING, 62);
statIfaceMap.put(Skills.FIREMAKING, 85);
statIfaceMap.put(Skills.WOODCUTTING, 102);
}

private final int[] primaryStats = {Skills.FISHING, Skills.COOKING},
defaultSecondaryStats = {Skills.FIREMAKING, Skills.WOODCUTTING};

protected void doAction() {
//log("Hovering stat(s).");
final List<Integer> statIDs = new LinkedList<Integer>();
for(final int stat : primaryStats) {
if(!cook || random(0, 2) == 0) {
statIDs.add(stat);
}
if(!cook) break;
}
if(check2ndSkills) {
final LevelRequirement[] reqs = curStyle.getLevelRequirements();
if(!cook && reqs.length > 1) {
for(int i = 1; i < reqs.length; i++) {
statIDs.add(reqs[i].getSkillID());
}
} else {
for(final int s : defaultSecondaryStats) {
if(random(0, 3) == 0) {
statIDs.add(s);
}
}
}
}
Collections.shuffle(statIDs);
while(!statIDs.isEmpty()) {
hoverSkill(statIDs.remove(0));
sleep(random(500, 2500));
}
}

private void hoverSkill(final int skillID) {
if(!statIfaceMap.containsKey(skillID)) return;
if(game.getCurrentTab() != Game.TAB_STATS) {
game.openTab(Game.TAB_STATS);
sleep(random(250, 750));
}
interfaces.getComponent(320, statIfaceMap.get(skillID)).doHover();
}
},
// Prayer hovering
new AntibanAction(60000, 1800000) {
private final int[] prayerLevels = {1, 4, 7, 8, 9, 10, 13, 16, 19, 22, 25, 26,
27, 28, 31, 34, 35, 37, 40, 43, 44, 45, 46, 49, 52, 60, 70};
protected void doAction() {
//log("Hovering prayer(s).");
if(game.getCurrentTab() != Game.TAB_PRAYER){
game.openTab(Game.TAB_PRAYER);
sleep(random(250, 750));
}
final List<RSComponent> prayers = new LinkedList<RSComponent>();
final RSComponent[] prayerComponents = prayerIface.getComponents();
final int prayLvl = skills.getRealLevel(Skills.PRAYER);
final int count = random(1, 6);
for(int i = 0; i < Math.min(prayerComponents.length, prayerLevels.length) &&
prayers.size() < count; i++) {
if(random(0, prayLvl <= prayerLevels[i] ? 7 : 15) == 0) {
prayers.add(prayerComponents[i]);
}
}
Collections.shuffle(prayers);
while(!prayers.isEmpty()) {
prayers.remove(0).doHover();
sleep(random(500, 2500));
}
}
},
// Spell hovering
new AntibanAction(60000, 1800000) {
public void doAction() {
//log("Hovering spell(s).");
if(game.getCurrentTab() != Game.TAB_MAGIC) {
game.openTab(Game.TAB_MAGIC);
sleep(random(250, 750));
}
final List<Integer> spells = new LinkedList<Integer>();
final int count = random(1, 6);
for(int i = 24; i < 92 && spells.size() < count; i++) {
if(random(0, 10) == 0 &&
magicIface.getComponent(i).getArea().
contains(magicIface.getComponent(i).getArea())) {
spells.add(i);
}
}
Collections.shuffle(spells);
while(!spells.isEmpty()) {
magicIface.getComponent(spells.remove(0)).doHover();
sleep(random(500, 2500));
}
}
},
// Scrollbar scrolling
new AntibanAction(60000, 1800000) {
protected void doAction() {
//log("Scrolling scrollbar.");
final int curIndex = random(0, scrollBarMap.size());
int i = 0;
for(final Map.Entry<Integer, RSComponent> entry : scrollBarMap.entrySet()) {
if(i++ != curIndex)
continue;
if(entry.getKey() != -1)
game.openTab(entry.getKey());
scrollScrollbar(entry.getValue(), random(0.0, 1.0));
if(random(0, 4) != 0) {
sleep(random(750, 2500));
scrollScrollbar(entry.getValue(),
(entry.getKey() == -1 ? 0.95 : 0.0) + random(0.0, 0.5));
}
break;
}
}

private void scrollScrollbar(final RSComponent scrollbar, final double yFactor) {
final RSComponent upButton = scrollbar.getComponent(4),
downButton = scrollbar.getComponent(5);
/*if(random(0, 3) == 0) {
final RSComponent curButton = random(0, 2) == 0 ? upButton : downButton;
for(int i = 0; i < random(1, 6); i++) {
curButton.doClick();
sleep(50, 250);
}
} else {*/
final RSComponent comp = scrollbar.getComponent(1);
if(comp == null || !comp.doHover()) return;
sleep(25, 150);
mouse.setSpeed((int)(mouseSpeed * random(3.0, 4.0)));
mouse.drag(comp.getAbsoluteX() + random(0, comp.getWidth()),
upButton.getAbsoluteY() + upButton.getHeight() +
(int)((downButton.getAbsoluteY() - upButton.getAbsoluteY()) * yFactor));
mouse.setSpeed(mouseSpeed);
//}
}
},
// AFKing
new AntibanAction(30000, 600000) {
protected void doAction() {
//log("AFKing");
final int oldCamMode = cameraAntiBan.getMode();
cameraAntiBan.setMode(CameraAntiBan.OFF);
sleep(750, 4000);
cameraAntiBan.setMode(oldCamMode);
}
},
// Music changing (WiP)
/*new AntibanAction(600000, 2400000) {
private static final Comparator<RSComponent> COMPONENT_NAME_COMPARATOR =
new Comparator<RSComponent>() {
public int compare(final RSComponent comp1, final RSComponent comp2) {
return processText(comp1.getText()).compareTo(processText(comp2.getText()));
}
private String processText(final String txt) {
return (txt.startsWith("The ") ? txt.substring(4) : txt);
}
};
private static final int MUSIC_COMPONENT_HEIGHT = 11,
MUSIC_COMPONENT_SPACING = 4;
private void doAction() {
log("Changing music...");
game.openTab(Game.TAB_MUSIC);
final RSComponent comp1 = musicPlayerIface.getComponent(1).getComponent(1702),
comp2 = musicPlayerIface.getComponent(1).getComponent(1704);
log("Area1: " + comp1.getArea() + ", " +
"Area2: " + comp2.getArea() + ", " +
"Spacing: " + (comp2.getAbsoluteY() - comp1.getAbsoluteY() + comp1.getHeight()));
final List<RSComponent> components = getMusicComponents();
final List<RSComponent> possible = new ArrayList<RSComponent>();
final List<Integer> possibleIndexes = new ArrayList<Integer>();
final RSComponent currentSongComp = musicPlayerIface.getComponent(4);
int index = 0;
for(final RSComponent comp : components) {
final String[] actions = comp.getActions();
if(actions != null && actions.length > 0 && actions[0] != null &&
!comp.getText().equals(currentSongComp.getText())) {
possible.add(comp);
possibleIndexes.add(index);
}
index++;
}
if(!possible.isEmpty()) {
final int totalHeight = (MUSIC_COMPONENT_HEIGHT + MUSIC_COMPONENT_SPACING) *
(components.size() - 1) + MUSIC_COMPONENT_HEIGHT;
final int rInt = random(0, possible.size());
final double percent = (double)possibleIndexes.get(rInt) / components.size();
final RSComponent comp = possible.get(rInt);
log("Song: " + comp.getText() + ", Percent: " + percent);
scrollScrollbar(musicPlayerIface.getComponent(2), percent);
mouse.click(comp.getAbsoluteX() + random(0, comp.getText().length() * 4),
resolveY(comp, musicPlayerIface.getComponent(2), totalHeight) +
random(0, comp.getHeight()), true);
log("RelY: " + resolveY(comp, musicPlayerIface.getComponent(2), totalHeight));
sleep(5000);
}
nextMusicTime = System.currentTimeMillis() + random(600000, 2400000);
}
}
private int resolveY(final RSComponent comp, final RSComponent scrollbar,
final int totalHeight) {
final RSComponent upButton = scrollbar.getComponent(4),
downButton = scrollbar.getComponent(5);
return (int)(totalHeight *
((double)(scrollbar.getComponent(1).getAbsoluteY() - upButton.getAbsoluteY()) /
(downButton.getAbsoluteY() - upButton.getAbsoluteY())) - comp.getAbsoluteY());
}
private List<RSComponent> getMusicComponents() {
if(!musicPlayerIface.isValid())
return Collections.emptyList();
final List<RSComponent> comps = new ArrayList<RSComponent>();
final RSComponent[] allComps = musicPlayerIface.getComponent(1).getComponents();
for(int i = 0; i < allComps.length / 2; i++) {
final RSComponent comp = allComps[i * 2];
if(comp != null && comp.getText() != null && !comp.getText().isEmpty())
comps.add(comp);
}
Collections.sort(comps, COMPONENT_NAME_COMPARATOR);
return comps;
} */
};
private int minimumRunPercent = random(15, 61);
private final Map<Integer, RSComponent> scrollBarMap = new HashMap<Integer, RSComponent>();
private RSComponent[] commonHoverComponents;

private FontMetrics fontMetrics;

private int trips;
private long startTime = System.currentTimeMillis();
private int selPaintTab = -1, defaultPaintTab = -1;
private boolean isGUIButtonHovered = false;

private final PaintTab TAB_INFO = new PaintTab(Color.WHITE, false) {
private String getStatus() {
switch(status) {
case FISHING: return "Fishing";
case CHOPPING: return "Chopping";
case FIRING: return "Firing";
case COOKING: return "Cooking";
case DROPPING: return "Dropping";
default: return "";
}
}

public String[] getTabContents() {
final int time = (int)(System.currentTimeMillis() - startTime);
return new String [] {
"Trips: " + formatAmount(trips) +
" (" + formatAmount(3600000.0 / time * trips) + " trips/h)",
"Trees found: " + (cook ? trees.size() : "--"),
"Levels gained: " + getTotalLevelGain(curStyle.getPaintTabs()),
"Status: " + getStatus(),
"Time running: " + formatTime(time)
};
}
},
TAB_FISHING = new PaintTab(Color.BLUE, false, Skills.FISHING, "Fishing",
"Fished: %s (%s fish/h)") {
public boolean checkGains(final String msg) {
if(!msg.startsWith("You catch")) return false;
for(final Fish f : curStyle.getCatches()) {
if(msg.contains(f.toString().toLowerCase())) {
this.addAmount();
this.addXPGain(f.getFishingXPGain());
f.updateXPGains();
return true;
}
}
return false;
}
},
TAB_WOODCUTTING = new PaintTab(Color.GREEN, true, Skills.WOODCUTTING, "Woodcutting",
"Chopped: %s (%s log(s)/h)") {
public boolean checkGains(final String msg) {
if(!msg.startsWith("You get some")) return false;
for(final Log log : Log.values()) {
if(msg.contains(log.toString().toLowerCase())) {
this.addAmount();
this.addXPGain(log.getWcXPGain());
return true;
}
}
return false;
}
},
TAB_FIREMAKING = new PaintTab(Color.RED, true, Skills.FIREMAKING, "Firemaking",
"Burnt: %s (%s fires/h)"),
TAB_COOKING = new PaintTab(Color.ORANGE, true, Skills.COOKING, "Cooking",
"Cooked: %s (%s cooks/h)") {
public boolean checkGains(final String msg) {
if(!msg.startsWith("You successfully cook") &&
msg.startsWith("You manage to cook") &&
msg.startsWith("You roast")) return false;
for(final Fish f : curStyle.getCatches()) {
if(msg.contains(f.toString().toLowerCase())) {
this.addAmount();
this.addXPGain(f.getCookingXPGain());
return true;
}
}
return false;
}
};
private final PaintTab[] DEFAULT_TABS = {
TAB_INFO, TAB_FISHING, TAB_WOODCUTTING, TAB_FIREMAKING, TAB_COOKING
};

private int hoverInvCount = -1;
private boolean checkDropping;

private static final Map<String, Double> antibanFactorMap = new LinkedHashMap<String, Double>();
{
antibanFactorMap.put("Off", -1.0);
antibanFactorMap.put("Very Rare", 4.0);
antibanFactorMap.put("Rare", 2.0);
antibanFactorMap.put("Normal", 1.0);
antibanFactorMap.put("Frequent", 0.5);
antibanFactorMap.put("Very Frequent", 0.25);
}

private FishingStyle curStyle;
private PaintTab curFMTab;
private int curStyleIndex;
private int mouseSpeed = 5;
private boolean cook = true;
private boolean fastPowerFish, drawPaint = true, drawTrees, check2ndSkills = true, customDropping, useMouseKeys;
private double antibanFactor = 1.0;
private final Set<Integer> customDroppingIDs = new LinkedHashSet<Integer>();
private Point guiLocation = new Point(250, 250);
private boolean takeScreenshots, takeScreenshotOnStop, takeScreenshotOnLevelup,
hideUsernameInScreenshot, tookScreenshotOnStop;
private int screenshotInterval = 3600;

private int treeFails, gearFails, tinderBoxFails, lvlFails, spotFindTimeout = random(240000, 360000);
private long lastSpotFoundTime = System.currentTimeMillis(), lastSpotNotifyTime;

private final File settingsFile = new File(GlobalConfiguration.Paths.getSettingsDirectory() +
File.separator + "ParaFishNCook.dat");
private long lastScreenshotTime;

private final CameraAntiBan cameraAntiBan = new CameraAntiBan();
private final Updater updater = new Updater();
private Gui gui;

private final Map<Integer, Long> fishDropMap = new HashMap<Integer, Long>();

private List<Fish> allFish = new ArrayList<Fish>();

private Fish
// Net fishing
shrimps = new Fish("Shrimps", "Burnt shrimp", 317, 315, 7954, 1, 1, 10, 30),
anchovies = new Fish("Anchovies", 321, 319, 323, 15, 15, 40, 30),
// Crayfish fishing
crayfish = new Fish("Crayfish", "Burnt crayfish", 13435, 13433, 13437, 1, 1, 10, 30),
// Sea Bait fishing
sardine = new Fish("Sardine", 327, 325, 369, 5, 1, 20, 40),
herring = new Fish("Herring", 345, 347, 357, 10, 5, 30, 50),
// River Bait fishing
pike = new Fish("Pike", 349, 351, 343, 25, 20, 60, 80),
// Fly fishing
trout = new Fish("Trout", 335, 333, 343, 20, 15, 50, 70),
salmon = new Fish("Salmon", 331, 329, 343, 30, 25, 70, 90),
// Harpoon fishing
tuna = new Fish("Tuna", 359, 361, 367, 35, 30, 80, 100),
swordfish = new Fish("Swordfish", "Burnt swordfish", 371, 373, 375, 50, 45, 100, 140),
// Lobster cage fishing
lobster = new Fish("Lobster", "Burnt lobster", 377, 379, 381, 40, 40, 90, 120),
// Heavy rod fishing
leapingTrout = new Fish("Leaping trout", 11328, 48, 50, new XPGain(Skills.AGILITY, 5),
new XPGain(Skills.STRENGTH, 5)),
leapingSalmon = new Fish("Leaping salmon", 11330, 58, 70, new XPGain(Skills.AGILITY, 6),
new XPGain(Skills.STRENGTH, 6)),
leapingSturgeon = new Fish("Leaping sturgeon", 11332, 70, 80, new XPGain(Skills.AGILITY, 7),
new XPGain(Skills.STRENGTH, 7));

private void init() {
magicIface = interfaces.get(Game.TAB_MAGIC);
chatboxIface = interfaces.get(137);
//musicPlayerIface = interfaces.get(187);
cookingIface = interfaces.getComponent(905, 14);
amountDisplay = interfaces.getComponent(916, 17);
amountIncreaseButton = interfaces.getComponent(916, 19);
levelUpIface = interfaces.getComponent(740, 3);
prayerIface = interfaces.getComponent(271, 8);
gameScreenIface = interfaces.getComponent(548, 3);

//chatScrollbar = interfaces.getComponent(137, 59);
scrollBarMap.put(-1, interfaces.getComponent(137, 59));
scrollBarMap.put(Game.TAB_QUESTS, interfaces.getComponent(190, 17));
scrollBarMap.put(Game.TAB_ACHIEVEMENTS, interfaces.getComponent(259, 9));
scrollBarMap.put(Game.TAB_CONTROLS, interfaces.getComponent(464, 0));

commonHoverComponents = new RSComponent[] {
interfaces.getComponent(548, 0),
interfaces.getComponent(548, 175),
interfaces.getComponent(548, 178),
interfaces.getComponent(748, 0),
interfaces.getComponent(749, 0),
interfaces.getComponent(750, 0),
};
}

private interface Checkable {
boolean check();
}

private final class LevelRequirement implements Checkable {
private final int skillID, levelRequired;
private final String skillName;

public LevelRequirement(final int skillID, final int levelRequired) {
this.skillID = skillID;
this.levelRequired = levelRequired;

this.skillName = capitalize(Skills.SKILL_NAMES[skillID]);
}

public String getSkillName() {
return skillName;
}

public int getSkillID() {
return this.skillID;
}

public int getLevel() {
return this.levelRequired;
}

public boolean check() {
return skills.getCurrentLevel(skillID) >= levelRequired;
}
}

/**
* Defines a one-of/any item requirement.
*
* author Parameter
*/
private final class OneItemRequirement implements Checkable {
private final int[] itemIDs;

public OneItemRequirement(final int... itemIDs) {
this.itemIDs = itemIDs;
}

public boolean check() {
return inventory.containsOneOf(itemIDs);
}
}

/**
* Defines all items requirement.
*
* author Parameter
*/
private final class AllItemsRequirement implements Checkable {
private final int[] itemIDs;

public AllItemsRequirement(final int... itemIDs) {
this.itemIDs = itemIDs;
}

public boolean check() {
return inventory.containsAll(itemIDs);
}
}

private static final class XPGain {
private final int statID;
private final double xpGain;

public XPGain(final int statID, final double xpGain) {
this.statID = statID;
this.xpGain = xpGain;
}

public int getSkillID() {
return this.statID;
}

public double getXPGain() {
return this.xpGain;
}
}

private class PaintTab {
private final Color buttonColor, progbarColor;
private final boolean isCookingOnly;
private final int skillID;
private final String infoFormat, skillName;
private int amount, lvlsGained;
private double xpGained;

/**
* Constructs a new PaintTab object.
*
* param color The color used to draw paint button's content and skill bar.
* param skillID The skill's ID (like Skill.FISHING)
* param skillName The skill's name (like "Fishing")
* param infoFormat The format string used for first line of the tab.
* (like "Fish cooked: %s (%s fish/h)")
*/
public PaintTab(final Color color, final boolean isCookingOnly, final int skillID,
final String skillName, final String infoFormat) {
this.buttonColor = color;
this.isCookingOnly = isCookingOnly;
this.progbarColor = new Color(0x96000000 + color.getRGB(), true);
this.skillID = skillID;
this.skillName = skillName;
this.infoFormat = infoFormat;
}

public PaintTab(final Color color, final boolean isCookingOnly,
final int skillID, final String skillName) {
this(color, isCookingOnly, skillID, skillName, null);
}

public PaintTab(final Color color, final boolean isCookingOnly) {
this(color, isCookingOnly, -1, null);
}

public Color getButtonColor() {
return buttonColor;
}

public Color getProgressBarColor() {
return this.progbarColor;
}

public boolean isCookingOnly() {
return this.isCookingOnly;
}

public String getSkillName() {
return this.skillName;
}

public int getSkillID() {
return this.skillID;
}

public void addAmount(final int amount) {
this.amount += amount;
}

public void addAmount() {
addAmount(1);
}

public void addXPGain(final double gain) {
this.xpGained += gain;
}

/**
* Checks the gains (xp, fish and other amounts...)
* using the passed-in ServerMessage string.
*
* param serverMessage The server message.
* return <tt>true</tt> if server message matched related gain message,
* <tt>false</tt> otherwise.
*/
public boolean checkGains(final String serverMessage) {
return false;
}

public String[] getTabContents() {
final int time = (int)(System.currentTimeMillis() - startTime);
final double xpPerMs = xpGained / (double)time;
return new String[] {
/*"Fish cooked: " + formatAmount(fishCooked) +
" (" + formatAmount(3600000.0 / time * fishCooked) + " fish/h)",*/
infoFormat == null ? null :
String.format(infoFormat, formatAmount(amount), formatAmount(3600000.0 / time * amount)),
skillName +" lvl: " + skills.getCurrentLevel(skillID) +
" (gained: " + lvlsGained + ")",
"Level in: " + (xpPerMs != 0 ?
formatTime(skills.getExpToNextLevel(skillID) / xpPerMs) :
"--:--:--"),
"XP gained: " + formatAmount(xpGained) +
" (" + formatAmount(3600000.0 / time * xpGained) + " xp/h)",
"%"
};
}

/**
* Reset the paint variables.
*/
public void reset() {
this.xpGained = this.amount = this.lvlsGained = 0;
}
}

private boolean updateLvlsGained(final String msg, final PaintTab... tabs) {
if(tabs == null) return false;
for(final PaintTab tab : tabs) {
if(tab.getSkillName() != null && msg.contains(tab.getSkillName())) {
tab.lvlsGained++;
return true;
}
}
return false;
}

private int getTotalLevelGain(final PaintTab... tabs) {
int lvlsGained = 0;
for(final PaintTab tab : tabs) {
lvlsGained += tab.lvlsGained;
}
return lvlsGained;
}

private void resetAllTabs(final PaintTab... tabs) {
for(final PaintTab tab : tabs) {
tab.reset();
}
}

private boolean checkAllGains(final String msg, final PaintTab... tabs) {
for(final PaintTab tab : tabs) {
if(tab.checkGains(msg))
return true;
}
return false;
}

private final FishingStyle[] fishingStyles = {
// NET
new FishingStyle("Net Fishing", "Net", 1, new int[] {621}, new int[] {303},
new Fish[] {shrimps, anchovies}, 323, 325, 327, 4908),
// CRAYFISH
new FishingStyle("Crayfish Fishing", "Cage", 1, new int[] {10009}, new int[] {13431},
new Fish[] {crayfish}, 6996, 6267),
// SEA_BAIT
new FishingStyle("Sea Bait Fishing", "Bait", 5, new int[] {622, 623}, new int[] {307, 313},
new Fish[] {sardine, herring}, 323, 327, 4908),
// RIVER_BAIT
new FishingStyle("River Bait Fishing", "Bait", 25, new int[] {622, 623}, new int[] {307, 313},
new Fish[] {pike}, 310, 311, 328, 329),
// LURE
new FishingStyle("Fly Fishing", "Lure", 20, new int[] {622, 623}, new int[] {309, 314},
new Fish[] {trout, salmon}, 310, 311, 328, 329),
// HARPOON
new FishingStyle("Harpoon Fishing", "Harpoon", 35, new int[] {618}, new int[] {311},
new Fish[] {tuna, swordfish}, 321, 324),
// CAGE
new FishingStyle("Lobster Cage Fishing", "Cage", 40, new int[] {619}, new int[] {301},
new Fish[] {lobster}, 321, 324),
// HEAVY_ROD
new FishingStyle("Barbarian Fishing", "Use-rod",
new LevelRequirement[] {
new LevelRequirement(Skills.FISHING, 48),
new LevelRequirement(Skills.AGILITY, 15),
new LevelRequirement(Skills.STRENGTH, 15)
}, new int[] {622, 623}, new Checkable[] {
new AllItemsRequirement(11323),
new OneItemRequirement(313, 314)},
new PaintTab[] {
TAB_INFO, TAB_FISHING,
new PaintTab(Color.GREEN, false, Skills.AGILITY, "Agility"),
new PaintTab(Color.YELLOW, false, Skills.STRENGTH, "Strength")
},
new Fish[] {leapingTrout, leapingSalmon, leapingSturgeon},
2722)
};

private class FishingStyle {

private final String name, action;
private final LevelRequirement[] levelRequirements;
private final PaintTab[] paintTabs;
private final int[] animations, spotIDs;
private final Checkable[] gearRequirements;
private final Fish[] catches;
private final int minFishingLvl, maxFishingLvl;
private final boolean containsAnyCookableFish;

public FishingStyle(final String name, final String action,
final LevelRequirement[] levelRequirements, final int[] animations,
final Checkable[] gearRequirements, final PaintTab[] paintTabs,
final Fish[] catches, final int... spotIDs) {
this.name = name;
this.action = action;
this.levelRequirements = levelRequirements;
this.animations = animations;
this.gearRequirements = gearRequirements;
this.paintTabs = paintTabs;
this.catches = catches;
this.spotIDs = spotIDs;
this.minFishingLvl = calculateMinFishingLvl(catches);
this.maxFishingLvl = calculateMaxFishingLvl(catches);

boolean cookable = false;
for(final Fish f : catches) {
if(f.isCookable()) {
cookable = true;
break;
}
}

this.containsAnyCookableFish = cookable;
}

public FishingStyle(final String name, final String action,
final LevelRequirement[] levelRequirements, final int[] animations,
final Checkable[] gearRequirements, final Fish[] catches, final int... spotIDs) {
this(name, action, levelRequirements, animations, gearRequirements,
DEFAULT_TABS, catches, spotIDs);
}

public FishingStyle(final String name, final String action,
final LevelRequirement[] levelRequirements, final int[] animations,
final int[] gearIDs, final Fish[] catches, final int... spotIDs) {
this(name, action, levelRequirements, animations,
new Checkable[] {new AllItemsRequirement(gearIDs)}, catches, spotIDs);
}

public FishingStyle(final String name, final String action,
final int fishingLvl, final int[] animations,
final int[] gearIDs, final Fish[] catches, final int... spotIDs) {
this(name, action,
new LevelRequirement[] {
new LevelRequirement(Skills.FISHING, fishingLvl)},
animations, gearIDs, catches, spotIDs);
}

private int calculateMinFishingLvl(final Fish... catches) {
int minLvl = 99;
for(final Fish f : catches) {
if(f.getFishingLvl() < minLvl) {
minLvl = f.getFishingLvl();
}
}
return minLvl;
}

private int calculateMaxFishingLvl(final Fish... catches) {
int maxLvl = 1;
for(final Fish f : catches) {
if(f.getFishingLvl() > maxLvl) {
maxLvl = f.getFishingLvl();
}
}
return maxLvl;
}

public String getName() {
return this.name;
}

public LevelRequirement[] getLevelRequirements() {
return this.levelRequirements;
}

public PaintTab[] getPaintTabs() {
return this.paintTabs;
}

public int[] getAnimations() {
return this.animations;
}

public boolean checkGear() {
for(final Checkable req : gearRequirements) {
if(!req.check()) return false;
}
return true;
}

public Fish[] getCatches() {
return this.catches;
}

public int[] getCatchIDs() {
final int[] ids = new int[catches.length * 3];
for(int i = 0; i < catches.length; i++) {
ids[i * 3] = catches[i].getID();
ids[i * 3 + 1] = catches[i].getCookedID();
ids[i * 3 + 2] = catches[i].getBurntID();
}
return ids;
}

public int[] getSpotIDs() {
return this.spotIDs;
}

public int getMinFishingLvl() {
return this.minFishingLvl;
}

public int getMaxFishingLvl() {
return this.maxFishingLvl;
}

public boolean containsAnyCookableFish() {
return this.containsAnyCookableFish;
}

public String toString() {
return this.action;
}
}

private class Fish {
private final String name;
private final int id, cookedId, burntId, fishingLvl, cookingLvl;
private final double fishingXPGain, cookingXPGain;
private final boolean cookable;
private final XPGain[] xpGains;

public Fish(final String name, final String burntName,
final int id, final int cookedId, final int burntId,
final int fishingLvl, final int cookingLvl,
final double fishingXPGain, final double cookingXPGain) {
this.name = name;
this.id = id;
this.cookedId = cookedId;
this.burntId = burntId;
this.fishingLvl = fishingLvl;
this.cookingLvl = cookingLvl;
this.fishingXPGain = fishingXPGain;
this.cookingXPGain = cookingXPGain;
this.cookable = true;
this.xpGains = null;

allFish.add(this);
}

public Fish(final String name, final int id, final int cookedId,
final int burntId, final int fishingLvl, final int cookingLvl,
final double fishingXPGain, final double cookingXPGain) {
this(name, "Burnt fish", id, cookedId, burntId,
fishingLvl, cookingLvl, fishingXPGain, cookingXPGain);
}

public Fish(final String name, final int id, final int fishingLvl, final int fishingXPGain,
final XPGain... xpGains) {
this.name = name;
this.id = id;
this.cookedId = 0;
this.burntId = 0;
this.fishingLvl = fishingLvl;
this.cookingLvl = 0;
this.fishingXPGain = fishingXPGain;
this.cookingXPGain = 0;
this.xpGains = xpGains;
this.cookable = false;

allFish.add(this);
}

public String toString() {
return this.name;
}

public int getID() {
return this.id;
}

public int getCookedID() {
return this.cookedId;
}

public int getBurntID() {
return this.burntId;
}

public double getFishingXPGain() {
return this.fishingXPGain;
}

public double getCookingXPGain() {
return this.cookingXPGain;
}

public int getFishingLvl() {
return this.fishingLvl;
}

public int getCookingLvl() {
return this.cookingLvl;
}

public boolean isCookable() {
return this.cookable;
}

public void updateXPGains() {
if(xpGains == null || curStyle == null) return;
for(final XPGain xpGain : xpGains) {
for(final PaintTab tab : curStyle.getPaintTabs()) {
if(xpGain.getSkillID() == tab.getSkillID()) {
tab.addXPGain(xpGain.getXPGain());
break;
}
}
}
}
}

private Fish getCookableInvFish() {
final int lvl = skills.getCurrentLevel(Skills.COOKING);

for(final Fish f : allFish){
if(f.cookingLvl <= lvl && inventory.contains(f.id)) {
return f;
}
}

return null;
}

private int getJunkInvFishID() {
for(final Fish f : allFish) {
if(inventory.contains(f.burntId)) {
return f.burntId;
}
}
for(final Fish f : allFish) {
if(inventory.contains(f.cookedId)) {
return f.cookedId;
}
}
for(final Fish f : allFish) {
if(inventory.contains(f.id)) {
return f.id;
}
}
return -1;
}

private final class Tree {
private final RSTile location;
private final TreeType type;

private Tree(final RSTile location, final TreeType type) {
this.location = location;
this.type = type;
}

public RSTile getLocation() {
return this.location;
}

public TreeType getType() {
return this.type;
}

public boolean isAvailable() {
final RSObject obj = objects.getTopAt(this.location, Objects.TYPE_INTERACTABLE);
return obj != null && arrayContains(obj.getID(), type.availableIDs);
}

public int hashCode() {
return location.hashCode();
}

public boolean equals(final Object obj) {
if(this == obj) {
return true;
}
if(!(obj instanceof Tree)) {
return false;
}
final Tree t = (Tree)obj;
return t.location.equals(this.location);
}
}

private Set<Tree> scanForTrees() {
final Set<Tree> trees = new HashSet<Tree>();

try {
final int baseX = game.getBaseX(), baseY = game.getBaseY();

for(int x = 0; x < 104; x++) {
for(int y = 0; y < 104; y++) {
final RSTile curTile = new RSTile(x + baseX, y + baseY);
if(containsTreeTile(trees, curTile)) {
continue;
}

final RSObject obj = objects.getTopAt(curTile, Objects.TYPE_INTERACTABLE);
if(obj == null) continue;
final TreeType type = TreeType.idToType(obj.getID());
if(type != null) {
trees.add(new Tree(curTile, type));
}
}
}
} catch (final Exception e) {
}

return trees;
}

private boolean containsTreeTile(final Collection<Tree> trees, final RSTile tile) {
for(final Tree tree : trees) {
final RSTile t = tree.getLocation();
final int edgeSize = tree.getType().getEdgeSize();
for(int x = t.getX(); x < t.getX() + edgeSize; x++) {
for(int y = t.getY(); y < t.getY() + edgeSize; y++) {
if(tile.getX() == x && tile.getY() == y) {
return true;
}
}
}
}

return false;
}

private Tree getNearestUsableTree(final Set<Tree> trees, final Set<Tree> treesToAvoid) {
final int wcLevel = skills.getCurrentLevel(Skills.WOODCUTTING);
final int fmLevel = skills.getCurrentLevel(Skills.FIREMAKING);
int lastDistance = 999;
Tree lastTree = null;

for(final Tree tree : trees) {
if(treesToAvoid.contains(tree) && calc.tileOnScreen(tree.getLocation()) &&
tree.isAvailable()) {
treesToAvoid.remove(tree);
}
if(!treesToAvoid.contains(tree) &&
tree.getType().getWcLevel() <= wcLevel &&
tree.getType().getLog().getFmLevel() <= fmLevel) {
final int dist = calc.distanceTo(tree.getLocation());
if(lastTree == null || dist < lastDistance) {
lastTree = tree;
lastDistance = dist;
}
}
}

return lastTree;
}

private static enum TreeType {
TREE ("Tree", 1, Log.NORMAL, new int[] {1276, 1278},
new int[] {1342}, 2),
SMALL_DEADTREE ("Dead tree", 1, Log.NORMAL, new int[] {1286},
new int[] {1351}, 1),
BIG_DEADTREE ("Dead tree", 1, Log.NORMAL, new int[] {1282},
new int[] {1347}, 2),
SMALL_EVERGREEN ("Evergreen", 1, Log.NORMAL, new int[] {1315},
new int[] {1342}, 2),
BIG_EVERGREEN ("Evergreen", 1, Log.NORMAL, new int[] {1316},
new int[] {1355}, 3),
OAK ("Oak", 15, Log.OAK_LOGS, new int[] {1281, 1383},
new int[] {1356, 1358}, 3),
WILLOW ("Willow", 30, Log.WILLOW_LOGS, new int[] {5551, 5552, 5553},
new int[] {5554}, 2),
MAPLE ("Maple", 45, Log.MAPLE_LOGS, new int[] {1307},
new int[] {7400}, 2);

private final String name;
private final int wcLevel, edgeSize;
private final Log log;
private final int[] availableIDs, unavailableIDs;

private TreeType(final String name, final int wcLevel, final Log log,
final int[] availableIDs, final int[] unavailableIDs,
final int edgeSize) {
this.name = name;
this.wcLevel = wcLevel;
this.log = log;
this.availableIDs = availableIDs;
this.unavailableIDs = unavailableIDs;
this.edgeSize = edgeSize;
}

public int getWcLevel() {
return this.wcLevel;
}

public Log getLog() {
return this.log;
}

public String toString() {
return this.name;
}

public int getEdgeSize() {
return this.edgeSize;
}

public boolean idMatches(final int id) {
return id != -1 &&
(arrayContains(id, availableIDs) || arrayContains(id, unavailableIDs));
}

public static TreeType idToType(final int id) {
if(id == -1) {
return null;
}
for(final TreeType type : values()) {
if(type.idMatches(id)) {
return type;
}
}
return null;
}
}

private static enum Log {
OAK_LOGS ("Oak logs", 1521, 15, 37.5, 60),
NORMAL ("Logs", 1511, 1, 25, 40),
WILLOW_LOGS ("Willow logs", 1519, 30, 67.5, 90),
MAPLE_LOGS ("Maple logs", 1517, 45, 100, 135);

private final String name;
private final int id, firemakingLvl;
private final double wcXPGain, fmXPGain;

private Log(final String name, final int id, final int firemakingLvl,
final double wcXPGain, final double fmXPGain) {
this.name = name;
this.id = id;
this.firemakingLvl = firemakingLvl;
this.wcXPGain = wcXPGain;
this.fmXPGain = fmXPGain;
}

public int getID() {
return this.id;
}

public int getFmLevel() {
return this.firemakingLvl;
}

public double getWcXPGain() {
return this.wcXPGain;
}

public double getFmXPGain() {
return this.fmXPGain;
}

public String toString() {
return this.name;
}
}

private Log getUsableInvLog() {
final int fmLevel = skills.getCurrentLevel(Skills.FIREMAKING);
for(final Log log : Log.values()) {
if(log.firemakingLvl <= fmLevel &&
inventory.contains(log.getID())) {
return log;
}
}
return null;
}

private class CameraAntiBan implements Runnable {
public static final int OFF = 0, WALKROTATING = 1, RANDOMROTATING = 2;

private final Thread thread = new Thread(this);

private int mode = OFF;
private boolean exit = false;

public void run() {
while(!Thread.interrupted() || !exit) {
if(isPaused() || !run || antibanFactor == -1) {
try {
Thread.sleep(500);
} catch (final InterruptedException e) {
if(exit) return;
}
continue;
}
switch(mode) {
case OFF:
try {
while(mode == OFF) {
synchronized(this) {
wait();
}
}
} catch (final InterruptedException e) {
if(exit) return;
}
break;
case WALKROTATING:
try {
Thread.sleep(frandom(500, 7500));
} catch (final InterruptedException e) {
if(exit) return;
continue;
}
final RSTile d = walking.getDestination();
if(d != null && random(0, 3) != 0) {
try {
setCameraRotation(camera.getTileAngle(d) + random(-50, 51));
} catch (final InterruptedException e) {
if(exit) return;
}
break;
}
case RANDOMROTATING:
if(mode == RANDOMROTATING) {
try {
Thread.sleep(frandom(500, 7500));
} catch (final InterruptedException e) {
if(exit) return;
continue;
}
}
final char key = (char)(random(0, 3) == 0 ?
(random(0, 3) == 0 ? KeyEvent.VK_DOWN : KeyEvent.VK_UP) :
(random(0, 2) == 0 ? KeyEvent.VK_LEFT : KeyEvent.VK_RIGHT));
keyboard.pressKey(key);
try {
Thread.sleep(frandom(50, 1250));
} catch (final InterruptedException e) {
if(exit) return;
continue;
} finally {
keyboard.releaseKey(key);
}
break;
}
}
}

public void start() {
thread.start();
}

public void stop() {
this.exit = true;
thread.interrupt();
try {
thread.join();
} catch (final InterruptedException ignored) {
}
}

public int getMode() {
return mode;
}

public void setMode(final int mode) {
if(this.mode == mode || mode < OFF || mode > RANDOMROTATING) return;
final int oldMode = this.mode;
this.mode = mode;
if(oldMode == OFF) {
synchronized(this) {
this.notifyAll();
}
} else {
thread.interrupt();
}
}

private void setCameraRotation(int degrees) throws InterruptedException {
final char left = 37;
final char right = 39;
char whichDir = left;
int start = camera.getAngle();
/*
* Some of this shit could be simplified, but it's easier to wrap my
* mind around it this way
*/
if (start < 180) {
start += 360;
}
if (degrees < 180) {
degrees += 360;
}
if (degrees > start) {
if (degrees - 180 < start) {
whichDir = right;
}
} else if (start > degrees) {
if (start - 180 >= degrees) {
whichDir = right;
}
}
degrees %= 360;
keyboard.pressKey(whichDir);
int timeWaited = 0;
try {
while (camera.getAngle() > degrees + 5 || camera.getAngle() < degrees - 5) {
Thread.sleep(10);
timeWaited += 10;
if (timeWaited > 500) {
int time = timeWaited - 500;
if (time == 0) {
keyboard.pressKey(whichDir);
} else if (time % 40 == 0) {
keyboard.pressKey(whichDir);
}
}
}
} finally {
keyboard.releaseKey(whichDir);
}
}
}

private abstract class AntibanAction {
private final int minInterval, maxInterval;
private long nextTime;

public AntibanAction(final int minInterval, final int maxInterval) {
this.minInterval = minInterval;
this.maxInterval = maxInterval;

updateNextTime();
}

public void updateNextTime() {
this.nextTime = antibanFactor == -1 ? 0 :
System.currentTimeMillis() + frandom(minInterval, maxInterval);
}

protected abstract void doAction();

public boolean perform() {
if(System.currentTimeMillis() >= nextTime) {
doAction();
updateNextTime();
return true;
}
return false;
}
}

private class Gui extends JFrame implements ActionListener, ListCellRenderer {
private static final long serialVersionUID = -6133534749232966475L;

private final JComboBox styleComboBox = new JComboBox(fishingStyles),
antibanComboBox = new JComboBox(antibanFactorMap.keySet().toArray());
private final JCheckBox cookCheckBox = new JCheckBox("Cook the fish"),
fastPowerFishCheckBox = new JCheckBox("Fast powerfishing (fish 2, drop 2)"),
drawPaintCheckBox = new JCheckBox("Draw paint"),
drawTreesCheckBox = new JCheckBox("Draw rectangles over detected trees."),
check2ndSkillsCheckBox = new JCheckBox("Check secondary skills (e.g fm & wc)"),
mouseKeysCheckBox = new JCheckBox("Mousekeys (faster dropping)(legit!)"),
takeScreenshotsCheckBox = new JCheckBox("Take screenshots every (HH:MM:SS):"),
takeScreenshotOnStopCheckBox = new JCheckBox("Take screenshot on stop."),
takeScreenshotOnLevelupCheckBox = new JCheckBox("Take screenshot on levelup."),
hideUsernameCheckBox = new JCheckBox("Hide username in screenshot.");
private final JSpinner mouseSpeedSpinner = new JSpinner();
private final JButton stateButton = new JButton("Start"),
applyButton = new JButton("Apply"),
updateButton = new JButton("Update");
private final JTextField screenshotIntervalField = new JTextField();

private final DropDialog dropDialog = new DropDialog();

public Gui() {
super("ParaFishNCook");
setResizable(false);
setLocation(guiLocation);
}

private void initComponents() {
styleComboBox.setActionCommand("checkcooking");
styleComboBox.addActionListener(this);
styleComboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
styleComboBox.setRenderer(this);
styleComboBox.setSelectedIndex(curStyleIndex);
styleComboBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 40));

int i = 0;
for(final double factor : antibanFactorMap.values()) {
if(antibanFactor == factor) {
antibanComboBox.setSelectedIndex(i);
break;
}
i++;
}

if(!fishingStyles[curStyleIndex].
containsAnyCookableFish()) {
cookCheckBox.setEnabled(false);
cookCheckBox.setSelected(false);
}

cookCheckBox.setMnemonic(KeyEvent.VK_C);
cookCheckBox.setSelected(cook);
cookCheckBox.setActionCommand("checkfastpowerfish");
cookCheckBox.addActionListener(this);

fastPowerFishCheckBox.setMnemonic(KeyEvent.VK_W);
fastPowerFishCheckBox.setSelected(fastPowerFish);
fastPowerFishCheckBox.setEnabled(!cook);

drawPaintCheckBox.setMnemonic(KeyEvent.VK_P);
drawPaintCheckBox.setSelected(drawPaint);

drawTreesCheckBox.setMnemonic(KeyEvent.VK_T);
drawTreesCheckBox.setSelected(drawTrees);

check2ndSkillsCheckBox.setMnemonic(KeyEvent.VK_H);
check2ndSkillsCheckBox.setSelected(check2ndSkills);

mouseKeysCheckBox.setMnemonic(KeyEvent.VK_K);
mouseKeysCheckBox.setSelected(useMouseKeys);

takeScreenshotsCheckBox.setMnemonic(KeyEvent.VK_E);
takeScreenshotsCheckBox.setSelected(takeScreenshots);

takeScreenshotOnStopCheckBox.setMnemonic(KeyEvent.VK_N);
takeScreenshotOnStopCheckBox.setSelected(takeScreenshotOnStop);

takeScreenshotOnLevelupCheckBox.setMnemonic(KeyEvent.VK_L);
takeScreenshotOnLevelupCheckBox.setSelected(takeScreenshotOnLevelup);

hideUsernameCheckBox.setMnemonic(KeyEvent.VK_U);
hideUsernameCheckBox.setSelected(hideUsernameInScreenshot);

mouseSpeedSpinner.setModel(
new SpinnerNumberModel(mouseSpeed, 0, 15, 1));
mouseSpeedSpinner.setMaximumSize(new Dimension(50,
mouseSpeedSpinner.getPreferredSize().height));
mouseSpeedSpinner.setAlignmentX(Component.LEFT_ALIGNMENT);

screenshotIntervalField.setText(formatTime(screenshotInterval * 1000));
screenshotIntervalField.setAlignmentX(Component.LEFT_ALIGNMENT);
screenshotIntervalField.setMaximumSize(new Dimension(Short.MAX_VALUE, 25));

stateButton.addActionListener(this);
stateButton.setActionCommand("changestate");
stateButton.setMnemonic(KeyEvent.VK_S);
getRootPane().setDefaultButton(stateButton);

applyButton.addActionListener(this);
applyButton.setActionCommand("apply");
applyButton.setMnemonic(KeyEvent.VK_A);
applyButton.setEnabled(false);

updateButton.addActionListener(this);
updateButton.setActionCommand("update");
}

public void init() {
initComponents();
dropDialog.init();

final JPanel pane = new JPanel(new BorderLayout(5, 5));
final JTabbedPane tabPane = new JTabbedPane();

final JPanel generalPanel = new JPanel(null);
generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.PAGE_AXIS));
generalPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
final JLabel styleLabel = new JLabel("Choose the style to use:");
styleLabel.setDisplayedMnemonic(KeyEvent.VK_Y);
styleLabel.setLabelFor(styleComboBox);
generalPanel.add(styleLabel);
generalPanel.add(styleComboBox);
generalPanel.add(cookCheckBox);
generalPanel.add(fastPowerFishCheckBox);
generalPanel.add(new JSeparator(JSeparator.HORIZONTAL));
generalPanel.add(mouseKeysCheckBox);
generalPanel.add(check2ndSkillsCheckBox);

final JPanel settingsPanel = new JPanel(null);
settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
settingsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
final JLabel mouseSpeedLabel = new JLabel("Mouse speed (lower the faster):");
mouseSpeedLabel.setDisplayedMnemonic(KeyEvent.VK_M);
mouseSpeedLabel.setLabelFor(mouseSpeedSpinner);
settingsPanel.add(mouseSpeedLabel);
settingsPanel.add(mouseSpeedSpinner);
settingsPanel.add(drawPaintCheckBox);
settingsPanel.add(drawTreesCheckBox);
final JButton customDroppingButton = new JButton("Custom dropping settings...");
customDroppingButton.addActionListener(this);
customDroppingButton.setActionCommand("showcustomdroppingdialog");
customDroppingButton.setMnemonic(KeyEvent.VK_D);
settingsPanel.add(customDroppingButton);
final JPanel antibanPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
antibanPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
antibanPanel.add(new JLabel("Antiban: "));
antibanPanel.add(antibanComboBox);
settingsPanel.add(antibanPanel);

final JPanel screenshotPanel = new JPanel(null);
screenshotPanel.setLayout(new BoxLayout(screenshotPanel, BoxLayout.PAGE_AXIS));
screenshotPanel.add(takeScreenshotsCheckBox);
screenshotPanel.add(screenshotIntervalField);
screenshotPanel.add(takeScreenshotOnStopCheckBox);
screenshotPanel.add(takeScreenshotOnLevelupCheckBox);
screenshotPanel.add(hideUsernameCheckBox);

tabPane.addTab("General", generalPanel);
tabPane.addTab("Settings", settingsPanel);
tabPane.addTab("Screenshot", screenshotPanel);

final JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
buttonPanel.add(new JLabel("v" + VERSION));
buttonPanel.add(Box.createHorizontalGlue());
buttonPanel.add(stateButton);
buttonPanel.add(applyButton);
buttonPanel.add(updateButton);

pane.add(tabPane, BorderLayout.CENTER);
pane.add(buttonPanel, BorderLayout.PAGE_END);
setContentPane(pane);

pack();
setVisible(true);
}

public void actionPerformed(final ActionEvent e) {
final String command = e.getActionCommand();
if(command.equals("apply")) {
applySettings();
} else if(command.equals("changestate")) {
if(run) { // Stop script
stateButton.setText("Start");
applyButton.setEnabled(false);
getRootPane().setDefaultButton(stateButton);
} else { // Start script
stateButton.setText("Stop");
applyButton.setEnabled(true);
getRootPane().setDefaultButton(applyButton);
applySettings();

curFMTab = null;
for(final PaintTab curTab : curStyle.getPaintTabs()) {
if(curTab.getSkillID() == Skills.FIREMAKING) {
curFMTab = curTab;
break;
}
}

// Reset instance fields...
lastSpotFoundTime = startTime = lastScreenshotTime = System.currentTimeMillis();
lastSpotNotifyTime = trips = gearFails = tinderBoxFails = lvlFails = 0;
fishingSpotTile = null;
fishingSpot = null;
status = FISHING;
resetAllTabs(curStyle.getPaintTabs());

hoverInvCount = -1;
}
run = !run;
} else if(command.equals("update")) {
updater.queryUpdate();
} else if(command.equals("checkcooking")) {
if(((FishingStyle)styleComboBox.getSelectedItem()).
containsAnyCookableFish()) {
cookCheckBox.setEnabled(true);
} else {
cookCheckBox.setEnabled(false);
cookCheckBox.setSelected(false);
}
} else if(command.equals("checkfastpowerfish")) {
if(cookCheckBox.isSelected()) {
fastPowerFishCheckBox.setEnabled(false);
fastPowerFishCheckBox.setSelected(false);
} else {
fastPowerFishCheckBox.setEnabled(true);
}
} else if(command.equals("showcustomdroppingdialog")) {
dropDialog.setVisible(true);
}
}

private void applySettings() {
curStyle = (FishingStyle)styleComboBox.getSelectedItem();
curStyleIndex = styleComboBox.getSelectedIndex();
cook = cookCheckBox.isSelected();
fastPowerFish = !cook && fastPowerFishCheckBox.isSelected();
drawPaint = drawPaintCheckBox.isSelected();
drawTrees = drawTreesCheckBox.isSelected();
check2ndSkills = check2ndSkillsCheckBox.isSelected();
useMouseKeys = mouseKeysCheckBox.isSelected();
takeScreenshots = takeScreenshotsCheckBox.isSelected();
takeScreenshotOnStop = takeScreenshotOnStopCheckBox.isSelected();
takeScreenshotOnLevelup = takeScreenshotOnLevelupCheckBox.isSelected();
hideUsernameInScreenshot = hideUsernameCheckBox.isSelected();
mouseSpeed = (Integer)mouseSpeedSpinner.getValue();
mouse.setSpeed(mouseSpeed);
final int interval = parseTime(screenshotIntervalField.getText());
if(interval < 0) {
screenshotIntervalField.setText(formatTime(screenshotInterval * 1000L));
} else {
screenshotInterval = interval;
}
final String antibanMode = (String)antibanComboBox.getSelectedItem();
antibanFactor = antibanFactorMap.get(antibanMode);
for(final AntibanAction antiban : antibans) {
antiban.updateNextTime();
}
log("Settings applied!");
log("Fishing style: " + curStyle.getName() + ", [" + (cook ? "X" : " ") + "] Cook, " +
"[" + (drawPaint ? "X" : " ") + "] Draw paint, " +
"[" + (fastPowerFish ? "X" : " ") + "] Fast Powerfish.");
log("[" + (useMouseKeys ? "X" : " ") + "] Mousekeys, " +
"[" + (drawTrees ? "X" : " ") + "] Draw trees, " +
"[" + (check2ndSkills ? "X" : " ") + "] Check secondary skills.");
log("Mouse speed: " + mouseSpeed + ", Antiban mode: " + antibanMode);
if(takeScreenshots) {
log("Taking screenshots every " + formatTime(screenshotInterval * 1000L) + ".");
}
log("[" + (takeScreenshotOnStop ? "X" : " ") + "] Take screenshot on stop.");
log("[" + (takeScreenshotOnLevelup ? "X" : " ") + "] Take screenshot on levelup.");
if(takeScreenshots || takeScreenshotOnStop || takeScreenshotOnLevelup)
log("[" + (hideUsernameInScreenshot ? "X" : " ") + "] Hide username in screenshot.");
}

public Component getListCellRendererComponent(final JList list,
final Object value, final int index,
final boolean isSelected, final boolean hasFocus) {
final FishingStyle style = (FishingStyle)value;
final int fishingLvl = skills.getCurrentLevel(Skills.FISHING);
final JLabel label = new JLabel("<html>" +
"<b>" + style.getName() + "</b><br/>" +
"<small>Fishing lvl: " +
"<font color='" + (fishingLvl >= style.getMinFishingLvl() ? "green" : "red") + "'>" +
style.getMinFishingLvl() + "</font> " +
(style.getMinFishingLvl() != style.getMaxFishingLvl() ?
"- <font color='" + (fishingLvl >= style.getMaxFishingLvl() ? "green" : "red") + "'>" +
style.getMaxFishingLvl() + "</font>" :
"") +
"</small></html>");

label.setOpaque(index != -1);
if(isSelected) {
label.setBackground(list.getSelectionBackground());
label.setForeground(list.getSelectionForeground());
} else {
label.setBackground(list.getBackground());
label.setForeground(list.getForeground());
}

return label;
}

private class DropDialog extends JDialog implements ActionListener {
private static final long serialVersionUID = 1252725231948793366L;

private final DefaultListModel listModel = new DefaultListModel();
private final JList dropList = new JList(listModel);
{
dropList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
dropList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
}
private final JCheckBox enableCheckBox = new JCheckBox("Enabled");
{
enableCheckBox.setMnemonic(KeyEvent.VK_E);
}
private final JTextField idField = new JTextField();
{
idField.addActionListener(this);
idField.setActionCommand("add");
idField.setMaximumSize(new Dimension(Integer.MAX_VALUE,
idField.getPreferredSize().height));
}
private final JButton addButton = new JButton("Add"),
removeButton = new JButton("Remove"),
selectAllButton = new JButton("Select All");
{
addButton.addActionListener(this);
addButton.setActionCommand("add");
addButton.setMnemonic(KeyEvent.VK_D);

removeButton.addActionListener(this);
removeButton.setActionCommand("remove");
removeButton.setMnemonic(KeyEvent.VK_R);

selectAllButton.addActionListener(this);
selectAllButton.setActionCommand("selectall");
selectAllButton.setMnemonic(KeyEvent.VK_A);
}

public DropDialog() {
super(Gui.this, "Custom dropping options", Dialog.ModalityType.APPLICATION_MODAL);
setLocation(new Point(300, 300));
setPreferredSize(new Dimension(250, 200));
setResizable(false);
}

private void initComponents() {
listModel.clear();
for(final int id : customDroppingIDs) {
listModel.addElement(id);
}
enableCheckBox.setSelected(customDropping);
}

public void init() {
initComponents();

final JPanel pane = new JPanel(new BorderLayout());

final JScrollPane listScrollPane = new JScrollPane(dropList);

final JPanel topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.PAGE_AXIS));
final JLabel label = new JLabel("Items to drop:");
label.setLabelFor(listScrollPane);
label.setDisplayedMnemonic(KeyEvent.VK_T);
topPanel.add(label);

final JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS));
buttonPanel.add(removeButton);
buttonPanel.add(selectAllButton);
buttonPanel.add(Box.createVerticalGlue());
final JLabel idLabel = new JLabel("ID:");
idLabel.setLabelFor(idField);
idLabel.setDisplayedMnemonic(KeyEvent.VK_I);
buttonPanel.add(idLabel);
buttonPanel.add(idField);
buttonPanel.add(addButton);

final JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
bottomPanel.add(enableCheckBox);
bottomPanel.add(Box.createHorizontalGlue());
final JButton okButton = new JButton("Ok");
okButton.addActionListener(this);
okButton.setActionCommand("ok");
okButto

Ingen status

Är reklamen ivägen? Logga in eller registrera dig så försvinner den!

Daniel
Visningsbild
P Malmö Hjälte 4 838 inlägg
0

Svar till karagana [Gå till post]:
Å andra sidan så är dess litterära kvalitéer betydligt bättre än Harry Potter.

Min internetkuk är alltid större än din.

Gurrewe
Visningsbild
P 30 Bromma Bästis För många inlägg
0

Svar till troll1 [Gå till post]:
"hasHatchet = false;" finns ju inte ens med i koden :)

/party


Forum » Mellan Himmel och Jord » Skräp & Spam » En kod.

Ansvariga ordningsvakter:

Användare som läser i den här tråden just nu

1 utloggad

Skriv ett nytt inlägg

Hej! Innan du skriver om ett potentiellt problem så vill vi påminna dig om att du faktiskt inte är ensam. Du är inte onormal och världen kommer inte att gå under, vi lovar! Så slappna av och gilla livet i några minuter - känns det fortfarande hemskt? Skriv gärna ner dina tankar och frågor, vi älskar att hjälpa just dig!

Den här tråden är äldre än Rojks drömtjej!

Det senaste inlägget i den här tråden skrevs för över tre månader sedan. Är du säker på att du vill återuppliva diskussionen? Har du något vettigt att tillföra eller passar din fråga i en ny tråd? Onödiga återupplivningar kommer att låsas så tänk efter en extra gång!

Hjälp

Det här är en hjälpruta

Här får du korta tips och förklaringar om forumet. Välj kapitel i rullningslisten här ovanför.

Rutan uppdateras automagiskt

När du använder funktioner i forumet så visas bra tips här.


Annons
Annons
Annons
Annons