Paper/patches/api/0315-fix-empty-array-elements-in-command-arguments.patch
Jason f97bb11e4b
Account for splash water bottles now extinguishing entities (#8622)
* Account for splash water bottles now extinguishing entities

* improvements and javadocs

* reorder patches

* rename event to WaterBottleSplashEvent

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
2022-12-08 16:33:22 -08:00

24 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Trigary <trigary0@gmail.com>
Date: Sat, 5 Jun 2021 10:29:39 +0200
Subject: [PATCH] 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.
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 950a2d0b3b583c6b9a703190874bbc4df2783ab7..b8623575b1c1b565560c2dd6438190716845a652 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -130,7 +130,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;