Class BetterStatsServerPlayNetworkHandler
java.lang.Object
io.github.thecsdev.betterstats.network.BetterStatsServerPlayNetworkHandler
Better statistics screen server play network handler.
Keeps track of
Keeps track of
ServerPlayerEntity
data that is related to BetterStats
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final net.minecraft.util.Identifier
The uniqueIdentifier
for obtaining an instance of this network handler for a given player entity, viaEntityHooks.getCustomData(Entity)
.boolean
When set totrue
, this should never be switched back tofalse
.
Indicates whether or not the associated player hasBetterStats
installed.long
The timestamp at which the last live stats update was performed.boolean
When set to true, theBetterStatsNetwork
will automatically update the client on their stats changes, live.boolean
Theplayer
's preference on having their statistics shared with third-party sources such as other players. -
Method Summary
Modifier and TypeMethodDescriptionfinal net.minecraft.server.network.ServerPlayerEntity
static final BetterStatsServerPlayNetworkHandler
of
(net.minecraft.server.network.ServerPlayerEntity player) Returns an instance ofBetterStatsServerPlayNetworkHandler
for a givenServerPlayerEntity
.final void
onIHaveBss
(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles theplayer
letting this server know they haveBetterStats
installed.final void
onMcbsRequest
(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handlesplayer
's requests for MCBS files.final void
Handles theplayer
joining event.final void
onPreferences
(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles theplayer
's preference changes for things like the "live hud stats updates" feature.final void
Tells theplayer
that this server hasBetterStats
installed.final boolean
Makes an attempt to send a live statistics update to theplayer
.final void
sendNullPlayerMcbs
(String playerName) Sends an indicator that the MCBS for a given player is "null".final boolean
sendPlayerMcbs
(net.minecraft.server.network.ServerPlayerEntity targetPlayer, boolean force) Sends an MCBS file of a givenServerPlayerEntity
, to theplayer
.
-
Field Details
-
CUSTOM_DATA_ID
public static final net.minecraft.util.Identifier CUSTOM_DATA_IDThe uniqueIdentifier
for obtaining an instance of this network handler for a given player entity, viaEntityHooks.getCustomData(Entity)
. -
hasBssInstalled
public boolean hasBssInstalledWhen set totrue
, this should never be switched back tofalse
.
Indicates whether or not the associated player hasBetterStats
installed. -
netPref_enableLiveStats
public boolean netPref_enableLiveStatsWhen set to true, theBetterStatsNetwork
will automatically update the client on their stats changes, live. -
liveStatsLastUpdate
public long liveStatsLastUpdateThe timestamp at which the last live stats update was performed. Used to avoid packet spam. -
netPref_statsSharingConsent
public boolean netPref_statsSharingConsentTheplayer
's preference on having their statistics shared with third-party sources such as other players.
-
-
Method Details
-
getPlayer
public final net.minecraft.server.network.ServerPlayerEntity getPlayer() -
onPlayerConnected
public final void onPlayerConnected()Handles theplayer
joining event. -
onIHaveBss
public final void onIHaveBss(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles theplayer
letting this server know they haveBetterStats
installed. -
onPreferences
public final void onPreferences(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles theplayer
's preference changes for things like the "live hud stats updates" feature. -
onMcbsRequest
public final void onMcbsRequest(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handlesplayer
's requests for MCBS files. -
sendIHaveBss
public final void sendIHaveBss()Tells theplayer
that this server hasBetterStats
installed. -
sendLiveStatsAttepmt
public final boolean sendLiveStatsAttepmt()Makes an attempt to send a live statistics update to theplayer
. The attempt may fail if theplayer
does not haveBetterStats
installed or if this method is being called too frequently. -
sendPlayerMcbs
public final boolean sendPlayerMcbs(net.minecraft.server.network.ServerPlayerEntity targetPlayer, boolean force) throws NullPointerException Sends an MCBS file of a givenServerPlayerEntity
, to theplayer
.- Parameters:
targetPlayer
- TheServerPlayerEntity
whose MCBS is to be sent.force
- Whentrue
, this will ignore theServerPlayerEntity
lack of consent.- Throws:
NullPointerException
-
sendNullPlayerMcbs
Sends an indicator that the MCBS for a given player is "null". The purpose of this is usually to let the client know that a given player's statistics cannot be shared because said player is currently offline.- Throws:
NullPointerException
- See Also:
-
of
public static final BetterStatsServerPlayNetworkHandler of(net.minecraft.server.network.ServerPlayerEntity player) throws NullPointerException Returns an instance ofBetterStatsServerPlayNetworkHandler
for a givenServerPlayerEntity
. Creates one if it doesn't exist yet.- Parameters:
player
- TheServerPlayerEntity
.- Throws:
NullPointerException
-