Skip to content

Add player object #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
Jul 26, 2021
Merged

Add player object #260

merged 61 commits into from
Jul 26, 2021

Conversation

TheNullicorn
Copy link
Contributor

@TheNullicorn TheNullicorn commented Jun 12, 2020

  • Provides weak encapsulation around player response JSON in the form of the Player object

    • Comes with methods for common operations, like getting the player's name, rank, experience, etc
    • Inherits from UnstableHypixelObject, which itself wraps the actual response JSON
      • Getters accept a simplified version of JsonPath (dot-notation; supports escaping)
      • Provides a layer of null-safety when accessing deeply-nested properties (whose parents may be null)
      • The original object can still be retrieved via getRaw()
  • Adds an optional API for filtering unwanted/unneeded properties from objects (based on MongoDB projections)

    • Wanted keys can be marked for inclusion via PropertyFilter#include(String[]) and the static constructor PropertyFilter#including(String[])
    • Filtered objects will only contain those properties whose names are explicitly included
    • All UnstableHypixelObject support filtering via their filter(PropertyFilter) method
    • Filtered overloads for all player getters are added to HypixelAPI
      • e.g. HypixelAPI#getPlayerByUuid(UUID, PropertyFilter)
  • Updates GetPlayerExample to reflect these changes

Copy link
Contributor

@mdashlw mdashlw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it ends up being merged, but it definitely answers some basic questions and ambiguities around stuff, such as networkLevel field.

@TheNullicorn
Copy link
Contributor Author

TheNullicorn commented Jun 13, 2020

Just gonna make this a draft until I'm sure it's good. Are there any other methods you think would be helpful on a player object? Also, thoughts on getUuid returning a java.util.UUID instead of a string?

@TheNullicorn TheNullicorn marked this pull request as draft June 13, 2020 15:28
@TheNullicorn TheNullicorn marked this pull request as ready for review June 14, 2020 10:44
@HydroPage
Copy link
Contributor

HydroPage commented Nov 17, 2020

I was wondering if this was being done. That's a LOT of work for you, man, good luck (I'm a little under the impression that you're going to map most if not all of the Player JsonObject? Probably overkill)

@TheNullicorn
Copy link
Contributor Author

I was wondering if this was being done. That's a LOT of work for you, man, good luck (I'm a little under the impression that you're going to map most if not all of the Player JsonObject? Probably overkill)

Sorry to disappoint, but that wasn't my plan for the PR. This is mainly for providing a layer of null-safety over the player structure, making it easier to access deeply nested fields which could potentially be missing. Player objects have no defined structure and are constantly changing, so mapping out the entire thing would be unrealistic. I did provided some utility methods for common fields though, such as those related to rank, experience, etc.

@ConnorLinfoot ConnorLinfoot added this to the v4.0.0 milestone May 9, 2021
Copy link
Member

@ConnorLinfoot ConnorLinfoot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor changes that I can also change once this is merged if needed but looks good. The current plan is to include this in 4.0.0 which we'll hopefully work on getting everything merged and released sometime this month.

@TheNullicorn
Copy link
Contributor Author

I've resolved the requested changes, so it should be ready to merge.

Right now I've got an isOnline() method that uses lastLogin and lastLogout, but I've marked it as deprecated to prefer the status endpoint. Is that fine as-is, or should we not be adding deprecated methods into the API?

@mdashlw
Copy link
Contributor

mdashlw commented May 10, 2021

Right now I've got an isOnline() method that uses lastLogin and lastLogout, but I've marked it as deprecated to prefer the status endpoint. Is that fine as-is, or should we not be adding deprecated methods into the API?

using lastLogin and lastLogout is not deperecated in any way

@TheNullicorn
Copy link
Contributor Author

Thanks for all the help. Wasn't able to get to a few of your reviews today, but hopefully by tomorrow. If you spot anything else in the changes, or if I prematurely closed one of the conversations, let me know.

@TheNullicorn
Copy link
Contributor Author

Apologies, I think I pressed re-review twice by mistake. I've left a few of the conversations open for you to look over, but I'm pretty confident the rest are addressed.

Copy link

@CyberFlameGO CyberFlameGO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@TheNullicorn
Copy link
Contributor Author

I've made the example a bit more friendly for new users, and cleared up some vague docs. I think I'm happy with this now, but reviews are still welcome.

Copy link

@CyberFlameGO CyberFlameGO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this looks much more friendly!

@ConnorLinfoot ConnorLinfoot merged commit d6f3895 into HypixelDev:master Jul 26, 2021
@HydroPage
Copy link
Contributor

It was fun helping you, nullicorn. GG on the merge, time to implement this in my applications

@TheNullicorn
Copy link
Contributor Author

It was fun helping you, nullicorn. GG on the merge, time to implement this in my applications

Thanks for all the helpful comments! Not used to that sort of review, so it was a really nice learning experience

@TheNullicorn TheNullicorn deleted the feature/player-obj branch August 12, 2021 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants