Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.
Pascal edited this page Jun 30, 2022 · 5 revisions

SquareTree

SquareTree is a Java library to create packet traffic of customized nodes and modules at the server-side. The application consists of several parts.

image

Custom packet

//require packet link
//the type must not be used in any other packet
@PacketLink(type = 3000)
public class PacketChatMessage extends Packet<EmptyResponse> {

  private String message;

  //it require empty constructor
  public PacketChatMessage() {

  }

  public PacketChatMessage(String message) {
    this.message = message;
  }

  @Override
  public void serialize(DataSerializer serializer) {
    serializer.writeString(message, StandardCharsets.UTF_8);
  }

  @Override
  public void deserialize(DataDeserializer deserializer) {
    message = deserializer.readString(StandardCharsets.UTF_8);
  }

  @Override
  public EmptyResponse getDefaultResponse() {
    return new EmptyResponse();
  }
}

Clone this wiki locally