Record Class FileTransferPacket

java.lang.Object
java.lang.Record
net.frozenblock.lib.image_transfer.FileTransferPacket
All Implemented Interfaces:
net.fabricmc.fabric.api.networking.v1.FabricPacket

public record FileTransferPacket(String transferPath, String fileName, boolean request, byte[] bytes) extends Record implements net.fabricmc.fabric.api.networking.v1.FabricPacket
  • Field Details

    • PACKET_TYPE

      public static final net.fabricmc.fabric.api.networking.v1.PacketType<FileTransferPacket> PACKET_TYPE
  • 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)
      Specified by:
      write in interface net.fabricmc.fabric.api.networking.v1.FabricPacket
    • getType

      public net.fabricmc.fabric.api.networking.v1.PacketType<?> getType()
      Specified by:
      getType in interface net.fabricmc.fabric.api.networking.v1.FabricPacket
    • 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