Normalize and trim spaces in Player#performCommand (#12892)
This commit is contained in:
@@ -116,6 +116,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage;
|
||||
import net.minecraft.world.level.storage.PrimaryLevelData;
|
||||
import net.minecraft.world.level.validation.ContentValidationException;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -979,12 +980,14 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + commandLine); // Spigot // Paper - Include command in error message
|
||||
CommandSourceStack sourceStack = VanillaCommandWrapper.getListener(rawSender);
|
||||
|
||||
String command = StringUtils.normalizeSpace(commandLine.trim());
|
||||
|
||||
net.minecraft.commands.Commands commands = this.getHandle().getServer().getCommands();
|
||||
com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher = commands.getDispatcher();
|
||||
com.mojang.brigadier.ParseResults<CommandSourceStack> results = dispatcher.parse(commandLine, sourceStack);
|
||||
com.mojang.brigadier.ParseResults<CommandSourceStack> results = dispatcher.parse(command, sourceStack);
|
||||
|
||||
CommandSender sender = sourceStack.getBukkitSender();
|
||||
String[] args = org.apache.commons.lang3.StringUtils.split(commandLine, ' '); // Paper - fix adjacent spaces (from console/plugins) causing empty array elements
|
||||
String[] args = org.apache.commons.lang3.StringUtils.split(command, ' '); // Paper - fix adjacent spaces (from console/plugins) causing empty array elements
|
||||
Command target = this.commandMap.getCommand(args[0].toLowerCase(java.util.Locale.ENGLISH));
|
||||
|
||||
try {
|
||||
@@ -992,13 +995,13 @@ public final class CraftServer implements Server {
|
||||
return false;
|
||||
}
|
||||
Commands.validateParseResults(results);
|
||||
commands.performCommand(results, commandLine, true);
|
||||
commands.performCommand(results, command, true);
|
||||
return true;
|
||||
} catch (CommandException ex) {
|
||||
new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args)).callEvent(); // Paper
|
||||
throw ex;
|
||||
} catch (Throwable ex) {
|
||||
String msg = "Unhandled exception executing '" + commandLine + "' in " + target;
|
||||
String msg = "Unhandled exception executing '" + command + "' in " + target;
|
||||
new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args)).callEvent(); // Paper
|
||||
throw new CommandException(msg, ex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user