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

@ -46,26 +46,24 @@ public class GeyserVelocityCommandExecutor extends CommandExecutor implements Si
@Override
public void execute(Invocation invocation) {
CommandSender sender = new VelocityCommandSender(invocation.source());
GeyserSession session = getGeyserSession(sender);
if (invocation.arguments().length > 0) {
GeyserCommand command = getCommand(invocation.arguments()[0]);
if (command != null) {
CommandSender sender = new VelocityCommandSender(invocation.source());
if (!invocation.source().hasPermission(getCommand(invocation.arguments()[0]).getPermission())) {
sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", sender.getLocale()));
return;
}
GeyserSession session = null;
if (command.isBedrockOnly()) {
session = getGeyserSession(sender);
if (session == null) {
sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.bedrock_only", sender.getLocale()));
return;
}
if (command.isBedrockOnly() && session == null) {
sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.bedrock_only", sender.getLocale()));
return;
}
command.execute(session, sender, invocation.arguments().length > 1 ? Arrays.copyOfRange(invocation.arguments(), 1, invocation.arguments().length) : new String[0]);
}
} else {
getCommand("help").execute(null, new VelocityCommandSender(invocation.source()), new String[0]);
getCommand("help").execute(session, sender, new String[0]);
}
}