Geyser Documentation
repository·master·Indexed 26 days ago
https://github.com/geysermc/geyserGeyser is a proxy that bridges Minecraft: Bedrock Edition and Minecraft: Java Edition, enabling cross-platform play by translating network packets between the two game protocols. This documentation covers server setup, compiling from source, and developing Geyser extensions, including the implementation of custom commands using the Command, CommandExecutor, and CommandSource APIs.
What's inside Geyser
- Geyser is a proxy that bridges the gap between Minecraft: Bedrock Edition and Minecraft: Java Edition. It allows Bedrock Edition users to join Java Edition servers by translating packets between the two different game protocols. Note that because of the nature of protocol translation, some features may not work perfectly.
Compile Geyser from source
masterTo build Geyser from the repository, follow these steps:
- Clone the repository to your local machine.
- Navigate to the Geyser root directory and initialize submodules:
git submodule update --init --recursive - Build the project using Gradle:
./gradlew build - The build artifacts can be found in the
bootstrap/buildfolder.
Set up Geyser
masterTo set up Geyser for your server, follow the official setup guide at https://geysermc.org/wiki/geyser/setup/.Define custom commands in Geyser extensions
masterTo create a new command for your Geyser extension, use the
Command.builder(Extension extension)method. You must specify asourcetype (any class extendingCommandSource, such asGeyserConnection) to ensure the command executor receives the correct type of source.Key configuration options include:
name(String name): The command name.description(String description): A description of the command.permission(String permission): The permission node required to run the command.aliases(List<String> aliases): A list of alternative names for the command.playerOnly(boolean playerOnly): If true, the command can only be executed by players.bedrockOnly(boolean bedrockOnly): If true, the command can only be executed by Bedrock players.executor(CommandExecutor<T> executor): The logic to run when the command is called.
Finally, call
build()to create theCommandinstance.Implement custom commands in Geyser extensions
masterTo add custom commands to a Geyser extension, extend the
GeyserExtensionCommandclass. This class handles the integration with the extension's root command and provides a builder pattern for defining command properties like name, description, permissions, and execution logic.Key requirements:
- The extension must have a non-blank
rootCommand()defined. - You must specify a
sourceType(the class of the object that will be passed to your executor). - You must provide a
CommandExecutorto handle the command logic.
Note: If the
sourceTypeisGeyserConnection, the command is automatically treated asbedrockOnly.- The extension must have a non-blank
Configure command permissions in Geyser standalone mode
masterIn standalone mode, you can manage command access by configuring
PermissionConfiguration. This allows you to define sets of permissions that are granted or denied by default. Use the following keys in your configuration file:defaultPermissions: A set of permission strings that are granted by default.defaultDeniedPermissions: A set of permission strings that are denied by default.
Use Command.Builder to construct commands
masterThe
Command.Builder<T>interface is used to configure and instantiate aCommand. The generic typeTrepresents theCommandSourcetype that will be passed to the command's executor.Method Description source(Class<? extends T> sourceType)Defines the source type (e.g., GeyserConnection.class).name(String name)Sets the command name. description(String description)Sets the command description. permission(String permission)Sets the permission node required. aliases(List<String> aliases)Sets the command aliases. playerOnly(boolean playerOnly)Sets if the command is player-only. bedrockOnly(boolean bedrockOnly)Sets if the command is Bedrock-only. executor(CommandExecutor<T> executor)Sets the command executor. build()Returns the constructed Command.Use the GeyserExtensionCommand.Builder to define commands
masterThe
GeyserExtensionCommand.Builder<T>is used to configure the properties of a new command. Use the following methods to set up your command:source(Class<? extends T> sourceType): Defines the type of the command source (e.g.,GeyserCommandSourceorGeyserConnection).name(String name): The command name.description(String description): The command description.permission(String permission): The permission required to run the command.permission(String permission, TriState defaultValue): Sets the permission and its default state.aliases(List<String> aliases): A list of alternative names for the command.playerOnly(boolean playerOnly): If true, the command can only be run by players.bedrockOnly(boolean bedrockOnly): If true, the command can only be run by Bedrock players.executor(CommandExecutor<T> executor): The logic to run when the command is invoked.executableOnConsole(boolean executableOnConsole): A convenience method; iffalse, it setsplayerOnlytotrue.
Implement CommandExecutor to handle commands in Geyser extensions
masterTo handle command execution within a Geyser extension, implement the
CommandExecutor<T>interface. Theexecutemethod is called when a command is triggered, providing the command source, the command object itself, and the array of arguments passed by the user. The generic typeTmust extendCommandSource.Implement this interface to define custom logic for how your extension responds to specific commands.
Use the CommandSource interface to interact with command executors
masterTheCommandSourceinterface represents an entity capable of receiving commands and messages (such as a player or the server console). When implementing or using command logic, you can use this interface to send messages back to the user, check for permissions, or identify if the source is a specific Bedrock player via theirGeyserConnection.Implement the Command interface
masterThe
Commandinterface represents a registered command in Geyser. When implementing or interacting with a command, the following methods are available:name(): Returns the command name.description(): Returns the command description.permission(): Returns the permission node string.aliases(): Returns an unmodifiable list of aliases.isPlayerOnly(): Returns true if the command is restricted to players.isBedrockOnly(): Returns true if the command is restricted to Bedrock players.
CommandSource API Reference
masterThe
CommandSourceinterface provides the following methods for interacting with the source of a command:String name(): Returns the name of the command source.void sendMessage(String message): Sends a single message to the command source.void sendMessage(String[] messages): Sends an array of messages to the command source.boolean isConsole(): Returnstrueif the source is the server console.@Nullable UUID playerUuid(): Returns the JavaUUIDif the source is a player; otherwise returnsnull.@Nullable GeyserConnection connection(): Returns theGeyserConnectionif the source is a Bedrock player connected to this Geyser instance; otherwise returnsnull.String locale(): Returns the locale of the command source.boolean hasPermission(String permission): Checks if the command source has the specified permission node.