Java返回错误?我很困惑

时间:2017-03-18 13:21:34

标签: java

我不确定我做错了什么我可能会错过一些愚蠢的返回错误  有人请帮助控制器错误我得到...

...起动 src \ com \ rs \ game \ npc \ combat \ impl \ ChaosElemental.java:59:错误:缺少return语句         } 1错误 按任意键继续......

    package com.rs.game.npc.combat.impl;

    import java.util.ArrayList;

    import com.rs.game.player.Player;
    import com.rs.game.Entity;
    import com.rs.game.ForceTalk;
    import com.rs.game.World;
    import com.rs.game.Animation;
    import com.rs.game.Graphics;
    import com.rs.game.Hit;
    import com.rs.game.Hit.HitLook;
    import com.rs.game.npc.NPC;
    import com.rs.game.npc.combat.CombatScript;
    import com.rs.game.npc.combat.NPCCombatDefinitions;
    import com.rs.game.tasks.WorldTask;
    import com.rs.game.tasks.WorldTasksManager;
    import com.rs.utils.Utils;

    public class ChaosElemental extends CombatScript {

@Override
public Object[] getKeys() {
    return new Object[] { 3200 };
}

@Override
public int attack(NPC npc, Entity target) {
            NPCCombatDefinitions cdefs = npc.getCombatDefinitions();
    if (Utils.random(7) == 2) {
            if (target instanceof Player) {
                delayHit(npc, 2, target, getRangeHit(npc, getRandomMaxHit(npc, 2000, NPCCombatDefinitions.RANGE, target)));
                World.sendProjectile(npc, target, 552, 18, 18, 50, 50, 0, 0);
                npc.setNextForceTalk(new ForceTalk("Charging a powerful attack..."));
            }
        } else {
    int rand = Utils.random(10);
            if (rand <= 3) {
                delayHit(npc, 2, target, getRangeHit(npc, getRandomMaxHit(npc, 650, NPCCombatDefinitions.RANGE, target)));
                World.sendProjectile(npc, target, 552, 18, 18, 50, 50, 0, 0);
            } else if (rand >= 7) {
                delayHit(npc,0,target,getMeleeHit(npc, getRandomMaxHit(npc, 800, NPCCombatDefinitions.MELEE, target)));
            } else {
                int damage = getRandomMaxHit(npc, 750, NPCCombatDefinitions.MAGE, target);
                if (damage > 0) {
                    delayHit(npc, 1, target, getMagicHit(npc, damage));
                }
                npc.setNextForceTalk(new ForceTalk("Your gon get rekt nerd"));
            }
        }
}

}

1 个答案:

答案 0 :(得分:0)

    如果您不想返回任何内容,
  • attack应该void作为返回类型而不是int
  • 为什么getKeys()会返回Object[]而不是int[]