Solve NullPointerException caused by wrong config #2389
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug
Overview
A NullPointerException could be thrown if the config file
worldedit-config.yml
has invalid data inwand-item
ornavigation-wand.item
. It will be thrown if a player enters the game (PlayerJoinEvent) or a players changes game mode (PlayerGameModeChangeEvent)Replicate
wand-item
ornavigation-wand.item
to a wrong value likeminecraft:-1
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 methodloadDefaults
in/main/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java#L1227
Submitter Checklist