-
Notifications
You must be signed in to change notification settings - Fork 0
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!
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 aNBTDatabase. 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 aNBTDatabaseAccessServer. -
RemoteNBTDatabaseAccess: Connects to aNBTDatabaseAccessServer. It is possible to pass this into the constructor of aNBTDatabaseAccessServer, which would act as a reverse proxy. This will most commonly be used to execute requests on a remoteNBTDatabasedirectly, rather than starting a second server.
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 aProtocolVersionPacket. - 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.