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

Solve NullPointerException caused by wrong config #2389

Conversation

luisch444
Copy link

@luisch444 luisch444 commented Aug 1, 2023

Bug

Overview

A NullPointerException could be thrown if the config file worldedit-config.yml has invalid data in wand-item or navigation-wand.item. It will be thrown if a player enters the game (PlayerJoinEvent) or a players changes game mode (PlayerGameModeChangeEvent)

Replicate

  1. Start a Bukkit or relative server with the last version of FAWE with this bug (2.7.1 as of today)
  2. Edit the config an set wand-item or navigation-wand.item to a wrong value like minecraft:-1
  3. Restarts the server and Join.
    You should see an Exception in the console

Risk

This bug could lead to skipping code. In the last example if you do not have the last version it will not be announced to an admin player. I did not find any pottencial risk, but in a future might produce a fatal unintended error.

Solution

Code

I just added some null checker in the if statement in the method loadDefaults in /main/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java#L1227

Submitter Checklist

  • Make sure you are opening from a topic branch (/feature/fix/docs/ branch (right side)) and not your main branch.
  • Ensure that the pull request title represents the desired changelog entry.
  • New public fields and methods are annotated with @SInCE TODO.
  • I read and followed the contribution guidelines.

@luisch444 luisch444 requested a review from a team as a code owner August 1, 2023 18:45
@github-actions github-actions bot added the Bugfix This PR fixes a bug label Aug 1, 2023
@NotMyFault
Copy link
Member

Thanks for the PR, although I don't think we should bother with invalid entries. A brief look at the material list is recommended whether you are unsure whether an item exists or not.

@NotMyFault NotMyFault closed this Aug 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix This PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants