Skip to content

Fix formatCommand to handle empty args correctly - #6213

Merged
JRoy merged 2 commits into
EssentialsX:2.xfrom
itsme-to:2.x
Jul 9, 2025
Merged

Fix formatCommand to handle empty args correctly#6213
JRoy merged 2 commits into
EssentialsX:2.xfrom
itsme-to:2.x

Conversation

@itsme-to

Copy link
Copy Markdown
Contributor

Information

This PR fixes #nnnn.

Details

Proposed fix:

Allows creating a clickable confirmation button for the clear command message.
The space prevents the command from being executed properly, as this tries to run '/clear ' instead of '/clear'.

Environments tested:

OS: Linux

Java version: 21

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

@JRoy
JRoy requested a review from CopilotJuly 9, 2025 18:06

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the formatCommand method within the Commandclearinventory class to handle empty argument arrays correctly. The issue was causing clickable confirmation buttons to generate malformed commands with trailing spaces.

  • Adds conditional logic to avoid adding unnecessary spaces when no arguments are present
  • Ensures proper command formatting for both empty and non-empty argument scenarios

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
JRoy
JRoy approved these changes Jul 9, 2025

@JRoyJRoy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch!

@JRoy
JRoy enabled auto-merge July 9, 2025 18:10
@JRoy
JRoy disabled auto-merge July 9, 2025 18:10
@JRoy
JRoy enabled auto-merge July 9, 2025 18:10
@JRoy
JRoy added this pull request to the merge queueJul 9, 2025
Merged via the queue into EssentialsX:2.x with commit b996a9fJul 9, 2025
Euphillya added a commit to Euphillya/Essentials-Folia that referenced this pull request Jul 13, 2025
EssentialsX@b996a9f Fix formatCommand to handle empty args correctly (EssentialsX#6213)
EssentialsX@e39b614 Fix numerous antibuild bypasses with signs (EssentialsX#6186)
EssentialsX@cc25a79 Fix player commands option not working (EssentialsX#6214)
EssentialsX@dfd83cf Fix /tpr on legacy versions (EssentialsX#6212)
EssentialsX@e04f488 Fix inventory behavior with new body/saddle slot (EssentialsX#6218)
EssentialsX@73da278 New Crowdin updates (EssentialsX#6143)
rewsdjad1 pushed a commit to rewsdjad1/EssentialsXPlus that referenced this pull request Aug 13, 2026
<!--
EssentialsX bug fix submission guide
====================================
NOTE: Failure to fill out this template properly may result in your PR
being
delayed or ignored without warning.
NOTE: Don't type between any arrows in the template, as this text will
be
hidden. This includes this header block and any other explanation text
blocks.
Want to discuss your PR before submitting it? Join the EssentialsX
Development
server: https://discord.gg/CUN7qVb
EssentialsX is GPL
------------------
By contributing to EssentialsX, you agree to license your code under the
GNU General Public License version 3, which can be found at the link
below:
https://github.com/EssentialsX/Essentials/blob/2.x/LICENSE
Instructions
------------
If you are submitting a bug fix, please follow the following steps:
1. Fill out the template in full.
This includes providing screenshots and a link to the original bug
report. If there isn't an existing bug report, we recommend opening a
new
detailed bug report BEFORE opening your PR to fix it, else your PR may
be
delayed or rejected without warning.
You can open a new bug report by following this link:
https://github.com/EssentialsX/Essentials/issues/new/choose 2. When linking logs or config files, do not attach them to the post!
Copy and paste any logs into https://gist.github.com/, then paste a
link to them in the relevant parts of the template. Do not use Hastebin
or Pastebin, as this can cause issues with future reviews.
DO NOT drag logs directly into this text box, as we cannot read these!
3. If you are fixing a performance issue, please include a link to a
Timings and/or profiler report, both before and after your PR.
4. If you are fixing a visual bug, such as in commands, please include
screenshots so that we can more easily review the proposed fix.
(You can drag screenshots into the bottom of the editor.)
-->
### Information
<!--
Replace #nnnn with the number of the original issue. If this PR fixes
multiple issues, you should repeat the phrase "fixes #nnnn" for each
issue.
-->
This PR fixes #nnnn. ### Details
**Proposed fix:** <!-- Type a description of your proposed fix below this line. -->
Allows creating a clickable confirmation button for the clear command
message.
The space prevents the command from being executed properly, as this
tries to run `'/clear '` instead of `'/clear'`.
**Environments tested:** <!-- Type the OS you have used below. -->
OS: Linux
<!-- Type the JDK version (from java -version) you have used below. -->
Java version: 21
<!--
Put an "x" inside the boxes for the server software you have tested this
bug fix on. If this feature does not apply to a server, strike through
the server software using ~~strikethrough~~. If you have tested on other
environments, add a new line with relevant details.
-->
- [X] Most recent Paper version (1.XX.Y, git-Paper-BUILD)
- [ ] CraftBukkit/Spigot/Paper 1.12.2
- [ ] CraftBukkit 1.8.8
**Demonstration:** <!--
Below this block, include screenshots/log snippets from before and after
as
necessary. If you have created or used a test case plugin, please link
to a
download of the plugin, source code and exact version used where
possible.
-->
---------
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@itsme-to@JRoy