Handle inventory max stack sizes even better. Fixes BUKKIT-5595
Manual merge of 8f0832a