我不知道为什么这总是编译说它缺少返回语句,如果有人可以帮助我,那就太好了!我已经尝试了几个小时,但仍然不明白为什么这段代码无法编译。我对 java 不是很好,但这段代码对我来说看起来很完美。
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import net.xotiksys.api.ActiveScript;
import net.xotiksys.api.Manifest;
import net.xotiksys.api.methods.input.Mouse;
import net.xotiksys.api.methods.recognition.ColorRecognition;
import net.xotiksys.api.painting.Paintable;
import net.xotiksys.api.util.Time;
@Manifest(author = "iwrestledabearonce", description = "Auto Miner with bank support", name = "MiningBot", version = 1.0)
public class MiningBot extends ActiveScript implements Paintable {
private int Mined;
private Color ITEM = new Color(0, 0, 0);
private static final Color addy = new Color(74, 93, 74);
private static final Rectangle magicTab = new Rectangle(629, 170, 28, 30);
private static final Rectangle inv = new Rectangle(551, 206, 185, 255);
private static final Rectangle GFrame = new Rectangle(2, 3, 517, 339);
private static final long START_TIME = System.currentTimeMillis();
private Point ROCK = null;
private Point rockToMine = null;
private String Status = "Starting Auto Miner by iwrestledabearonce - Version 1.0 - Please be patient...";
private String TempColor = "";
@Override
public int script() {
Time.sleep(700);
if (ROCK != null) {
startMining(); //by iwrestledabearonce
}
else
return 700;
}
public void startMining() {
do {
ROCK = ColorRecognition.getPoint(addy, 2, inv);
rockToMine = ColorRecognition.getPoint(ITEM, 2, inv);
if (ROCK != null) {
Mouse.click(ROCK, 0, 0, true);
Time.sleep(700);
Mined++;
Status = "Mining Ore...";
stopScript();
} while (ROCKS != null && validate());
}
public void paint(final Graphics g) {
g.setColor(Color.ORANGE);
int ycoord = 349;
g.drawString("Status: " + Status, 15, ycoord += 10);
g.drawString("Rock's Mined: " + Mined, 15, ycoord += 20);
g.drawString("Run Time: "+ Time.format(System.currentTimeMillis() - START_TIME),15, ycoord += 30);
}
}
上面的新代码现在会在下面创建此错误:
Scripts\MiningBot.java:52: error: while expected
}
^
Scripts\MiningBot.java:56: error: illegal start of expression
public void paint(final Graphics g) {
^
Scripts\MiningBot.java:56: error: ')' expected
public void paint(final Graphics g) {
^
Scripts\MiningBot.java:56: error: ';' expected
public void paint(final Graphics g) {
^
Scripts\MiningBot.java:56: error: ';' expected
public void paint(final Graphics g) {
^
Scripts\MiningBot.java:63: error: reached end of file while parsing
}
^
6 errors
C:\Users\TJ\Desktop\XotikColor>pause
Press any key to continue . . .