NPE with requester display name and non citizen requester
SirEndii opened this issue ยท 2 comments
Is there an existing issue for this?
- I have searched the existing issues
Are you using the latest MineColonies Version?
- I am running the latest alpha version of MineColonies for my Minecraft version.
I am also running the latest (possible) versions of other mods that are part of my problem.
Did you check on the Wiki? or ask on Discord?
- I checked the MineColonies/Structurize Wiki or I asked on discord. Or I was sent from discord to open an issue here.
Minecraft Version
1.18
MineColonies Version
1.18.2-1.0.872-BETA
Structurize Version
1.18.2-1.0.411-ALPHA
Related Mods and their Versions
- Forge: 40.1.54
Current Behavior
I found a weird issue with minecolonies requests
When I try to use the method AbstractBuilding#getgetRequesterDisplayName
with the requests from the IRequestManager
it sometimes throws an NPE
So I tried to debug this. And I found that a request from the cook(64 salmon) returns a citizenId of -1 from getCitizensByRequest()
(See screenshot)
Ofc -1 is not a valid citizen number and citizenData
becomes null.(See Screenshot)
It seems that if the requester is not a citizen, it throws this NPE
Expected Behavior
It should not throw an NPE
It would be better if it returns null or something I can work with
Reproduction Steps
IRequestManager requestManager = colony.getRequestManager();
Set<IToken<?>> tokens = new HashSet<>();
tokens.addAll(requestManager.getPlayerResolver().getAllAssignedRequests());
tokens.addAll( requestManager.getRetryingRequestResolver().getAllAssignedRequests());
List<IRequest<?>> requests = new ArrayList<>();
for (IToken<?> token : tokens) {
IRequest<?> request = requestManager.getRequestForToken(token);
if (request != null && !(request instanceof IDeliverable))
requests.add(request);
}
//Throws the NPE
return request.getRequester().getRequesterDisplayName(requestManager, request).getString();
Logs
Anything else?
No response
Footer
Viewers
- Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
- Add a comment if you have any insights or background information that isn't already part of the conversation.