mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix help command (#2604)
* Always pass session to execute() if the sender is a geyser player * cleanup
This commit is contained in:
parent
eb211884de
commit
1929a5be83
5 changed files with 32 additions and 37 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue