+ * Command source types can be anything that extend
+ * {@link CommandSource}, such as {@link GeyserConnection}.
+ * This will guarantee that the source used in the executor
+ * is an instance of this source.
+ *
+ * @param sourceType the source type
+ * @return the builder
+ */
+ Builder
+ * This is the first line that will be displayed.
+ *
+ * @return the primary MOTD shown to Bedrock players.
+ */
+ String primaryMotd();
+
+ /**
+ * Gets the secondary MOTD shown to Bedrock players if a ping passthrough setting is not enabled.
+ *
+ * This is the second line that will be displayed.
+ *
+ * @return the secondary MOTD shown to Bedrock players.
+ */
+ String secondaryMotd();
+
+ /**
+ * Gets the server name that is sent to Bedrock clients.
+ *
+ * @return the server sent to Bedrock clients
+ */
+ String serverName();
+}
diff --git a/api/base/src/main/java/org/geysermc/api/session/Connection.java b/api/geyser/src/main/java/org/geysermc/geyser/api/network/RemoteServer.java
similarity index 61%
rename from api/base/src/main/java/org/geysermc/api/session/Connection.java
rename to api/geyser/src/main/java/org/geysermc/geyser/api/network/RemoteServer.java
index 3e997912b4a..8ac5d8a03ad 100644
--- a/api/base/src/main/java/org/geysermc/api/session/Connection.java
+++ b/api/geyser/src/main/java/org/geysermc/geyser/api/network/RemoteServer.java
@@ -23,46 +23,48 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.api.session;
+package org.geysermc.geyser.api.network;
import org.checkerframework.checker.nullness.qual.NonNull;
-import org.checkerframework.common.value.qual.IntRange;
-
-import java.util.UUID;
/**
- * Represents a player connection.
+ * Represents the Java server that Geyser is connecting to.
*/
-@NonNull
-public interface Connection {
+public interface RemoteServer {
+
+ /**
+ * Gets the IP address of the remote server.
+ *
+ * @return the IP address of the remote server
+ */
+ String address();
+
/**
- * Gets the name of the connection.
+ * Gets the port of the remote server.
*
- * @return the name of the connection
+ * @return the port of the remote server
*/
- String name();
+ int port();
/**
- * Gets the {@link UUID} of the connection.
+ * Gets the protocol version of the remote server.
*
- * @return the UUID of the connection
+ * @return the protocol version of the remote server
*/
- UUID uuid();
+ int protocolVersion();
/**
- * Gets the XUID of the connection.
+ * Gets the Minecraft version of the remote server.
*
- * @return the XUID of the connection
+ * @return the Minecraft version of the remote server
*/
- String xuid();
+ String minecraftVersion();
/**
- * Transfer the connection to a server. A Bedrock player can successfully transfer to the same server they are
- * currently playing on.
+ * Gets the {@link AuthType} required by the remote server.
*
- * @param address The address of the server
- * @param port The port of the server
- * @return true if the transfer was a success
+ * @return the auth type required by the remote server
*/
- boolean transfer(@NonNull String address, @IntRange(from = 0, to = 65535) int port);
+ @NonNull
+ AuthType authType();
}
diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/util/TriState.java b/api/geyser/src/main/java/org/geysermc/geyser/api/util/TriState.java
new file mode 100644
index 00000000000..457a38e32e2
--- /dev/null
+++ b/api/geyser/src/main/java/org/geysermc/geyser/api/util/TriState.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.geyser.api.util;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * This is a way to represent a boolean, but with a non set value added.
+ * This class was inspired by adventure's version https://github.com/KyoriPowered/adventure/blob/main/4/api/src/main/java/net/kyori/adventure/util/TriState.java
+ */
+public enum TriState {
+ /**
+ * Describes a value that is not set, null, or not present.
+ */
+ NOT_SET,
+
+ /**
+ * Describes a true value.
+ */
+ TRUE,
+
+ /**
+ * Describes a false value.
+ */
+ FALSE;
+
+ /**
+ * Converts the TriState to a boolean.
+ *
+ * @return the boolean value of the TriState
+ */
+ public @Nullable Boolean toBoolean() {
+ return switch (this) {
+ case TRUE -> true;
+ case FALSE -> false;
+ default -> null;
+ };
+ }
+
+ /**
+ * Creates a TriState from a boolean.
+ *
+ * @param value the Boolean value
+ * @return the created TriState
+ */
+ public static @NonNull TriState fromBoolean(@Nullable Boolean value) {
+ return value == null ? NOT_SET : fromBoolean(value.booleanValue());
+ }
+
+ /**
+ * Creates a TriState from a primitive boolean.
+ *
+ * @param value the boolean value
+ * @return the created TriState
+ */
+ public @NonNull static TriState fromBoolean(boolean value) {
+ return value ? TRUE : FALSE;
+ }
+}
diff --git a/api/pom.xml b/api/pom.xml
deleted file mode 100644
index 9b4816954ec..00000000000
--- a/api/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
+ * This event is mapped to the existence of Brigadier on the server.
+ */
+public class ServerDefineCommandsEvent extends ConnectionEvent implements Cancellable {
+ private final Set extends CommandInfo> commands;
+ private boolean cancelled;
+
+ public ServerDefineCommandsEvent(@NonNull GeyserConnection connection, @NonNull Set extends CommandInfo> commands) {
+ super(connection);
+ this.commands = commands;
+ }
+
+ /**
+ * A collection of commands sent from the server. Any element in this collection can be removed, but no element can
+ * be added.
+ *
+ * @return a collection of the commands sent over
+ */
+ @NonNull
+ public Set extends CommandInfo> commands() {
+ return this.commands;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return this.cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+
+ public interface CommandInfo {
+ /**
+ * Gets the name of the command.
+ *
+ * @return the name of the command
+ */
+ String name();
+
+ /**
+ * Gets the description of the command.
+ *
+ * @return the description of the command
+ */
+ String description();
+ }
+}
diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/event/lifecycle/GeyserDefineCommandsEvent.java b/api/geyser/src/main/java/org/geysermc/geyser/api/event/lifecycle/GeyserDefineCommandsEvent.java
new file mode 100644
index 00000000000..77d5efa658e
--- /dev/null
+++ b/api/geyser/src/main/java/org/geysermc/geyser/api/event/lifecycle/GeyserDefineCommandsEvent.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.geyser.api.event.lifecycle;
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.geysermc.event.Event;
+import org.geysermc.geyser.api.command.Command;
+
+import java.util.Map;
+
+/**
+ * Called when commands are defined within Geyser.
+ *
+ * This event allows you to register new commands using the {@link #register(Command)}
+ * method and retrieve the default commands defined.
+ */
+public interface GeyserDefineCommandsEvent extends Event {
+
+ /**
+ * Registers the given {@link Command} into the Geyser
+ * command manager.
+ *
+ * @param command the command to register
+ */
+ void register(@NonNull Command command);
+
+ /**
+ * Gets all the registered built-in {@link Command}s.
+ *
+ * @return all the registered built-in commands
+ */
+ @NonNull
+ Map
+ *
+ *
+ * The reason is that {@link MinecraftServer#getPort()} doesn't return the LAN port if it's the integrated server,
+ * and changing the behavior of this method via a mixin should be avoided as it could have unexpected consequences.
+ *
+ * @return The server port.
+ */
+ int geyser$getServerPort();
+}
diff --git a/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/FabricCommandSender.java b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/FabricCommandSender.java
new file mode 100644
index 00000000000..5973e04f178
--- /dev/null
+++ b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/FabricCommandSender.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.geyser.platform.fabric.command;
+
+import me.lucko.fabric.api.permissions.v0.Permissions;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.minecraft.commands.CommandSourceStack;
+import net.minecraft.network.chat.Component;
+import net.minecraft.server.level.ServerPlayer;
+import org.geysermc.geyser.GeyserImpl;
+import org.geysermc.geyser.command.GeyserCommandSource;
+import org.geysermc.geyser.text.ChatColor;
+
+import javax.annotation.Nonnull;
+
+public class FabricCommandSender implements GeyserCommandSource {
+
+ private final CommandSourceStack source;
+
+ public FabricCommandSender(CommandSourceStack source) {
+ this.source = source;
+ }
+
+ @Override
+ public String name() {
+ return source.getTextName();
+ }
+
+ @Override
+ public void sendMessage(@Nonnull String message) {
+ if (source.getEntity() instanceof ServerPlayer) {
+ ((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false);
+ } else {
+ GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET));
+ }
+ }
+
+ @Override
+ public void sendMessage(net.kyori.adventure.text.Component message) {
+ if (source.getEntity() instanceof ServerPlayer player) {
+ String decoded = GsonComponentSerializer.gson().serialize(message);
+ player.displayClientMessage(Component.Serializer.fromJson(decoded), false);
+ return;
+ }
+ GeyserCommandSource.super.sendMessage(message);
+ }
+
+ @Override
+ public boolean isConsole() {
+ return !(source.getEntity() instanceof ServerPlayer);
+ }
+
+ @Override
+ public boolean hasPermission(String permission) {
+ return Permissions.check(source, permission);
+ }
+}
diff --git a/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/GeyserFabricCommandExecutor.java b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/GeyserFabricCommandExecutor.java
new file mode 100644
index 00000000000..7600e41361f
--- /dev/null
+++ b/bootstrap/fabric/src/main/java/org/geysermc/geyser/platform/fabric/command/GeyserFabricCommandExecutor.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.geyser.platform.fabric.command;
+
+import com.mojang.brigadier.Command;
+import com.mojang.brigadier.context.CommandContext;
+import me.lucko.fabric.api.permissions.v0.Permissions;
+import net.minecraft.commands.CommandSourceStack;
+import org.geysermc.geyser.GeyserImpl;
+import org.geysermc.geyser.command.GeyserCommand;
+import org.geysermc.geyser.command.GeyserCommandExecutor;
+import org.geysermc.geyser.platform.fabric.GeyserFabricMod;
+import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.text.ChatColor;
+import org.geysermc.geyser.text.GeyserLocale;
+
+import java.util.Collections;
+
+public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command