NullPointerException when setting flag to "none" in RegionCommands.setFlag
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start at RegionCommands.setFlag and trace the /rg flag command's handling of its return value when the flag argument is none. Reproduce the issue with the provided region and flag commands, then verify that clearing the flag still saves successfully and produces standard confirmation output without a NullPointerException.
Written by the indexing model from the issue text.
Description
WorldEdit Version
7.4.5+7590-b8dc4c1
WorldGuard Version
7.0.18+2392-fa605e6
Platform Version
Purpur 26.2-2627-HEAD@f284e3d
Confirmations
- I am using the most recent Minecraft release.
- I am using a version of WorldEdit compatible with my Minecraft version.
- I am using a version of WorldGuard compatible with my Minecraft version.
- I am using the latest or recommended version of my platform software.
- I am NOT using a hybrid server, e.g. a server that combines Bukkit and Forge. Examples include Arclight, Mohist, and Cardboard.
- I am NOT using a fork of WorldEdit, such as FastAsyncWorldEdit (FAWE) or AsyncWorldEdit (AWE)
Bug Description
When setting a WorldGuard flag to none to remove it, the plugin successfully clears the flag and saves the data in the background, but throws a NullPointerException in the server console/chat. This happens because the command framework attempts to invoke .toString() on the null value returned by RegionCommands.setFlag(...) to build the console/chat feedback.
Copy from the log:
[20:25:40] [Server thread/INFO]: Cannot invoke "Object.toString()" because the return value of "com.sk89q.worldguard.commands.region.RegionCommands.setFlag(com.sk89q.worldguard.protection.regions.ProtectedRegion, com.sk89q.worldguard.protection.flags.Flag, com.sk89q.worldedit.extension.platform.Actor, String)" is null -- | [20:25:44] [WorldGuard Region I/O/INFO]: [WorldGuard] Region data changes made in 'world' have been background savedExpected Behavior
The plugin should successfully clear the flag, gracefully handle the null return value from the cleared state, and send a standard confirmation message without throwing any errors in the console.
Reproduction Steps
- Create a region and assign a flag to a specific value (e.g.,
/rg flag testregion exit deny). - Attempt to remove the flag by setting it to none (e.g.,
/rg flag testregion exit none). - Check the server console to observe the
Cannot invoke "Object.toString()" ... is nullerror, followed by the background save message.
Optional WorldGuard-Report
No response
Anything Else?
No response
- Dominant language
- Java
- Stars
- 939
- Forks
- 672
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from EngineHub/WorldGuard
-
status:pending type:bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
EngineHub/WorldGuard#2302 · 4 comments ·
-
status:pending type:feature-request
Difficulty 4/5 3-5 days Newbie friendliness 45/100
EngineHub/WorldGuard#2301 · 5 comments ·
-
status:pending type:feature-request
Difficulty 5/5 Over a week Newbie friendliness 25/100
EngineHub/WorldGuard#2288 · 1 comment ·
-
status:pending type:feature-request
Difficulty 5/5 Over a week Newbie friendliness 35/100
EngineHub/WorldGuard#2287 ·
-
status:pending type:bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
EngineHub/WorldGuard#2284 ·
All issues in EngineHub/WorldGuard
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100