Class SimpleChannel


  • public class SimpleChannel
    extends java.lang.Object
    • Field Detail

      • loginPackets

        private java.util.List<java.util.function.Function<java.lang.Boolean,​? extends java.util.List<? extends org.apache.commons.lang3.tuple.Pair<java.lang.String,​?>>>> loginPackets
    • Method Detail

      • networkEventListener

        private void networkEventListener​(NetworkEvent networkEvent)
      • encodeMessage

        public <MSG> int encodeMessage​(MSG message,
                                       PacketBuffer target)
      • toBuffer

        private <MSG> org.apache.commons.lang3.tuple.Pair<PacketBuffer,​java.lang.Integer> toBuffer​(MSG msg)
      • sendToServer

        public <MSG> void sendToServer​(MSG message)
      • isRemotePresent

        public boolean isRemotePresent​(NetworkManager manager)
        Returns true if the channel is present in the given connection.
      • messageBuilder

        public <M> SimpleChannel.MessageBuilder<M> messageBuilder​(java.lang.Class<M> type,
                                                                  int id)
        Build a new MessageBuilder. The type should implement IntSupplier if it is a login packet.
        Type Parameters:
        M - Type of type
        Parameters:
        type - Type of message
        id - id in the indexed codec
        Returns:
        a MessageBuilder
      • messageBuilder

        public <M> SimpleChannel.MessageBuilder<M> messageBuilder​(java.lang.Class<M> type,
                                                                  int id,
                                                                  NetworkDirection direction)
        Build a new MessageBuilder. The type should implement IntSupplier if it is a login packet.
        Type Parameters:
        M - Type of type
        Parameters:
        type - Type of message
        id - id in the indexed codec
        direction - a network direction which will be asserted before any processing of this message occurs. Use to enforce strict sided handling to prevent spoofing.
        Returns:
        a MessageBuilder