Skip to content

Connection Module

mega12345mega edited this page Jul 26, 2025 · 2 revisions

This module allows you to host and connect to a server. The server forwards requests to a NBTDatabaseAccess. You can browse entries in a server directly by entering the server's address into a browser (ie. Chrome, Firefox, etc.).

The standard port is 25560, which should be used whenever possible!

NBTDatabaseAccess

This interface allows you to send requests to an NBTDatabase. See the File Module for an example of the types of requests that can be made. Instead of returning values directly, all of the methods return a CompletableFuture. There are two implementations:

  • LocalNBTDatabaseAccess: Simply wraps a NBTDatabase. Note that requests are still executed on a different thread, so this could be useful for async requests. This will most commonly be used for the constructor of a NBTDatabaseAccessServer.
  • RemoteNBTDatabaseAccess: Connects to a NBTDatabaseAccessServer. It is possible to pass this into the constructor of a NBTDatabaseAccessServer, which would act as a reverse proxy. This will most commonly be used to execute requests on a remote NBTDatabase directly, rather than starting a second server.

NBTDatabaseAccessServer

This allows other people to connect to your database. (Note that you will need to do the normal port forwarding stuff.) The server accepts three different protocols:

  • NBT Protocol: Indicated with the magic bytes 0x6E, 0x62, and 0x74 ("nbt" in ASCII). This is the protocol used internally by the RemoteNBTDatabaseAccess. The first packet must be a ProtocolVersionPacket.
  • HTTP (not upgraded): The server will return a website that only allows reading entries, not writing.
  • WebSocket (upgraded from HTTP): This allows for NBT Protocol over WebSocket. The magic bytes shouldn't be sent. Each WebSocket message is one NBT Protocol packet.

Clone this wiki locally