What I would do is get the item IDs of each weapon style melee, ranged and magic and sort them into an array. Then use binarySearch to check if the opponents weapon slot equipment is included in one of the arrays. Next I would check the distance of the opponent from myself to determine if he is not staff bashing or casting a spell. Pour this into a separate thread which calls every 600ms (1 tick) and change a variable concurrently using AtomicReference in the main thread for thread safety to grab whichever attack style the opponent is using. You would only do this for the character interacting with yourself through Players.getLocal().getCharacterInteractingWithMe()