Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 用于在不同阵列之间切换的运算符,内部更精确_Java_Arrays_If Statement - Fatal编程技术网

Java 用于在不同阵列之间切换的运算符,内部更精确

Java 用于在不同阵列之间切换的运算符,内部更精确,java,arrays,if-statement,Java,Arrays,If Statement,我正在为一个程序编写一个脚本,我正在尝试添加一个功能,如果客户端检测到某个字符串被发送,并执行响应中指定的操作,则该功能将被添加 这是我的问题,我试图得到它,这样当它说任何与“这里”在它,然后它将移动到一个新的瓷砖阵列!那么,如果消息被发送,有没有办法让脚本转到下一个数组 这是我的代码,我将在下面更好地解释我的问题: @ScriptDetails(author = "iSully", category = "Firemaking", description = "Burns Your Will

我正在为一个程序编写一个脚本,我正在尝试添加一个功能,如果客户端检测到某个字符串被发送,并执行响应中指定的操作,则该功能将被添加

这是我的问题,我试图得到它,这样当它说任何与“这里”在它,然后它将移动到一个新的瓷砖阵列!那么,如果消息被发送,有没有办法让脚本转到下一个数组

这是我的代码,我将在下面更好地解释我的问题:

@ScriptDetails(author = "iSully", category = "Firemaking", description = "Burns Your  Willow Logs So You Don't Have To!", name = "iFire - Willows", version = 1.1)
public class iFire extends Script implements Painter, LoopTask {

private static int logs;
private static final int tinderbox = 591;
private int loopCounter = 0;
private static final int fire = 2732;
private static final int ID_BANKBOOTH = 2213;
private FontMetrics FONTMETRICS = null;
private final Timer RUNTIME = new Timer();
private String STATE = "";
private int Burnt = 0;
private int XP = 0;
public boolean guiWait = true;
gui g = new gui();

Tile[] toFire1 = new Tile[] { new Tile(2722, 3493, 0),
        new Tile(2725, 3489, 0), new Tile(2725, 3485, 0),
        new Tile(2734, 3486, 0) };

Tile[] fire1ToBank = new Tile[] { new Tile(2711, 3486, 0),
        new Tile(2716, 3484, 0), new Tile(2721, 3486, 0),
        new Tile(2725, 3489, 0), new Tile(2722, 3493, 0) };

Tile[] toFire2 = new Tile[] { new Tile(2721, 3493, 0), new Tile(2723, 3488, 0), new Tile(2720, 3484, 0), 
        new Tile(2715, 3483, 0), new Tile(2710, 3483, 0), new Tile(2708, 3483, 0) };

Tile[] toFire3 = new Tile[] { new Tile(2722, 3493, 0), new Tile(2725, 3489, 0), new Tile(2721, 3486, 0), 
        new Tile(2716, 3485, 0), new Tile(2711, 3485, 0), new Tile(2706, 3485, 0), 
        new Tile(2706, 3484, 0) };

Tile[] fire3ToBank = new Tile[] { new Tile(2683, 3484, 0), new Tile(2688, 3484, 0), new Tile(2695, 3484, 0), 
        new Tile(2701, 3484, 0), new Tile(2706, 3484, 0), new Tile(2711, 3485, 0), 
        new Tile(2716, 3485, 0), new Tile(2721, 3485, 0), new Tile(2724, 3489, 0), 
        new Tile(2721, 3493, 0) };

Tile[] fire2ToBank = new Tile[] { new Tile(2680, 3482, 0), new Tile(2686, 3482, 0), new Tile(2691, 3482, 0), 
        new Tile(2696, 3484, 0), new Tile(2701, 3485, 0), new Tile(2706, 3485, 0), 
        new Tile(2711, 3485, 0), new Tile(2716, 3485, 0), new Tile(2721, 3485, 0), 
        new Tile(2723, 3490, 0), new Tile(2721, 3493, 0) };

Tile[] toFire4 = new Tile[] { new Tile(2721, 3493, 0), new Tile(2724, 3489, 0), new Tile(2721, 3485, 0), 
        new Tile(2716, 3484, 0), new Tile(2711, 3484, 0), new Tile(2708, 3485, 0) };

Tile[] fire4ToBank = new Tile[] { new Tile(2682, 3484, 0), new Tile(2688, 3484, 0), new Tile(2695, 3484, 0), 
        new Tile(2700, 3484, 0), new Tile(2705, 3483, 0), new Tile(2710, 3483, 0), 
        new Tile(2716, 3483, 0), new Tile(2721, 3482, 0), new Tile(2722, 3487, 0), 
        new Tile(2721, 3492, 0), new Tile(2720, 3493, 0) };

private ArrayList<Strategy> strategy = new ArrayList<Strategy>();

protected boolean onExecute() {
    strategy.add(new a1());
    provide(strategy);
    g.setVisible(true);

    while (guiWait == true) {
        BotGUI.log("Starting up....");
        sleep(10000);
    }
    return (true);
}

public void paint(Graphics g) {
    if (FONTMETRICS == null) {
        FONTMETRICS = g.getFontMetrics();
        RUNTIME.start();
    }
    drawGradientText(g, "Runtime: " + RUNTIME.getElapsedTime(), 15, 200,
            Color.red);
    drawGradientText(g, "State: " + STATE, 15, 218, Color.red);
    drawGradientText(g, "Logs Burnt: " + Burnt + "", 15, 236, Color.red);

}

public class a1 extends Strategy {

    public boolean isValid() {
        BotGUI.log("Script Started!");
        return true;

    }

    public void run() {
        Camera.setPitch(true);

    }
}

protected void onFinish() {
    BotGUI.log("Script Stopped! Thanks for using iFire by iSully!");
    BotGUI.log("Please leave feedback on the Parabot forum");
}

public int loop() {
    bank();
    toFire1();
    lightFires();
    toBank1();
    bank();
    toFire2();
    lightFires();
    toBank2();
    bank();
    toFire3();
    lightFires();
    toBank3();
    bank();
    toFire4();
    lightFires();
    toBank4();
    loopCounter++;
    return 1000;
}

void toBank1() {
    STATE = "Walking To Bank";
    Path path = new Path(fire1ToBank);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(fire1ToBank).traverse();
        }
    }

}

void toBank2() {
    STATE = "Walking To Bank";
    Path path = new Path(fire2ToBank);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(fire2ToBank).traverse();
        }
    }

}

void toFire1() {
    STATE = "Walking To Burning Path #1";
    Path path = new Path(toFire1);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(toFire1).traverse();
            if(toFire1.equals(2732)){
                toFire2();
            }
        }
    }

}

void toFire2() {
    STATE = "Walking To Burning Path #2";
    Path path = new Path(toFire2);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(toFire2).traverse();
        }if(toFire2.equals(2732)){
            toFire3();
        }
    }

}
void toBank3() {
    STATE = "Walking To Bank";
    Path path = new Path(fire3ToBank);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(fire3ToBank).traverse();
        }
    }

}

void toFire3() {
    STATE = "Walking To Burining Location #3";
    Path path = new Path(toFire3);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(toFire3).traverse();
        }if(toFire3.equals(2732)){
            toFire4();
        }
    }

}

void toFire4() {
    STATE = "Walking To Burining Location #4";
    Path path = new Path(toFire4);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(toFire4).traverse();
        }if(toFire4.equals(2732)){
            toFire2();
        }
    }

}

void toBank4() {
    STATE = "Walking To Bank";
    Path path = new Path(fire4ToBank);
    while (!path.hasReached()) {
        while (!Players.getMyPlayer().isMoving()) {
            Walking.getPath(fire4ToBank).traverse();
        }
    }

}

void closeBank() {
    if (Walking.isRunEnabled() == false) {
        Time.sleep(1000); // 1600
        Mouse.hop(460, 41);
        Time.sleep(500); // 900
        Mouse.click(460, 41, true);
        Time.sleep(500); // 1000
    }
}

void bank() {
    GameObject bankBooth = GameObjects.getNearest(ID_BANKBOOTH);
    if (!bankBooth.isOnScreen()) {
        Camera.turnTo(bankBooth);
    }

    while (!Bank.isOpen()) {
        bankBooth.interact("Use-quickly");
        Time.sleep(2000);
    }

    while (!Inventory.isFull()) {
        Bank.withdraw(logs, 27);
        Time.sleep(500);
    }

}

private boolean isLighting() {
    return Players.getMyPlayer().getAnimation() != -1;
}

void lightFires() {
    STATE = "Lighting Fires";
    while (Inventory.contains(logs)) {
        if (isLighting() == false) {
            Inventory.getItem(tinderbox).interact("Use");
            Inventory.getItem(logs).interact("Use Tinderbox with");
            Burnt++;
            Time.sleep(3000);
        } else {
            Time.sleep(4500);
        }
    }

}

void useRun() {
    if (Walking.isRunEnabled() == false) {
        Time.sleep(1000);
        Mouse.hop(710, 485);
        Time.sleep(500);
        Mouse.click(710, 485, true);
        Time.sleep(1000);
        Mouse.hop(625, 270);
        Time.sleep(500);
        Mouse.click(625, 270, true);
        Time.sleep(500);
        Mouse.hop(650, 185);
        Time.sleep(1000);
        Mouse.click(650, 185, true);
        Time.sleep(random(750, 1250));
    }
}

public void drawGradientText(Graphics g, String text, int x, int y, Color c) {
    Graphics2D g2 = (Graphics2D) g;
    Color color3 = new Color(51, 51, 51, 205);
    Font font1 = new Font("Arial", 0, 12);
    g.setFont(font1);
    FONTMETRICS = g.getFontMetrics();
    Rectangle textBox = new Rectangle(x, y - g.getFont().getSize(),
            (int) FONTMETRICS.getStringBounds(text, g).getWidth() + 8,
            (int) FONTMETRICS.getStringBounds(text, g).getHeight() + 5);
    Paint defaultPaint = g2.getPaint();
    g2.setPaint(new RadialGradientPaint(new Point.Double(textBox.x
            + textBox.width / 2.0D, textBox.y + textBox.height / 2.0D),
            (float) (textBox.getWidth() / 2.0D),
            new float[] { 0.5F, 1.0F }, new Color[] {
                    new Color(color3.getRed(), color3.getGreen(), color3
                            .getBlue(), 175),
                    new Color(0.0F, 0.0F, 0.0F, 0.8F) }));
    g.fillRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
    g2.setPaint(defaultPaint);
    g.setColor(Color.WHITE);
    g.drawRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
    g.setColor(Color.WHITE);
    g.drawString(text, x + 4, y + 15);
    for (int i = 0; i < text.length(); i++) {
        if (Character.isDigit(text.charAt(i))) {
            g.setColor(new Color(255, 255, 255));
            g.drawString("" + text.charAt(i),
                    x + FONTMETRICS.stringWidth(text.substring(0, i)) + 4,
                    y + 15);
        }
    }
}

public class Timer {
    long millis;

    /**
     * Starts the timer
     */
    public void start() {
        millis = System.currentTimeMillis();
    }

    /**
     * Resets the timer
     */
    public void reset() {
        millis = 0;
    }

    /**
     * Determines if timer is running
     * 
     * @return <b>true</b> if timer is running
     */
    public boolean isRunning() {
        return millis != 0;
    }

    /**
     * Generates string based on HH:MM:SS
     * 
     * @return String
     */
    public String getElapsedTime() {
        long elapsedTime = System.currentTimeMillis() - millis;
        String format = String.format("%%0%dd", 2);
        elapsedTime = elapsedTime / 1000;
        String seconds = String.format(format, elapsedTime % 60);
        String minutes = String.format(format, (elapsedTime % 3600) / 60);
        String hours = String.format(format, elapsedTime / 3600);
        String time = hours + ":" + minutes + ":" + seconds;
        return time;
    }

    /**
     * Calculates Experience per hour based on timer
     * 
     * @param Gained
     *            experience
     * @return Experience per hour
     */
    public int getEXPHour(int xpgained) {
        return (int) ((xpgained) * 3600000D / (System.currentTimeMillis() - millis));
    }

}

public void messageRecieved(String message) {
    if (message.toLowerCase().contains("burn")) {
        Burnt++;
        if(message.toLowerCase().contains("here")){

        }
    }
}
@ScriptDetails(author=“iSully”,category=“Firemaking”,description=“烧掉你的柳树原木,这样你就不必了!”,name=“iFire-Willows”,version=1.1)
公共类iFire扩展脚本实现Painter、LoopTask{
私有静态int日志;
专用静态最终int tinderbox=591;
私有int循环计数器=0;
私人静态最终内部火灾=2732;
私人静态最终int ID_BANKBOOTH=2213;
私有FontMetrics FontMetrics=null;
专用最终计时器运行时=新计时器();
私有字符串状态=”;
私有int=0;
私有int XP=0;
公共布尔值guiWait=true;
gui g=新gui();
Tile[]toFire1=新Tile[]{新Tile(27223493,0),
新瓷砖(27253489,0),新瓷砖(27253485,0),
新瓷砖(27343486,0)};
瓷砖[]fire1ToBank=新瓷砖[]{新瓷砖(27113486,0),
新瓷砖(27163484,0),新瓷砖(27213486,0),
新瓷砖(27253489,0),新瓷砖(27223493,0)};
瓷砖[]toFire2=新瓷砖[]{新瓷砖(27213493,0),新瓷砖(27233488,0),新瓷砖(27203484,0),
新瓷砖(27153483,0),新瓷砖(27103483,0),新瓷砖(27083483,0)};
瓷砖[]toFire3=新瓷砖[]{新瓷砖(27223493,0),新瓷砖(27253489,0),新瓷砖(27213486,0),
新瓷砖(27163485,0)、新瓷砖(27113485,0)、新瓷砖(27063485,0),
新瓷砖(27063484,0)};
瓷砖[]fire3ToBank=新瓷砖[]{新瓷砖(26833484,0),新瓷砖(26883484,0),新瓷砖(26953484,0),
新瓷砖(27013484,0)、新瓷砖(27063484,0)、新瓷砖(27113485,0),
新瓷砖(27163485,0)、新瓷砖(27213485,0)、新瓷砖(27243489,0),
新瓷砖(27213493,0)};
瓷砖[]fire2ToBank=新瓷砖[]{新瓷砖(26803482,0),新瓷砖(26863482,0),新瓷砖(26913482,0),
新瓷砖(26963484,0),新瓷砖(27013485,0),新瓷砖(27063485,0),
新瓷砖(27113485,0)、新瓷砖(27163485,0)、新瓷砖(27213485,0),
新瓷砖(27233490,0),新瓷砖(27213493,0)};
瓷砖[]toFire4=新瓷砖[]{新瓷砖(27213493,0),新瓷砖(27243489,0),新瓷砖(27213485,0),
新瓷砖(27163484,0),新瓷砖(27113484,0),新瓷砖(27083485,0)};
瓷砖[]fire4ToBank=新瓷砖[]{新瓷砖(26823484,0),新瓷砖(26883484,0),新瓷砖(26953484,0),
新瓷砖(27003484,0),新瓷砖(27053483,0),新瓷砖(27103483,0),
新瓷砖(27163483,0)、新瓷砖(27213482,0)、新瓷砖(27223487,0),
新瓷砖(27213492,0),新瓷砖(27203493,0)};
私有ArrayList策略=新建ArrayList();
受保护的布尔值onExecute(){
添加(新a1());
提供(战略);
g、 setVisible(真);
while(guiWait==true){
日志(“启动…”);
睡眠(10000);
}
返回(真);
}
公共空间涂料(图g){
如果(FONTMETRICS==null){
FONTMETRICS=g.getFontMetrics();
RUNTIME.start();
}
drawGradientText(g,“Runtime:+Runtime.getElapsedTime(),15200,
颜色(红色);
drawGradientText(g,“状态:+状态,15218,颜色.红色);
drawGradientText(g,“烧过的原木:“+burned+”,15236,颜色为红色);
}
公共类a1扩展策略{
公共布尔值isValid(){
log(“脚本已启动!”);
返回true;
}
公开募捐{
摄像机。设置俯仰(真);
}
}
受保护的void onFinish(){
log(“脚本停止了!感谢您使用iFire by iSully!”);
log(“请在Parabot论坛上留下反馈”);
}
公共int循环(){
银行();
toFire1();
闪电();
toBank1();
银行();
toFire2();
闪电();
toBank2();
银行();
toFire3();
闪电();
toBank3();
银行();
toFire4();
闪电();
toBank4();
loopCounter++;
返回1000;
}
void toBank1(){
STATE=“步行到银行”;
路径路径=新路径(fire1ToBank);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(fire1ToBank.traverse();
}
}
}
void toBank2(){
STATE=“步行到银行”;
路径路径=新路径(fire2ToBank);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(fire2ToBank.traverse();
}
}
}
void toFire1(){
STATE=“走向燃烧路径#1”;
路径路径=新路径(toFire1);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(toFire1.travel();
if(toFire1.等于(2732)){
toFire2();
}
}
}
}
void toFire2(){
STATE=“走向燃烧路径#2”;
路径路径=新路径(toFire2);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(toFire2.travel();
}if(toFire2.等于(2732)){
toFire3();
}
}
}
void toBank3(){
STATE=“步行到银行”;
路径路径=新路径(fire3ToBank);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(fire3ToBank.traverse();
}
}
}
void toFire3(){
STATE=“步行到Buring位置#3”;
路径路径=新路径(toFire3);
而(!path.hasreach()){
而(!Players.getMyPlayer().isMoving()){
Walking.getPath(toFire3.travel();
}如果(toFire3.equ)
Tile[] toFire1 = ...
Tile[] toFire2 = ...
Tile[] toFire3 = ...
Tile[][] toFire = {{ new Tile(2722, 3493, 0), new Tile(2725, 3489, 0), new Tile(2725, 3485, 0), new Tile(2734, 3486, 0)},  // was toFire1
                   { new Tile(2721, 3493, 0), new Tile(2723, 3488, 0), new Tile(2720, 3484, 0), new Tile(2715, 3483, 0), new Tile(2710, 3483, 0), new Tile(2708, 3483, 0) }, // was toFire2
                   { new Tile(2722, 3493, 0), new Tile(2725, 3489, 0), new Tile(2721, 3486, 0), new Tile(2716, 3485, 0), new Tile(2711, 3485, 0), new Tile(2706, 3485, 0), new Tile(2706, 3484, 0) }} // was toFire3