fix empty array elements in command arguments

Adjacent spaces caused empty array elements due to how String#split works.
This change removes those empty array elements without modifying anything else.
Adjacent spaces sent by players are removed in PlayerConnection, so this change doesn't affect players.
But it does affect the console, command blocks, Bukkit.dispatchCommand, etc.
This commit is contained in:
Trigary 2021-06-05 10:29:39 +02:00
parent 83f8fa22d2
commit 357d34835f

View file

@ -131,7 +131,7 @@ public class SimpleCommandMap implements CommandMap {
*/
@Override
public boolean dispatch(@NotNull CommandSender sender, @NotNull String commandLine) throws CommandException {
String[] args = commandLine.split(" ");
String[] args = org.apache.commons.lang3.StringUtils.split(commandLine, ' '); // Paper - fix adjacent spaces (from console/plugins) causing empty array elements
if (args.length == 0) {
return false;