File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java Compiler Error's dont know what to do Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Compiler Error Watch "Java Compiler Error New topic
Author

Java Compiler Error's dont know what to do

Preston Howard
Greenhorn

Joined: Dec 29, 2009
Posts: 1
Here is the script



import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.Map;
import org.rsbot.event.listeners.PaintListener;
import org.rsbot.event.listeners.ServerMessageListener;
import org.rsbot.event.events.ServerMessageEvent;
import org.rsbot.script.*;
import org.rsbot.script.wrappers.*;
import org.rsbot.script.wrappers.RSTile;
import org.rsbot.bot.Bot;
import org.rsbot.accessors.*;
import org.rsbot.accessors.Character;
import org.rsbot.account.Account;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import org.rsbot.event.listeners.PaintListener;

public class CaseAviansieRanger extends Script implements ServerMessageListener, PaintListener {
public long startTime = System.currentTimeMillis();
public int[] monsterID = new int[] {6244, 6233, 6241, 6236, 6234, 6242}; //Aviansies
public int ammoID = 9142; //Mith bolts
public int dropID = 2362; //Addy bars
public int tabID = 8015; //Bones2Peaches
public int peach = 6883; //Peach
public int bones = 526; //Bones
public int eatAt = 40;

public int nature = 561;
public int fire = 554;
public int dagger = 5678;
public int limbs = 9431;
public int air = 556;
public int law = 563;

public int cbow = 9185;

public int state = 0; //Case Modifier
public int lootCount = 0; //Times to loot before combat

public boolean emergency = false;
public boolean looting = false;

private int anti = 0;
private int run = 0;

public RSNPC killID = null;

public double getVersion( ) {
return( 0.02 );
}

public String getName( ) {
return( "AviansieRanger" );
}

public String getAuthor( ) {
return( "Blood Argon" );
}

public String getScriptCategory() {
return( "Minigames" );
}

public String getScriptDescription( ) {
String html = "";

html += "<html>\n";
html += "<body>\n";
html += "<h2>" + getName( ) + " v" + getVersion( ) + "</h2><br>\n";
html += "Author: " + getAuthor( ) + "<br>\n";
html += "<br>\n";


return( html );
}
public boolean onStart( String[ ] args ) {
log(" Avansie Ranger");
Bot.getEventManager( ).addListener(PaintListener.class, this);
return( true );
}
public void onFinish( ) {
Bot.getEventManager( ).removeListener(PaintListener.class, this);
}
public void serverMessageRecieved(ServerMessageEvent e) {
String message = e.getMessage().toLowerCase();
if(e.getMessage().equalsIgnoreCase("There is no ammo left in your quiver."))
{
log("EMERGENCY OUT OF AMMO!");
teleport();
wait(5000);
stopAllScripts();
}

}
public int loop( ) {

switch(state)
{
case 0: //Checks for required items
if (isLoggedIn()) {
setRun(true);
if (getInventoryCount(nature) >= 1 && getInventoryCount(fire) >= 5)
{
log("Alching runes [Check]");
} else {
log("Alching runes [Failed]");
log("Continuing script without alching");
}
if (getInventoryCount(law) >= 1 && getInventoryCount(air) >= 3 && getInventoryCount(fire) >= 1)
{
log("Varrock teleport [Check]");
} else {
log("Varrock teleport [Failed]");
log("No teleport failsafe. Stopping script.");
stopAllScripts();
}
if(getInventoryCount(tabID) > 1)
{
log("Bones to Peaches [Check]");
state = 1;
} else {
log("Bones to Peaches [Failed]");
log("Stopping script");
stopAllScripts();
}
}
return 1000;


case 1: //Combat
checkForFood();
setRun(true);
killID = getNearestFreeNPCByID(monsterID);
if (!getMyPlayer().isInCombat())
{
RSItemTile bone = getGroundItemByID(5,bones);
RSItemTile bar = getGroundItemByID(20,dropID);
if ((bone != null && !isInventoryFull()) || (bar != null && getInventoryCount(dropID) >= 1))
{
state = 2;
wait(random(800,1000));
looting = true;
}
if (!killID.isInCombat() && looting == false)
{
log("Target is not in combat");
if (tileOnScreen(killID.getLocation()) && !killID.isMoving()) {
if(!atNPC(killID, "attack"))
atNPC(killID, "attack");

wait(random(800,1000));
log("Attempting to kill NPC");
} else {
if(!getMyPlayer().isMoving())
walkHalfMM(killID);

wait(random(800,1000));
log("Attempting to walk to NPC");
}
} else
log("Target is in combat/We are l00tin");

} else {
wait(random(200,500));
log("We are in combat.");
}
if (getInventoryCount(cbow) >= 1)
{
log("Crossbow should not be in your inventory!");

if (getCurrentTab() != TAB_INVENTORY)
openTab(TAB_INVENTORY);

clickInventoryItem(cbow, true);
}
return 100;

case 2: //Drops
wait(random(200,500));
RSItemTile bone = getGroundItemByID(5,bones);
RSItemTile bar = getGroundItemByID(20,dropID);
RSItemTile limb = getGroundItemByID(5,limbs);
RSItemTile daggerz = getGroundItemByID(5,dagger);
if ((bar != null || bone != null || limb != null || daggerz != null) && !isInventoryFull())
log("We should loot"); looting = true;
if (bar != null && !getMyPlayer().isMoving() && (!isInventoryFull() || getInventoryCount(dropID) >= 1))
{
if (atTile(bar,"bar"))
{
log("We got the bar.");
lootCount++;
} else
walkTileMM(bar);
}
if (bone != null && !getMyPlayer().isMoving() && !isInventoryFull() && getInventoryCount(bones) < 10)
{
if (atTile(bone,"bone"))
{
log("We got the bone.");
lootCount++;
wait(random(500,1000));
} else
walkTileMM(bone);
}
if (daggerz != null && !getMyPlayer().isMoving() && !isInventoryFull())
{
if (atTile(daggerz,"dagger"))
{
log("We got the dagger.");
lootCount++;
wait(random(500,1000));
} else
walkTileMM(daggerz);
}
if (limb != null && !getMyPlayer().isMoving() && !isInventoryFull())
{
if (atTile(limb,"limb"))
{
log("We got the limb.");
lootCount++;
wait(random(500,1000));
} else
walkTileMM(limb);
}
if (isInventoryFull())
state = 3;
else
state = 1; looting = false;

if (getMyPlayer().isInCombat())
state = 1; looting = false;

if ((getInventoryCount(dagger) >= 1 || getInventoryCount(limbs) >= 1) && lootCount <= 4)
state = 3;

if (lootCount >= 5)
{
looting = false;
state = 1;
lootCount = 0;
log("Looted 5 times : Returning to combat");
}

return 1000;


case 3: //Alching drops
if (getInventoryCount(nature) >= 1 && getInventoryCount(fire) >= 5)
{
if (getInventoryCount(dagger) >= 1)
{
if (getCurrentTab() != TAB_MAGIC)
openTab(TAB_MAGIC);

castSpell(36);
clickInventoryItem(dagger, true);
wait(random(1000,2000));
}
if (getInventoryCount(limbs) >= 1)
{
if (getCurrentTab() != TAB_MAGIC)
openTab(TAB_MAGIC);

castSpell(36);
clickInventoryItem(limbs, true);
wait(random(1000,2000));
}
if (getInventoryCount(limbs) == 0 && getInventoryCount(dagger) == 0)
state = 1;
else
state = 1;

}
return 1000;



}

return 1;
}



public void walkHalfMM(RSNPC c) {
RSTile t = c.getLocation();
walkTileMM(t);
}
public void checkForFood()
{
if (skills.getCurrentSkillLevel(3) <= eatAt)
{
log("Food time");
if (getInventoryCount(peach) >= 1)
{
clickInventoryItem(peach, true);
wait(random(1000,2000));
} else {
log("Emergency tab time");
clickInventoryItem(tabID, true);
wait(random(2000,3000));
}
if (getInventoryCount(bones) >= 10)
{
if (getInventoryCount(tabID) >= 1)
{
clickInventoryItem(tabID, true);
log("Made more peaches");
wait(random(2000,3000));
} else {
log("We are out of tablets!");
teleport();
wait(5000);
stopAllScripts();
}
}
}
}
public void teleport()
{
if (getCurrentTab() != TAB_MAGIC)
{
openTab(TAB_MAGIC);
castSpell(16); //
castSpell(16); //Should we mess up
castSpell(16); //
log("Teleported to varrock");
}
}

@Override
public void castSpell(int spell) {
int x = 0;
int y = 0;
int offSet = 0;
offSet = random(-5,5);
if (getCurrentTab() != TAB_MAGIC)
openTab(TAB_MAGIC);

if (spell == 16) { //Varrock Teleport
x = 598;
y = 278;
}

if (spell == 36) { //High Alch
x = 574;
y = 348;
}
x += offSet;
y += offSet;
clickMouse(x, y, 5, 5, true);

}
public boolean clickInventoryItem(int itemID, boolean click) {
if (getCurrentTab() != TAB_INVENTORY
&& !RSInterface.getInterface(INTERFACE_BANK).isValid()
&& !RSInterface.getInterface(INTERFACE_STORE).isValid()) {
openTab(TAB_INVENTORY);
}
int[] items = getInventoryArray();
java.util.List<Integer> possible = new ArrayList<Integer>();
for (int i = 0; i < items.length; i++) {
if (items[i] == itemID) {
possible.add(i);
}
}
if (possible.size() == 0) return false;
int idx = possible.get(random(0, possible.size()));
Point t = getInventoryItemPoint(idx);
clickMouse(t, 5, 5, click);
return true;
}



public void rotate() {
int button = random(37,40);
Bot.getInputManager().pressKey((char) button);
wait(random(500, 1500));
Bot.getInputManager().releaseKey((char) button);
}

public void antiban() {

anti = random(0, 500);

if (anti <= 2) {
turnCamera();
wait(random(500, 1000));
}

if (anti == 7) {
moveMouse(random(0, 764), random(0, 501));

}

if (anti == 8) {

openTab(random(0, 13));

}

if (anti == 9) {
openTab(TAB_STATS);
wait(random(250, 700));
moveMouse(random(556, 707), random(230, 442));
wait(random(255, 400));
}

if (anti == 10) {
if (run == 0) {
setRun(true);
run = 1;
} else {
openTab(TAB_STATS);
wait(random(350, 800));
moveMouse(random(556, 707), random(230, 442));
wait(random(255, 400));

}
}
}
public void turnCamera() {
char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
char[] UD = new char[] { KeyEvent.VK_UP, KeyEvent.VK_DOWN };
char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
KeyEvent.VK_UP, KeyEvent.VK_DOWN };
int random2 = random(0, 2);
int random1 = random(0, 2);
int random4 = random(0, 4);

if (random(0, 3) == 0) {
Bot.getInputManager().pressKey(LR[random1]);
try {
Thread.sleep(random(100, 400));
} catch (Exception e) {}
Bot.getInputManager().pressKey(UD[random2]);
try {
Thread.sleep(random(300, 600));
} catch (Exception e) {}
Bot.getInputManager().releaseKey(UD[random2]);
try {
Thread.sleep(random(100, 400));
} catch (Exception e) {}
Bot.getInputManager().releaseKey(LR[random1]);
} else {
Bot.getInputManager().pressKey(LRUD[random4]);
if (random4 > 1) {
try {
Thread.sleep(random(300, 600));
} catch (Exception e) {}
} else {
try {
Thread.sleep(random(500, 900));
} catch (Exception e) {}
}
Bot.getInputManager().releaseKey(LRUD[random4]);
}
}
public void onRepaint( Graphics g ) {
if (isLoggedIn()) {
long millis = System.currentTimeMillis() - startTime;
long hours = millis / (1000 * 60 * 60);
millis -= hours * 1000 * 60 * 60;
long minutes = millis / (1000 * 60);
millis -= minutes * 1000 * 60;
long seconds = millis / 1000;
int x = 9;
int y = 188;
int barcount = 0;
int GEPrice = 2299;
int profit = 0;
int coins = 0;
coins = getInventoryCount(995);
profit = (barcount*GEPrice);
barcount = getInventoryCount(dropID);
//interval of 12
g.setColor(Color.white);
g.drawString("Aviansie Hunter", x, y);
g.drawString("Bars Collected : "+barcount+".", x, y+=12);
g.drawString("Coins from Alching : "+coins+".", x, y+=12);
g.drawString("Time Running : " + hours + " hours " + minutes + " minutes " + seconds + " seconds.", x, y+=12);
}
}
}

/*
setRun(true);
antiban(); //Standard routine
if (!getMyPlayer().isInCombat()) {
if (!isInventoryFull() || getInventoryCount(dropID) >= 1) //We can collect our loot
{
wait(random(200,500));
RSItemTile bone = getGroundItemByID(7,bones);
RSItemTile bar = getGroundItemByID(7,dropID);
if (bar != null || bone != null)
log("We should loot");
if (bar != null)
{
if (distanceTo(bar) > 5){
walkTileMM(bar);
wait(random(1500,2000));
}
if (atTile(bar,"bar"))
{
log("We got the bar.");
}
}
wait(random(2000,3000));
if (bone != null)
{
if (atTile(bone,"bone"))
{
log("We got the bone.");
wait(random(500,1000));
}
}
if (bar != null) //Bar is most important, and we cannot miss it!
{
if (distanceTo(bar) > 5){
walkTileMM(bar);
wait(random(1500,2000));
}
if (atTile(bar,"bar"))
{
log("We got the bar.");
}
}
}
}

killID = getNearestFreeNPCByID(monsterID);
//lockOn();
if (!getMyPlayer().isInCombat())
{
if (!killID.isInCombat())
{
log("Target is not in combat");
//if (atNPC(killID, "attack")) {log("Started combat"); } else { rotate(); }
if (emergency == true)
{
getLost();
} else {
atNPC(killID, "attack");
}
} else {
log("Target is busy");
}
} else {
wait(random(200,500));
log("We are in combat.");
if (emergency == true)
{
getLost();
}
}


if (skills.getCurrentSkillLevel(3) <= eatAt)
{
log("Food time");
if (getInventoryCount(peach) >= 1)
{
clickInventoryItem(peach, true);
wait(random(1000,2000));
} else {
log("Emergency tab time");
clickInventoryItem(tabID, true);
}
if (getInventoryCount(bones) >= 10)
{
if (getInventoryCount(tabID) >= 1)
{
clickInventoryItem(tabID, true);
log("Made more peaches");
wait(random(2000,3000));
} else {
log("We are out of tablets!");
stopAllScripts();
}
}
}

*/



Here it is after I compile!!!


Looking for JDK
Compiling scripts
Scripts\CaseAviansieRanger.java:12: cannot find symbol
symbol : class Character
location: package org.rsbot.accessors
import org.rsbot.accessors.Character;
^
Scripts\CaseAviansieRanger.java:13: package org.rsbot.account does not exist
import org.rsbot.account.Account;
^
Scripts\CaseAviansieRanger.java:47: reference to RSNPC is ambiguous, both class
org.rsbot.accessors.RSNPC in org.rsbot.accessors and class org.rsbot.script.wrap
pers.RSNPC in org.rsbot.script.wrappers match
public RSNPC killID = null;
^
Scripts\CaseAviansieRanger.java:286: reference to RSNPC is ambiguous, both class
org.rsbot.accessors.RSNPC in org.rsbot.accessors and class org.rsbot.script.wra
ppers.RSNPC in org.rsbot.script.wrappers match
public void walkHalfMM(RSNPC c) {
^
Scripts\CaseAviansieRanger.java:333: castSpell(int) in CaseAviansieRanger cannot
override castSpell(int) in org.rsbot.script.Methods; attempting to use incompat
ible return type
found : void
required: boolean
public void castSpell(int spell) {
^
Scripts\CaseAviansieRanger.java:332: method does not override or implement a met
hod from a supertype
@Override
^
Scripts\CaseAviansieRanger.java:357: reference to RSInterface is ambiguous, both
class org.rsbot.accessors.RSInterface in org.rsbot.accessors and class org.rsbo
t.script.wrappers.RSInterface in org.rsbot.script.wrappers match
&& !RSInterface.getInterface(INTERFACE_BANK).isV
alid()
^
Scripts\CaseAviansieRanger.java:358: reference to RSInterface is ambiguous, both
class org.rsbot.accessors.RSInterface in org.rsbot.accessors and class org.rsbo
t.script.wrappers.RSInterface in org.rsbot.script.wrappers match
&& !RSInterface.getInterface(INTERFACE_STORE).is
Valid()) {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors
Press any key to continue . . .








Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41620
    
  55
Welcome to JavaRanch.

Please edit your post to UseCodeTags. It's unnecessarily hard to read the code as it is, making it less likely that people will bother to do so.


Ping & DNS - my free Android networking tools app
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
You might also want to try to figure out what pieces of code go with which error, if you can. That is a wall of code that I suspect many people would look at, and not really want to dig through all of it to find each error.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

posting the exact and complete text of the error messages would also help.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

They are there Fred, just not very clear without the formatting. Here they are again, with my explanations of them in between for Preston:
This looks clear enough; you try to import org.rsbot.accessors.Character but it simply does not exist. I can also not find it at http://rsbotsvn.googlecode.com/svn/trunk/src/org/rsbot/.

Likewise, but this time an entire package does not exist. This may be caused by a missing JAR file on the class path.

The error says enough; you import both org.rsbot.accessors.* and org.rsbot.script.wrappers.*. Both packages have a class called RSNPC. You need to import the one you need explicitly.

Apparently class org.rsbot.script.Methods has a method called castSpell that takes an int and returns a boolean. Your class extends Script which in turn extends this class. Therefore, you must keep the return type as boolean. Both errors will be fixed by this change.

See my comments about the earlier ambiguous reference.

This is a warning but it is also quite clear. Somewhere you override a deprecated method or call one. I've checked, and both getScriptDescription() and onStart(String[]) are deprecated. The Javadoc of the class mention what to use instead.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: Java Compiler Error's dont know what to do