Extensions have their own command

This commit is contained in:
Camotoy 2022-07-10 20:58:48 -04:00
parent 897c4dcfec
commit 83ba6b5ab5
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
16 changed files with 101 additions and 116 deletions

View File

@ -33,7 +33,9 @@ import org.geysermc.geyser.api.event.connection.ConnectionEvent;
import java.util.Set;
/**
* Called when the downstream server defines the commands available on the server.
* Called when the Java server defines the commands available on the server.
* <br>
* 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;

View File

@ -1,42 +0,0 @@
/*
* 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.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandManager;
import org.geysermc.geyser.api.event.Event;
import java.util.Map;
/**
* Called when commands are defined within Geyser.
*
* @param commandManager the command manager
* @param commands an immutable view of the default commands
*/
public record GeyserDefineCommandsEvent(@NonNull CommandManager commandManager, @NonNull Map<String, Command> commands) implements Event {
}

View File

@ -86,7 +86,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
InetSocketAddress javaAddr = listener.getHost();
// By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
@ -109,7 +109,7 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
return;
}
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) {
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && getProxy().getPluginManager().getPlugin("floodgate") == null) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
return;
} else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate") != null) {
@ -134,7 +134,8 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
this.geyserBungeePingPassthrough = new GeyserBungeePingPassthrough(getProxy());
}
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor(geyser));
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor("geyser", geyser, geyserCommandManager.getCommands()));
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor("geyserext", geyser, geyserCommandManager.commands()));
}
@Override

View File

@ -37,14 +37,15 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
public class GeyserBungeeCommandExecutor extends Command implements TabExecutor {
private final GeyserCommandExecutor commandExecutor;
public GeyserBungeeCommandExecutor(GeyserImpl geyser) {
super("geyser");
public GeyserBungeeCommandExecutor(String name, GeyserImpl geyser, Map<String, org.geysermc.geyser.api.command.Command> commands) {
super(name);
this.commandExecutor = new GeyserCommandExecutor(geyser);
this.commandExecutor = new GeyserCommandExecutor(geyser, commands);
}
@Override

View File

@ -170,8 +170,8 @@ public class GeyserSpigotInjector extends GeyserInjector {
*/
private void workAroundWeirdBug(GeyserBootstrap bootstrap) {
MinecraftProtocol protocol = new MinecraftProtocol();
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().getAddress(),
bootstrap.getGeyserConfig().getRemote().getPort(), this.serverSocketAddress,
LocalSession session = new LocalSession(bootstrap.getGeyserConfig().getRemote().address(),
bootstrap.getGeyserConfig().getRemote().port(), this.serverSocketAddress,
InetAddress.getLoopbackAddress().getHostAddress(), protocol, protocol.createHelper());
session.connect();
}

View File

@ -43,7 +43,6 @@ import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.adapters.spigot.SpigotAdapters;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.network.AuthType;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.configuration.GeyserConfiguration;
import org.geysermc.geyser.dump.BootstrapDumpInfo;
@ -125,7 +124,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
}
// By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces
if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
@ -148,7 +147,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
return;
}
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) {
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && Bukkit.getPluginManager().getPlugin("floodgate") == null) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
this.getPluginLoader().disablePlugin(this);
return;
@ -249,8 +248,10 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
geyserLogger.debug("Using default world manager: " + this.geyserWorldManager.getClass());
}
PluginCommand pluginCommand = this.getCommand("geyser");
pluginCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser));
PluginCommand geyserCommand = this.getCommand("geyser");
geyserCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands()));
PluginCommand geyserExtCommand = this.getCommand("geyserext");
geyserExtCommand.setExecutor(new GeyserSpigotCommandExecutor(geyser, geyserCommandManager.getCommands()));
if (!INITIALIZED) {
// Register permissions so they appear in, for example, LuckPerms' UI
@ -277,7 +278,7 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
boolean brigadierSupported = CommodoreProvider.isSupported();
geyserLogger.debug("Brigadier supported? " + brigadierSupported);
if (brigadierSupported) {
GeyserBrigadierSupport.loadBrigadier(this, pluginCommand);
GeyserBrigadierSupport.loadBrigadier(this, geyserCommand);
}
// Check to ensure the current setup can support the protocol version Geyser uses

View File

@ -38,11 +38,12 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class GeyserSpigotCommandExecutor extends GeyserCommandExecutor implements TabExecutor {
public GeyserSpigotCommandExecutor(GeyserImpl geyser) {
super(geyser);
public GeyserSpigotCommandExecutor(GeyserImpl geyser, Map<String, org.geysermc.geyser.api.command.Command> commands) {
super(geyser, commands);
}
@Override

View File

@ -8,4 +8,7 @@ api-version: 1.13
commands:
geyser:
description: The main command for Geyser.
usage: /geyser <subcommand>
usage: /geyser <subcommand>
geyserext:
description: The command any extensions can register to.
usage: /geyserext <subcommand>

View File

@ -99,14 +99,14 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
// Don't change the ip if its listening on all interfaces
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true);
geyserConfig.getRemote().setPort(javaAddr.getPort());
}
}
if (geyserConfig.getBedrock().isCloneRemotePort()) {
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort());
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().port());
}
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
@ -121,7 +121,8 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser);
this.geyserCommandManager.init();
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser), "geyser");
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser, geyserCommandManager.getCommands()), "geyser");
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser, geyserCommandManager.commands()), "geyserext");
}
@Override

View File

@ -26,6 +26,7 @@
package org.geysermc.geyser.platform.sponge.command;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandExecutor;
import org.geysermc.geyser.command.GeyserCommandSource;
@ -40,15 +41,12 @@ import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.*;
public class GeyserSpongeCommandExecutor extends GeyserCommandExecutor implements CommandCallable {
public GeyserSpongeCommandExecutor(GeyserImpl geyser) {
super(geyser);
public GeyserSpongeCommandExecutor(GeyserImpl geyser, Map<String, Command> commands) {
super(geyser, commands);
}
@Override

View File

@ -102,7 +102,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
// By default this should be localhost but may need to be changed in some circumstances
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) {
this.geyserConfig.setAutoconfiguredRemote(true);
// Don't use localhost if not listening on all interfaces
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
@ -128,7 +128,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
} catch (ClassNotFoundException ignored) {
}
if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && proxyServer.getPluginManager().getPlugin("floodgate").isEmpty()) {
geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " "
+ GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
return;
@ -148,7 +148,8 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
this.geyserCommandManager = new GeyserVelocityCommandManager(geyser);
this.geyserCommandManager.init();
this.commandManager.register("geyser", new GeyserVelocityCommandExecutor(geyser));
this.commandManager.register("geyser", new GeyserVelocityCommandExecutor(geyser, geyserCommandManager.getCommands()));
this.commandManager.register("geyserext", new GeyserVelocityCommandExecutor(geyser, geyserCommandManager.commands()));
if (geyserConfig.isLegacyPingPassthrough()) {
this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(geyser);
} else {

View File

@ -27,6 +27,7 @@ package org.geysermc.geyser.platform.velocity.command;
import com.velocitypowered.api.command.SimpleCommand;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.command.GeyserCommand;
import org.geysermc.geyser.command.GeyserCommandExecutor;
import org.geysermc.geyser.command.GeyserCommandSource;
@ -37,11 +38,12 @@ import org.geysermc.geyser.text.GeyserLocale;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class GeyserVelocityCommandExecutor extends GeyserCommandExecutor implements SimpleCommand {
public GeyserVelocityCommandExecutor(GeyserImpl geyser) {
super(geyser);
public GeyserVelocityCommandExecutor(GeyserImpl geyser, Map<String, Command> commands) {
super(geyser, commands);
}
@Override

View File

@ -37,15 +37,16 @@ import java.util.List;
import java.util.Map;
/**
* Represents helper functions for listening to {@code /geyser} commands.
* Represents helper functions for listening to {@code /geyser} or {@code /geyserext} commands.
*/
@AllArgsConstructor
public class GeyserCommandExecutor {
protected final GeyserImpl geyser;
private final Map<String, Command> commands;
public GeyserCommand getCommand(String label) {
return (GeyserCommand) geyser.commandManager().commands().get(label);
return (GeyserCommand) commands.get(label);
}
@Nullable
@ -78,7 +79,6 @@ public class GeyserCommandExecutor {
}
List<String> availableCommands = new ArrayList<>();
Map<String, Command> commands = geyser.commandManager().getCommands();
// Only show commands they have permission to use
for (Map.Entry<String, Command> entry : commands.entrySet()) {

View File

@ -25,6 +25,7 @@
package org.geysermc.geyser.command;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -34,7 +35,6 @@ import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.command.CommandExecutor;
import org.geysermc.geyser.api.command.CommandManager;
import org.geysermc.geyser.api.command.CommandSource;
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
import org.geysermc.geyser.command.defaults.*;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale;
@ -42,91 +42,104 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@RequiredArgsConstructor
public abstract class GeyserCommandManager extends CommandManager {
@Getter
private final Map<String, Command> commands = new HashMap<>();
private final Map<String, Command> commands = new Object2ObjectOpenHashMap<>(12);
private final Map<String, Command> extensionCommands = new Object2ObjectOpenHashMap<>(0);
private final GeyserImpl geyser;
public void init() {
register(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help"));
register(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
register(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
register(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
register(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
register(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version"));
register(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
register(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
register(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
register(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
register(new ExtensionsCommand(geyser, "extensions", "geyser.commands.extensions.desc", "geyser.command.extensions"));
registerBuiltInCommand(new HelpCommand(geyser, "help", "geyser.commands.help.desc", "geyser.command.help", "geyser", commands));
registerBuiltInCommand(new ListCommand(geyser, "list", "geyser.commands.list.desc", "geyser.command.list"));
registerBuiltInCommand(new ReloadCommand(geyser, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
registerBuiltInCommand(new OffhandCommand(geyser, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
registerBuiltInCommand(new DumpCommand(geyser, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
registerBuiltInCommand(new VersionCommand(geyser, "version", "geyser.commands.version.desc", "geyser.command.version"));
registerBuiltInCommand(new SettingsCommand(geyser, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
registerBuiltInCommand(new StatisticsCommand(geyser, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
registerBuiltInCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
registerBuiltInCommand(new AdvancedTooltipsCommand("tooltips", "geyser.commands.advancedtooltips.desc", "geyser.command.tooltips"));
if (GeyserImpl.getInstance().getPlatformType() == PlatformType.STANDALONE) {
register(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
registerBuiltInCommand(new StopCommand(geyser, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
}
this.geyser.eventBus().fire(new GeyserDefineCommandsEvent(this, this.commands()));
register(new HelpCommand(geyser, "help", "geyser.commands.exthelp.desc", "geyser.command.exthelp", "geyserext", extensionCommands));
}
/**
* For internal Geyser commands
*/
public void registerBuiltInCommand(GeyserCommand command) {
register(command, this.commands);
}
@Override
public void register(@NonNull Command command) {
this.commands.put(command.name(), command);
this.geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", command.name()));
register(command, this.extensionCommands);
}
private void register(Command command, Map<String, Command> commands) {
commands.put(command.name(), command);
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", command.name()));
if (command.aliases().isEmpty()) {
return;
}
for (String alias : command.aliases()) {
this.commands.put(alias, command);
commands.put(alias, command);
}
}
@Override
public void unregister(@NonNull Command command) {
this.commands.remove(command.name(), command);
this.extensionCommands.remove(command.name(), command);
if (command.aliases().isEmpty()) {
return;
}
for (String alias : command.aliases()) {
this.commands.remove(alias, command);
this.extensionCommands.remove(alias, command);
}
}
@NotNull
@Override
public Map<String, Command> commands() {
return Collections.unmodifiableMap(this.commands);
return Collections.unmodifiableMap(this.extensionCommands);
}
public void runCommand(GeyserCommandSource sender, String command) {
if (!command.startsWith("geyser "))
return;
public boolean runCommand(GeyserCommandSource sender, String command) {
boolean extensionCommand = command.startsWith("geyserext ");
if (!command.startsWith("geyser ") && !extensionCommand) {
return false;
}
command = command.trim().replace("geyser ", "");
command = command.trim().replace(extensionCommand ? "geyserext " : "geyser ", "");
String label;
String[] args;
if (!command.contains(" ")) {
label = command.toLowerCase();
label = command.toLowerCase(Locale.ROOT);
args = new String[0];
} else {
label = command.substring(0, command.indexOf(" ")).toLowerCase();
label = command.substring(0, command.indexOf(" ")).toLowerCase(Locale.ROOT);
String argLine = command.substring(command.indexOf(" ") + 1);
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
}
Command cmd = commands.get(label);
Command cmd = (extensionCommand ? this.extensionCommands : this.commands).get(label);
if (cmd == null) {
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.invalid"));
return;
return false;
}
if (cmd instanceof GeyserCommand) {
@ -140,6 +153,8 @@ public abstract class GeyserCommandManager extends CommandManager {
}
}
}
return true;
}
/**

View File

@ -39,10 +39,15 @@ import java.util.Map;
public class HelpCommand extends GeyserCommand {
private final GeyserImpl geyser;
private final String baseCommand;
private final Map<String, Command> commands;
public HelpCommand(GeyserImpl geyser, String name, String description, String permission) {
public HelpCommand(GeyserImpl geyser, String name, String description, String permission,
String baseCommand, Map<String, Command> commands) {
super(name, description, permission);
this.geyser = geyser;
this.baseCommand = baseCommand;
this.commands = commands;
this.setAliases(Collections.singletonList("?"));
}
@ -61,8 +66,7 @@ public class HelpCommand extends GeyserCommand {
String header = GeyserLocale.getPlayerLocaleString("geyser.commands.help.header", sender.locale(), page, maxPage);
sender.sendMessage(header);
Map<String, Command> cmds = geyser.commandManager().getCommands();
for (Map.Entry<String, Command> entry : cmds.entrySet()) {
for (Map.Entry<String, Command> entry : commands.entrySet()) {
Command cmd = entry.getValue();
// Standalone hack-in since it doesn't have a concept of permissions
@ -72,7 +76,7 @@ public class HelpCommand extends GeyserCommand {
continue;
}
sender.sendMessage(ChatColor.YELLOW + "/geyser " + entry.getKey() + ChatColor.WHITE + ": " +
sender.sendMessage(ChatColor.YELLOW + "/" + baseCommand + " " + entry.getKey() + ChatColor.WHITE + ": " +
GeyserLocale.getPlayerLocaleString(cmd.description(), sender.locale()));
}
}

View File

@ -28,7 +28,6 @@ package org.geysermc.geyser.translator.protocol.bedrock;
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
import org.geysermc.common.PlatformType;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.GeyserCommandManager;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
@ -40,10 +39,8 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
@Override
public void translate(GeyserSession session, CommandRequestPacket packet) {
String command = packet.getCommand().replace("/", "");
GeyserCommandManager commandManager = GeyserImpl.getInstance().commandManager();
if (session.getGeyser().getPlatformType() == PlatformType.STANDALONE && command.trim().startsWith("geyser ") && commandManager.getCommands().containsKey(command.split(" ")[1])) {
commandManager.runCommand(session, command);
} else {
if (!(session.getGeyser().getPlatformType() == PlatformType.STANDALONE
&& GeyserImpl.getInstance().commandManager().runCommand(session, command))) {
String message = packet.getCommand().trim();
if (MessageTranslator.isTooLong(message, session)) {