Class PacketHandlers

java.lang.Object
com.viaversion.viaversion.api.protocol.remapper.PacketHandlers
All Implemented Interfaces:
PacketHandler

public abstract class PacketHandlers extends Object implements PacketHandler
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    create(Type<T> type, T value)
    Writes a value.
    final void
    Handles a packet.
    void
    Adds a packet handler.
    void
    Adds a packet handler which will suppress any exceptions thrown by the handler.
    int
     
    <T> void
    map(ValueReader<T> inputReader, ValueWriter<T> outputWriter)
    Maps a type using a basic ValueReader to a ValueWriter.
    <T1, T2> void
    map(ValueTransformer<T1,T2> transformer)
    Maps a type from an old type to a transformed new type based on their input type.
    void
    map(Type<?> oldType, Type<?> newType)
    Reads the first given type and writes the second given type.
    <T> void
    map(Type<T> type)
    Reads and writes the given type.
    <T1, T2> void
    map(Type<T1> oldType, ValueTransformer<T1,T2> transformer)
    Maps a type from an old type to a transformed new type.
    <T1, T2> void
    map(Type<T1> oldType, Type<T2> newType, Function<T1,T2> transformer)
    Maps a type from an old type to a transformed new type.
    void
    read(Type<?> type)
    Reads (and thus removes) the given type.
    protected abstract void
    Registers the handlers for this packet.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.viaversion.viaversion.api.protocol.remapper.PacketHandler

    then
  • Constructor Details

    • PacketHandlers

      protected PacketHandlers()
  • Method Details

    • map

      public <T> void map(Type<T> type)
      Reads and writes the given type.
      Parameters:
      type - type to map
    • map

      public void map(Type<?> oldType, Type<?> newType)
      Reads the first given type and writes the second given type.
      Parameters:
      oldType - old type
      newType - new type
    • map

      public <T1, T2> void map(Type<T1> oldType, Type<T2> newType, Function<T1,T2> transformer)
      Maps a type from an old type to a transformed new type.
      Type Parameters:
      T1 - old value type
      T2 - new value type
      Parameters:
      oldType - old type
      newType - new type
      transformer - transformer to produce the new type
    • map

      public <T1, T2> void map(ValueTransformer<T1,T2> transformer)
      Maps a type from an old type to a transformed new type based on their input type.
      Type Parameters:
      T1 - old value type
      T2 - new value type
      Parameters:
      transformer - transformer to produce the new type
    • map

      public <T1, T2> void map(Type<T1> oldType, ValueTransformer<T1,T2> transformer)
      Maps a type from an old type to a transformed new type.
      Type Parameters:
      T1 - old value type
      T2 - new value type
      Parameters:
      oldType - old type
      transformer - transformer to produce the new type
    • map

      public <T> void map(ValueReader<T> inputReader, ValueWriter<T> outputWriter)
      Maps a type using a basic ValueReader to a ValueWriter.
      Type Parameters:
      T - read/write type
      Parameters:
      inputReader - reader to read with
      outputWriter - writer to write with
    • handler

      public void handler(PacketHandler handler)
      Adds a packet handler.
      Parameters:
      handler - packet handler
    • handlerSoftFail

      public void handlerSoftFail(PacketHandler handler)
      Adds a packet handler which will suppress any exceptions thrown by the handler.
      Parameters:
      handler - packet handler
    • create

      public <T> void create(Type<T> type, T value)
      Writes a value.
      Parameters:
      type - type to write
      value - value to write
    • read

      public void read(Type<?> type)
      Reads (and thus removes) the given type.
      Parameters:
      type - type to read
    • register

      protected abstract void register()
      Registers the handlers for this packet.
    • handle

      public final void handle(PacketWrapper wrapper) throws InformativeException
      Description copied from interface: PacketHandler
      Handles a packet.
      Specified by:
      handle in interface PacketHandler
      Parameters:
      wrapper - packet wrapper
      Throws:
      InformativeException
    • handlersSize

      public int handlersSize()