-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
232 additions
and
56 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.scrayos.xenos.client.data | ||
|
||
import net.scrayos.xenos.client.utility.toImage | ||
import scrayosnet.xenos.ProfileOuterClass.CapeResponse | ||
import java.awt.image.BufferedImage | ||
import java.time.Instant | ||
|
||
/** | ||
* A [CapeInfo] is the response to the request of the cape texture of a specific player. The result includes the | ||
* moment when this information was freshly retrieved from Mojang and may be stale or outdated, if Xenos is configured | ||
* to return those values. The texture is optimized for fast retrieval and all data is stored in memory. | ||
*/ | ||
data class CapeInfo( | ||
/** The loaded texture of the cape that was requested for the supplied player. */ | ||
val texture: BufferedImage, | ||
/** The moment when this data was originally fetched from the MojangAPI and when it was considered fresh. */ | ||
val retrievedAt: Instant, | ||
) | ||
|
||
/** | ||
* Converts the raw response from gRPC into a more user-friendly data class, that encapsulates the contained data in an | ||
* easy-to-use format. No information is dropped or lost through the conversion. The wrapped response drops all | ||
* information that is related to the gRPC origin and is therefore independent of the client implementation, that was | ||
* used to retrieve the data from Xenos. | ||
*/ | ||
internal fun CapeResponse.toResult(): CapeInfo { | ||
return CapeInfo( | ||
bytes.toImage(), | ||
Instant.ofEpochSecond(timestamp), | ||
) | ||
} |
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
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
Oops, something went wrong.