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.
This commit will make the
JSONHandler
class return default values instead of emptyOptional
'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. TheJSONHandler
class is needed because if the value wasn't present in the API anNPE
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.