Skip to content

Fix IllegalArgumentException occurring when using /de back - Enhanced with join location tracking#136

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-96977234-c7e4-4ae0-826d-c84e5a13c60f
Draft

Fix IllegalArgumentException occurring when using /de back - Enhanced with join location tracking#136
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-96977234-c7e4-4ae0-826d-c84e5a13c60f

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 21, 2025

Fix IllegalArgumentException occurring when using /de back

This PR fixes a critical crash that occurs when players use the /de back command without having a previous teleport location stored. The solution includes both immediate crash prevention and enhanced functionality to improve the user experience.

Issue Description

The issue occurs because:

  1. The TeleportListener only captures the "from" location when a PlayerTeleportEvent occurs
  2. If a player joins the server and uses /de back without teleporting first, the HashMap has no entry for that player
  3. Calling player.teleport(null) throws IllegalArgumentException: location

Solution Implemented

Enhanced fix with two-part approach:

  1. Immediate crash prevention: Added null safety check in BackCommand to prevent the IllegalArgumentException and provide user-friendly error messaging

  2. Enhanced functionality: Modified JoinListener to track the player's join location as their initial "back" location, ensuring players always have a meaningful location to return to

Changes Made

  • BackCommand.java: Added null safety check and improved error messaging ("previous location" instead of "last location")
  • JoinListener.java: Now tracks join location as initial "back" location for all players upon joining

Benefits

  • ✅ Prevents server crashes from IllegalArgumentException
  • ✅ Provides clear error messaging for edge cases
  • ✅ Ensures /de back command is always functional for all players
  • ✅ Improves user experience by making the command more reliable and useful

The fix addresses both the immediate crash issue and the underlying usability problem, making the /de back command robust and user-friendly.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
@dmccoystephenson
Copy link
Copy Markdown
Member

Try again

1 similar comment
@dmccoystephenson
Copy link
Copy Markdown
Member

Try again

@dmccoystephenson
Copy link
Copy Markdown
Member

@copilot Try again

…mprove messaging

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 21, 2025

@copilot Try again

I've enhanced the fix with a more comprehensive solution. The updated implementation now:

  1. ✅ Prevents the IllegalArgumentException with null check
  2. ✅ Tracks the player's join location as their initial "back" location
  3. ✅ Provides clear error messaging
  4. ✅ Ensures players always have a previous location to return to

Changes in commit 4c8f9e2:

  • Enhanced JoinListener to store join location in lastLogins map
  • Improved BackCommand error messaging
  • Maintained null safety for edge cases

This addresses the root cause while providing a better user experience.

Copilot AI changed the title [WIP] @Dans-Plugins/Dans-Essentials/issues/132 Fix IllegalArgumentException occurring when using /de back - Enhanced with join location tracking Sep 21, 2025
Sign up for free to 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.

2 participants