API breaking behavior within User#performCommand
YouHaveTrouble opened this issue · comments
Expected behavior
As for the API for PlayerCommandPreprocessEvent#getMessage() it's for the implementation to ignore the symbol before the command
Gets the command that the player is attempting to send.
All commands begin with a special character; implementations do not consider the first character when executing the content.
If the message is modified to include the / at the start, the / should be ignored when executing the command logic.
Observed/Actual behavior
/
is not stripped out and passed directly into Player#performCommand() HERE
Steps/models to reproduce
-
Create a simple plugin listening to PlayerCommandPreprocessEvent.
-
Modify the command message using setMessage(), adding the / at the start
-
Observe as things like gui click effects stop working due to server not being able to find a command with / at the start
BentoBox version
BentoBox sürümü: 1.24.1
Database: JSON
addons N/A, API issue
Plugin list
N/A
Other
Easy solution:
if (!event.isCancelled()) {
return getPlayer().performCommand(event.getMessage().startsWith("/") ? event.getMessage().substring(1) : event.getMessage() );
}
Thanks!