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

Crash in PlayerDeathSystem while trying to update statistics #234

Closed
skaldarnar opened this issue Aug 29, 2021 · 2 comments
Closed

Crash in PlayerDeathSystem while trying to update statistics #234

skaldarnar opened this issue Aug 29, 2021 · 2 comments
Labels
Category: Crash Requests, Issues and Changes targeting unexpected terminations, segfaults, etc. Multiplayer Affects aspects not visible in Singleplayer mode only Type: Bug Issues reporting and PRs fixing problems

Comments

@skaldarnar
Copy link
Contributor

During play-testing https://github.com/MovingBlocks/Terasology/releases/tag/v5.2.0-rc.1 the (headless) server crashed due to the following NPE when updating the player statistics:

java.lang.NullPointerException: null
        at org.terasology.ligthandshadow.componentsystem.controllers.PlayerDeathSystem.updateStatistics(PlayerDeathSystem.java:93)
        at org.terasology.ligthandshadow.componentsystem.controllers.PlayerDeathSystem.beforeDestroy(PlayerDeathSystem.java:63)
        at org.terasology.ligthandshadow.componentsystem.controllers.PlayerDeathSystemMethodAccess.invoke(Unknown Source)
        at org.terasology.engine.entitySystem.event.internal.EventSystemImpl$ByteCodeEventHandlerInfo.invoke(EventSystemImpl.java:379)
        at org.terasology.engine.entitySystem.event.internal.EventSystemImpl.sendConsumableEvent(EventSystemImpl.java:254)
        at org.terasology.engine.entitySystem.event.internal.EventSystemImpl.send(EventSystemImpl.java:233)
        at org.terasology.engine.core.bootstrap.eventSystem.AbstractEventSystemDecorator.send(AbstractEventSystemDecorator.java:67

This occurs when the player does not have a PlayerStatisticsComponent.

private void updateStatistics(EntityRef player, String type) {
PlayerStatisticsComponent playerStatisticsComponent = player.getComponent(PlayerStatisticsComponent.class);
if (type.equals("kills")) {
playerStatisticsComponent.kills += 1;
}
if (type.equals("deaths")) {
playerStatisticsComponent.deaths += 1;
}
player.saveComponent(playerStatisticsComponent);
}

@skaldarnar skaldarnar added Type: Bug Issues reporting and PRs fixing problems Category: Crash Requests, Issues and Changes targeting unexpected terminations, segfaults, etc. Multiplayer Affects aspects not visible in Singleplayer mode only labels Aug 29, 2021
ujjman added a commit to ujjman/LightAndShadow that referenced this issue Oct 26, 2021
@jdrueckert
Copy link
Member

Release v5.2.0

@jdrueckert
Copy link
Member

Fixed by #242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Crash Requests, Issues and Changes targeting unexpected terminations, segfaults, etc. Multiplayer Affects aspects not visible in Singleplayer mode only Type: Bug Issues reporting and PRs fixing problems
Projects
None yet
Development

No branches or pull requests

2 participants