|
3 | 3 | import io.papermc.paper.configuration.GlobalConfiguration;
|
4 | 4 | import io.papermc.paper.console.BrigadierCompletionMatcher;
|
5 | 5 | import io.papermc.paper.console.BrigadierConsoleParser;
|
| 6 | +import net.kyori.adventure.text.Component; |
| 7 | +import net.kyori.adventure.text.format.NamedTextColor; |
6 | 8 | import net.minecraft.server.dedicated.DedicatedServer;
|
| 9 | +import net.minecraft.util.StringUtil; |
7 | 10 | import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
| 11 | +import org.bukkit.Bukkit; |
8 | 12 | import org.bukkit.craftbukkit.command.ConsoleCommandCompleter;
|
9 | 13 | import org.jline.reader.LineReader;
|
10 | 14 | import org.jline.reader.LineReaderBuilder;
|
@@ -45,12 +49,23 @@ protected void runCommand(String command) {
|
45 | 49 | // terminals interpret pressing [enter] and pasting a multi-line string differently,
|
46 | 50 | // the latter makes the line reader read it as a single line - and we don't want that
|
47 | 51 | // https://github.com/PaperMC/Paper/issues/13006
|
48 |
| - for (String line : command.split("\n")) { |
49 |
| - if (line.isEmpty()) { |
50 |
| - continue; |
51 |
| - } |
52 |
| - this.server.handleConsoleInput(line, this.server.createCommandSourceStack()); |
53 |
| - } |
| 52 | + command.lines() |
| 53 | + .filter(line -> !line.isEmpty()) |
| 54 | + .forEach(line -> { |
| 55 | + for (char character : line.toCharArray()) { |
| 56 | + if (!StringUtil.isAllowedChatCharacter(character)) { |
| 57 | + Bukkit.getConsoleSender().sendMessage( |
| 58 | + Component.text() |
| 59 | + .append(Component.text("Illegal console input character: 0x")) |
| 60 | + .append(Component.text(Integer.toHexString(character))) |
| 61 | + .color(NamedTextColor.RED) |
| 62 | + ); |
| 63 | + return; |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + this.server.handleConsoleInput(line, this.server.createCommandSourceStack()); |
| 68 | + }); |
54 | 69 | }
|
55 | 70 |
|
56 | 71 | @Override
|
|
0 commit comments