The problemo is here:
switch(getState()){
case KILL:
NPC skeleton = npcs.closest("Skeleton");
if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){
getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
} else sleep(random(100,250));
getTabs().open(Tab.MAGIC);
break;
more importantly:
if (skeleton.isVisible() && getTabs().getOpen().equals(magic)){
Firstly, nullcheck for the skeleton. Secondly, it would have to be
getTabs().getOpen().equals(Tab.MAGIC);
(not sure why you had just magic there, but i would expect it to give you an error for that). The reason it opens the magic tab then does nothing is because that if statement returns false every time as you just wrote magic in there. that means it always goes to the else part which says open the magic tab (which already checks if it is open or not before performing). So ye, replace all that with this:
case KILL:
NPC skeleton = npcs.closest("Skeleton");
if (skeleton != null && skeleton.exists() && skeleton.isVisible() && getTabs().getOpen().equals(Tab.MAGIC)){
getMagic().castSpellOnEntity(Spells.NormalSpells.CRUMBLE_UNDEAD, skeleton);
sleep(3000L);
} else {
sleep(random(100,250));
getTabs().open(Tab.MAGIC);
}
break;
Let me know if anything is unclear
Apaec