This commit is contained in:
LeoDog896 2021-02-09 12:24:50 -05:00
parent becd876dcd
commit de5e8e3e67
7 changed files with 5 additions and 9 deletions

View File

@ -31,7 +31,7 @@ public class CommandDispatcher {
// Register aliases
final String[] aliases = command.getAliases();
if (aliases != null) {
for (String alias : command.getAliases()) {
for (String alias : aliases) {
this.commandMap.put(alias.toLowerCase(), command);
}
}
@ -62,13 +62,14 @@ public class CommandDispatcher {
final String[] parts = commandString.split(StringUtils.SPACE);
final String commandName = parts[0];
final String[] args = commandString.replaceFirst(Pattern.quote(commandName), "").trim().split(StringUtils.SPACE);
final Command command = findCommand(commandName);
// Check if the command exists
if (command == null)
return null;
// Removes the command's name + the space after
final String[] args = commandString.replaceFirst(Pattern.quote(commandName), "").trim().split(StringUtils.SPACE);
// Find the used syntax, or check which argument is wrong
return findCommandResult(command, args);
}

View File

@ -20,7 +20,7 @@ public class ArgumentStringArray extends Argument<String[]> {
@NotNull
@Override
public String[] parse(@NotNull String input) throws ArgumentSyntaxException {
public String[] parse(@NotNull String input) {
return input.split(Pattern.quote(StringUtils.SPACE));
}

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments.number;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments.number;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments.number;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.jetbrains.annotations.NotNull;

View File

@ -1,6 +1,5 @@
package net.minestom.server.command.builder.arguments.number;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
import org.jetbrains.annotations.NotNull;