why not try
NPC Goblin = npcs.closest("Goblin");
if (Goblin != null && !(Goblin.isUnderAttack())) //getMap().canReach(Goblin) { if (Goblin.isVisible()) { Goblin.interact(new String[]{"Attack"}); new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().getInteracting() != null; } }.sleep(); } } else if (!Goblin.isVisible()) { this.camera.toEntity((Entity) Goblin); if (Goblin.exists() && !Goblin.isVisible()) { walking.walk(Goblin); while(myPlayer().isMoving()) { sleep(250); } }