Class BetterStatsClientPlayNetworkHandler

java.lang.Object
io.github.thecsdev.betterstats.client.network.BetterStatsClientPlayNetworkHandler

@Internal public final class BetterStatsClientPlayNetworkHandler extends Object
Better statistics screen client play network handler.
Keeps track of ClientPlayerEntity data that is related to BetterStats.
  • Field Details

    • CUSTOM_DATA_ID

      public static final net.minecraft.util.Identifier CUSTOM_DATA_ID
      The unique Identifier for obtaining an instance of this network handler for a given player entity, via EntityHooks.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 the OtherClientPlayerStatsProvider from the sessionPlayerStatStorage, creating an instance if it doesn't exist yet.
      Throws:
      NullPointerException
    • onDisconnected

      public final void onDisconnected()
      Handles the player disconnecting from the server.
    • onIHaveBss

      public final void onIHaveBss(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx)
      Handles the server telling the player it has BetterStats installed.
    • onMcbs

      public final void onMcbs(io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetworkReceiver.PacketContext ctx)
      Handles the server sending the player an MCBS file.
    • comms

      public final boolean comms()
      Returns true if BetterStatsClientPlayNetworkHandler is allowed to communicate with the server.
    • sendIHaveBss

      public final boolean sendIHaveBss(boolean forceSend)
      Sends the server a message letting the server know the player has BetterStats 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 to sendPreferences(), except the sent preferences disable everything, and the bssNetworkConsent is fully revoked.
    • sendMcbsRequest

      public final boolean sendMcbsRequest(String playerName)
      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 of BetterStatsClientPlayNetworkHandler from a given ClientPlayerEntity. Creates one if it doesn't exist yet.
      Parameters:
      player - The ClientPlayerEntity.
      Throws:
      NullPointerException
    • getInstance

      @Nullable public static final @Nullable BetterStatsClientPlayNetworkHandler getInstance()
      Returns an instance of BetterStatsClientPlayNetworkHandler for MinecraftClient.player, or null if the client player is also null.