Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat vs Console command arguments mismatch #5777

Closed
3 tasks done
molor opened this issue Jun 5, 2021 · 2 comments · Fixed by #5778
Closed
3 tasks done

Chat vs Console command arguments mismatch #5777

molor opened this issue Jun 5, 2021 · 2 comments · Fixed by #5778
Labels
type: bug Something doesn't work as it was intended to. version: 1.16 Game version 1.16

Comments

@molor
Copy link

molor commented Jun 5, 2021

Expected behavior

Player1 or Console performed command:

/tt 1 2  3   4    5     0

TestPlugin onCommand handler received:

arguments: ["1", "2", "3", "4", "5", "0"]

Observed/Actual behavior

Player1 performed command:

/tt 1 2  3   4    5     0

TestPlugin onCommand handler received:

arguments: ["1", "2", "3", "4", "5", "0"]

Console performed command:

/tt 1 2  3   4    5     0

TestPlugin onCommand handler received:

arguments: ["1", "2", "", "3", "", "", "4", "", "", "", "5", "", "", "", "", "0"]

Steps/models to reproduce

@Override
public boolean onCommand(CommandSender theSender, Command theCommand, String labelString, String[] arguments) {
	if (theCommand.getName().equalsIgnoreCase("tt")) {
		System.out.println("arguments: [\"" + String.join("\", \"", arguments) + "\"]");
		return true;
	}

	return false;
}

Then try to perform tt command with more than 1 space between arguments from game chat and server console and see the difference. This problem can break some plugins which do not expect to see empty strings as the argument value, because you can't send an empty argument from a game chat.

Plugin list

TestPlugin

Paper version

git-Paper-763 (MC: 1.16.5)

Agreements

  • I am running the latest version of Paper available from https://papermc.io/downloads.
  • I have searched for and ensured there isn't already an open issue regarding this.
  • My version of Minecraft is supported by Paper.

Other

No response

@Prof-Bloodstone Prof-Bloodstone added type: bug Something doesn't work as it was intended to. version: 1.16 Game version 1.16 labels Jun 5, 2021
Trigary added a commit to Trigary/Paper that referenced this issue Jun 5, 2021
@Prof-Bloodstone
Copy link
Contributor

It's weird because I swear I had an issue before with executing commands with too many spaces as player, but might remember it wrong since I can't reproduce.

It's also an issue with rcon - it doesn't strip it either.
Confirmed with grakkit:

core.command({
  name: 'tt',
  execute: (player, ...args) => {
    player.sendMessage("Arguments: " + args)
  }
})

In game:

/tt 1  2   3
Arguments: 1,2,3

Console:

[10:43:52 INFO]: Prof_Bloodstone issued server command: /tt 1 2 3
> tt 1  2   3
[10:45:12 INFO]: Arguments: 1,,2,,,3

RCON:

./rcon-cli 'tt 1  2   3'
Arguments: 1,,2,,,3

This could be caused by chat processing earlier on, where it squashes duplicate whitespace:

I     like     tacos
<Prof_Bloodstone> I like tacos

@molor
Copy link
Author

molor commented Jul 28, 2021

(same on 1.17.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something doesn't work as it was intended to. version: 1.16 Game version 1.16
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants