Fix help command (#2604)

* Always pass session to execute() if the sender is a geyser player

* cleanup
This commit is contained in:
Konicai 2021-10-31 01:22:41 -04:00 committed by GitHub
parent eb211884de
commit 1929a5be83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 37 deletions

View file

@ -53,28 +53,26 @@ public class GeyserSpongeCommandExecutor extends CommandExecutor implements Comm
@Override
public CommandResult process(CommandSource source, String arguments) {
CommandSender commandSender = new SpongeCommandSender(source);
GeyserSession session = getGeyserSession(commandSender);
String[] args = arguments.split(" ");
if (args.length > 0) {
GeyserCommand command = getCommand(args[0]);
if (command != null) {
CommandSender commandSender = new SpongeCommandSender(source);
if (!source.hasPermission(command.getPermission())) {
// Not ideal to use log here but we dont get a session
source.sendMessage(Text.of(ChatColor.RED + LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.permission_fail")));
return CommandResult.success();
}
GeyserSession session = null;
if (command.isBedrockOnly()) {
session = getGeyserSession(commandSender);
if (session == null) {
source.sendMessage(Text.of(ChatColor.RED + LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.bedrock_only")));
return CommandResult.success();
}
if (command.isBedrockOnly() && session == null) {
source.sendMessage(Text.of(ChatColor.RED + LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.bedrock_only")));
return CommandResult.success();
}
getCommand(args[0]).execute(session, commandSender, args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0]);
}
} else {
getCommand("help").execute(null, new SpongeCommandSender(source), new String[0]);
getCommand("help").execute(session, commandSender, new String[0]);
}
return CommandResult.success();
}