Class AbstractNetworkInstance

java.lang.Object
io.github.kosmx.emotes.api.proxy.AbstractNetworkInstance
All Implemented Interfaces:
INetworkInstance

public abstract class AbstractNetworkInstance extends Object implements INetworkInstance
Implement this if you want to act as a proxy for EmoteX This has most of the functions implemented as you might want, but you can override any.
  • Constructor Details

    • AbstractNetworkInstance

      public AbstractNetworkInstance()
  • Method Details

    • sendMessage

      public void sendMessage(EmotePacket packet, @Nullable @Nullable UUID target)
      If you want to send byte array

      You can wrap bytes to Netty Unpooled.wrappedBuffer(bytes) or to Minecraft's PacketByteBuf (yarn mappings) / FriendlyByteBuf (official mappings) new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes))

      Parameters:
      packet - bytes to send
      target - target to send message, if null, everyone in the view distance
    • sendMessage

      public void sendMessage(EmotePacket.Builder builder, @Nullable @Nullable UUID target) throws IOException
      Send not prepared message, if you want to modify the message before sending, override this. You can call the super, but if you do, you'll need to override another.

      For example, you want to manipulate the data, before sending, override this, edit the builder, call its super then override sendMessage(EmotePacket, UUID) to send the bytes data

      Specified by:
      sendMessage in interface INetworkInstance
      Parameters:
      builder - EmotePacket builder
      target - target to send message, if null, everyone in the view distance
      Throws:
      IOException - throws IOException if packet writing has failed
    • receiveMessage

      public void receiveMessage(EmotePacket packet)
      Receive message, but you don't know who sent this The bytes data has to contain the identity of the sender INetworkInstance.trustReceivedPlayer() should return true as you don't have your own identifier system as alternative
      Parameters:
      packet - message
    • disconnect

      protected void disconnect()
      When the network instance disconnects...
    • setVersions

      public void setVersions(Map<Byte,Byte> map)
      Default client-side version config, Please call super if you override it.
      Specified by:
      setVersions in interface INetworkInstance
      Parameters:
      map - version/config map
    • getRemoteVersions

      public HashMap<Byte,Byte> getRemoteVersions()
      see INetworkInstance.getRemoteVersions() it is just a default implementation
      Specified by:
      getRemoteVersions in interface INetworkInstance
      Returns:
      maybe null
    • isServerTrackingPlayState

      public boolean isServerTrackingPlayState()
      Description copied from interface: INetworkInstance
      Does the track the emote play state of every player -> true The client has to resend the emote if a new player get close -> false
      Specified by:
      isServerTrackingPlayState in interface INetworkInstance
    • sendC2SConfig

      public void sendC2SConfig(Consumer<EmotePacket.Builder> consumer)
      Description copied from interface: INetworkInstance
      Client is sending config message to server. Vanilla clients will answer to the server configuration phase message. This might get invoked multiple times on the same network instance.
      Specified by:
      sendC2SConfig in interface INetworkInstance