neopixeldev / hypixel-api-java

Asynchronous Java wrapper for the Hypixel API
MIT License
6 stars 2 forks source link

Change JSONHandler from returning empty optionals to default values #97

Closed unpluggedsam closed 2 years ago

unpluggedsam commented 2 years ago

This commit will make the JSONHandler class return default values instead of empty Optional's. It checks if the value is present, and if it is it returns the value, but if it isn't it returns a default value based on the type. The JSONHandler class is needed because if the value wasn't present in the API an NPE would be thrown.

Originally, Optional's were preferred because we were nervous about the User handling null values. But, after further consideration returning default values is preferable because in reality that is what the value really is. For example, if the User has no kills in lucky blocks bedwars that statistic wouldn't show up. But really, they just have the default value of 0.