Skip to content

Connection Module

mega12345mega edited this page Aug 1, 2026 · 4 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 28260, 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.

AuthorizationManager

This interface allows requests to be rejected based on the user sending it. There are several implementations:

  • AllowAuthorizationManager: Allows all requests.
  • PermissionAuthorizationManager: Allows requests based on a PermissionManager.
  • CachedAuthorizationManager: Wraps AuthorizationManagers to cache the AuthorizationCheck objects.

PermissionManager

This interface allows permissions to be granted for use by the PermissionAuthorizationManager. There are two implementations:

  • GlobalPermissionManager: Holds a Set<String> of granted permissions.
  • UserMapPermissionManager: Holds a Set<String> of global permissions along with a Map<UUID, Map<String, Boolean>> of user-specific tweaks.

Clone this wiki locally