Class BetterStatsClientPlayNetworkHandler
java.lang.Object
io.github.thecsdev.betterstats.client.network.BetterStatsClientPlayNetworkHandler
Better statistics screen client play network handler.
Keeps track of
Keeps track of
ClientPlayerEntity
data that is related to BetterStats
.-
Field Summary
Modifier and TypeFieldDescriptionboolean
static final net.minecraft.util.Identifier
The uniqueIdentifier
for obtaining an instance of this network handler for a given player entity, viaEntityHooks.getCustomData(Entity)
.boolean
boolean
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
comms()
Returnstrue
ifBetterStatsClientPlayNetworkHandler
is allowed to communicate with the server.static final @Nullable BetterStatsClientPlayNetworkHandler
Returns an instance ofBetterStatsClientPlayNetworkHandler
forMinecraftClient.player
, ornull
if the client player is alsonull
.final net.minecraft.client.network.ClientPlayerEntity
getSessionPlayerStats
(String otherPlayerName) Obtains theOtherClientPlayerStatsProvider
from thesessionPlayerStatStorage
, creating an instance if it doesn't exist yet.static final BetterStatsClientPlayNetworkHandler
of
(net.minecraft.client.network.ClientPlayerEntity player) Returns an instance ofBetterStatsClientPlayNetworkHandler
from a givenClientPlayerEntity
.final void
Handles theplayer
disconnecting from the server.final void
onIHaveBss
(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles the server telling theplayer
it hasBetterStats
installed.final void
onMcbs
(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles the server sending theplayer
an MCBS file.final boolean
Similar tosendPreferences()
, except the sent preferences disable everything, and thebssNetworkConsent
is fully revoked.final boolean
sendIHaveBss
(boolean forceSend) Sends the server a message letting the server know theplayer
hasBetterStats
installed.final boolean
sendMcbsRequest
(String playerName) Sends a third-party player statistics request to the server.final boolean
Sends the player's preferences to the server, such as for example the "enable live stats" preference.
-
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)
. -
serverHasBss
public boolean serverHasBss -
bssNetworkConsent
public boolean bssNetworkConsent -
netPref_enableLiveStats
public boolean netPref_enableLiveStats
-
-
Method Details
-
getPlayer
public final net.minecraft.client.network.ClientPlayerEntity getPlayer() -
getSessionPlayerStats
public final OtherClientPlayerStatsProvider getSessionPlayerStats(String otherPlayerName) throws NullPointerException Obtains theOtherClientPlayerStatsProvider
from thesessionPlayerStatStorage
, creating an instance if it doesn't exist yet.- Throws:
NullPointerException
-
onDisconnected
public final void onDisconnected()Handles theplayer
disconnecting from the server. -
onIHaveBss
public final void onIHaveBss(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles the server telling theplayer
it hasBetterStats
installed. -
onMcbs
public final void onMcbs(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx) Handles the server sending theplayer
an MCBS file. -
comms
public final boolean comms()Returnstrue
ifBetterStatsClientPlayNetworkHandler
is allowed to communicate with the server. -
sendIHaveBss
public final boolean sendIHaveBss(boolean forceSend) Sends the server a message letting the server know theplayer
hasBetterStats
installed. -
sendPreferences
public final boolean sendPreferences()Sends the player's preferences to the server, such as for example the "enable live stats" preference. -
sendAndRevokePreferences
public final boolean sendAndRevokePreferences()Similar tosendPreferences()
, except the sent preferences disable everything, and thebssNetworkConsent
is fully revoked. -
sendMcbsRequest
Sends a third-party player statistics request to the server. The server should respond by sending back the given player's statistics, if said player consents to this.- Parameters:
playerName
- The name of the other player whose statistics this client wishes to see.
-
of
public static final BetterStatsClientPlayNetworkHandler of(net.minecraft.client.network.ClientPlayerEntity player) throws NullPointerException Returns an instance ofBetterStatsClientPlayNetworkHandler
from a givenClientPlayerEntity
. Creates one if it doesn't exist yet.- Parameters:
player
- TheClientPlayerEntity
.- Throws:
NullPointerException
-
getInstance
Returns an instance ofBetterStatsClientPlayNetworkHandler
forMinecraftClient.player
, ornull
if the client player is alsonull
.
-