Class PacketRemapper


  • public abstract class PacketRemapper
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PacketRemapper()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      <T> void create​(Type<T> type, T value)
      Writes a value.
      void handler​(PacketHandler handler)
      Adds a packet handler.
      <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 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, java.util.function.Function<T1,​T2> transformer)
      Maps a type from an old type to a transformed new type.
      void map​(Type oldType, Type newType)
      Reads the first given type and writes the second given type.
      void read​(Type type)
      Reads (and thus removes) the given type.
      abstract void registerMap()
      Registers the handlers for this packet.
      void remap​(PacketWrapper packetWrapper)
      Processes a packet wrapper.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PacketRemapper

        protected PacketRemapper()
    • Method Detail

      • map

        public void map​(Type 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,
                                      java.util.function.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
      • 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
      • registerMap

        public abstract void registerMap()
        Registers the handlers for this packet.
      • remap

        public void remap​(PacketWrapper packetWrapper)
                   throws java.lang.Exception
        Processes a packet wrapper.
        Parameters:
        packetWrapper - packet wrapper to remap
        Throws:
        InformativeException - if packet reading or writing fails
        CancelException - if the packet should be cancelled
        java.lang.Exception