-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Wrap player object in class * Add utility methods to player * Add javadocs for player object * Add javadocs for property accessors * Add get level method to player * Update examples * Fix incorrect network exp * Use getLongProperty instead of getNumberProperty.longValue * Use fallback when displayname is not present * Fix exp calculation Co-authored-by: mdashlw <[email protected]> * Add method for recent GameType * Add method for PetStats * Add methods to check player api visibility * Add rank color & mc version methods to player * Fix incorrect javadocs * Fix javadoc typo * Remove methods that access player settings * Add public constructor to Player * Check for exception in GetPlayerExample * Return UUID instead of String from getUuid * Move GSON into Utilities * Clarify getUuid javadoc Co-authored-by: Noe <[email protected]> * Change getPlusColor to getSelectedPlusColor * Explicitly exit in GetPlayerExample * Clean up uuidFromString Co-authored-by: Noe <[email protected]> * Add hasProperty() to Player * Add ComplexHypixelObject for property methods * Remove extra parenthesis * Simplify uuidFromString * Begin property filter * Let keys be removed from filter * Check for null keys * Document PropertyFilter * Overload player fetch methods w/ filters * Allow batch filtering * Detect & fix key collisions * Respect escapes when applying * Respect escapes in #getProperty(...) * Apply suggestions from code review Co-authored-by: Noe <[email protected]> * Make raw non-null * Change "complex" to "unstable" * Only compile key splitter once * Private constructor & final for Utilities * Remove redundant getProperty() logic * More getProperty() simplifying * Change with() to including() * Remove "keys" from method names * Clarify property javadocs * Update exists() check * Formatting & example change * Fix null players & flip filter/object dependence * Clarify documentation for players * Use ZonedDateTime instead of Date * Use a more informative example * Add a note about getRaw() * Suppression on lazily assigned field * Change toString() for null players * Fix broken import Co-authored-by: mdashlw <[email protected]> Co-authored-by: Noe <[email protected]> Co-authored-by: Connor Linfoot <[email protected]>
- Loading branch information
1 parent
85feb8b
commit d6f3895
Showing
14 changed files
with
1,019 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
hypixel-api-core/src/main/java/net/hypixel/api/adapters/PlayerTypeAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.hypixel.api.adapters; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonToken; | ||
import com.google.gson.stream.JsonWriter; | ||
import net.hypixel.api.reply.PlayerReply.Player; | ||
|
||
import java.io.IOException; | ||
|
||
public class PlayerTypeAdapter extends TypeAdapter<Player> { | ||
|
||
private final TypeAdapter<JsonElement> defaultAdapter; | ||
|
||
public PlayerTypeAdapter() { | ||
defaultAdapter = new Gson().getAdapter(JsonElement.class); | ||
} | ||
|
||
@Override | ||
public void write(JsonWriter out, Player value) throws IOException { | ||
defaultAdapter.write(out, value.getRaw()); | ||
} | ||
|
||
@Override | ||
public Player read(JsonReader in) throws IOException { | ||
JsonToken type = in.peek(); | ||
if (type == JsonToken.NULL) { | ||
in.nextNull(); | ||
return new Player(null); | ||
} | ||
return new Player(defaultAdapter.read(in)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.