Record Class FileTransferPacket

java.lang.Object
java.lang.Record
net.frozenblock.lib.image_transfer.FileTransferPacket
All Implemented Interfaces:
net.minecraft.network.protocol.common.custom.CustomPacketPayload

public record FileTransferPacket(String transferPath, String fileName, boolean request, byte[] bytes) extends Record implements net.minecraft.network.protocol.common.custom.CustomPacketPayload
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.network.protocol.common.custom.CustomPacketPayload

    net.minecraft.network.protocol.common.custom.CustomPacketPayload.FallbackProvider<B extends net.minecraft.network.FriendlyByteBuf>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>, net.minecraft.network.protocol.common.custom.CustomPacketPayload.TypeAndCodec<B extends net.minecraft.network.FriendlyByteBuf,T extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<FileTransferPacket>
     
    static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,FileTransferPacket>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FileTransferPacket(String transferPath, String fileName, boolean request, byte[] bytes)
    Creates an instance of a FileTransferPacket record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the bytes record component.
    static @NotNull FileTransferPacket
    create(String destPath, @NotNull File file)
     
    static @NotNull FileTransferPacket
    create(@NotNull net.minecraft.network.FriendlyByteBuf buf)
     
    static @NotNull FileTransferPacket
    createRequest(String directory, String fileName)
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the fileName record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the request record component.
    static void
    sendToPlayer(File file, String transferPath, net.minecraft.server.level.ServerPlayer player)
     
    final String
    Returns a string representation of this record class.
    Returns the value of the transferPath record component.
    @NotNull net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload>
     
    void
    write(@NotNull net.minecraft.network.FriendlyByteBuf buf)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • PACKET_TYPE

      public static final net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<FileTransferPacket> PACKET_TYPE
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf,FileTransferPacket> STREAM_CODEC
  • Constructor Details

    • FileTransferPacket

      public FileTransferPacket(String transferPath, String fileName, boolean request, byte[] bytes)
      Creates an instance of a FileTransferPacket record class.
      Parameters:
      transferPath - the value for the transferPath record component
      fileName - the value for the fileName record component
      request - the value for the request record component
      bytes - the value for the bytes record component
  • Method Details

    • create

      @NotNull public static @NotNull FileTransferPacket create(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf)
    • create

      @NotNull public static @NotNull FileTransferPacket create(String destPath, @NotNull @NotNull File file) throws IOException
      Throws:
      IOException
    • createRequest

      @NotNull public static @NotNull FileTransferPacket createRequest(String directory, String fileName)
    • sendToPlayer

      public static void sendToPlayer(File file, String transferPath, net.minecraft.server.level.ServerPlayer player) throws IOException
      Throws:
      IOException
    • write

      public void write(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf)
    • type

      @NotNull public @NotNull net.minecraft.network.protocol.common.custom.CustomPacketPayload.Type<? extends net.minecraft.network.protocol.common.custom.CustomPacketPayload> type()
      Specified by:
      type in interface net.minecraft.network.protocol.common.custom.CustomPacketPayload
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • transferPath

      public String transferPath()
      Returns the value of the transferPath record component.
      Returns:
      the value of the transferPath record component
    • fileName

      public String fileName()
      Returns the value of the fileName record component.
      Returns:
      the value of the fileName record component
    • request

      public boolean request()
      Returns the value of the request record component.
      Returns:
      the value of the request record component
    • bytes

      public byte[] bytes()
      Returns the value of the bytes record component.
      Returns:
      the value of the bytes record component