I've tried to create an itemstack and catch any exceptions and if it does throw an exception then it isn't an item id, is this correct? Is there a better method?
Nvm Throws a NullPointerException so the item is null if new ItemStack(this integer isn't valid) never mind guys!
I just try{ new Material(theId).name(); } catch(NullPointerException e){ //then it isn't a valid item id }
With that you heavily rely on something, which can change anytime, as it isn't specified in the API. For example in 1.8.7 it could throw a IllegalArgumentException or just return "AIR". You don't know. Better only use functions you can rely on: Material.getMaterial(id) == null when given invalid id.
It is command based, generally it would be better that way, however what I am using it for is better with my method as the item is generated via command into a custom GUI, I don't think it would change if the event was cancelled all the time