-
Notifications
You must be signed in to change notification settings - Fork 22
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
fix: prevent npe on player death by thrown spear #254
Conversation
Combat system may assign `null` as instigator to some (Before)DestroyEvents which causes an NPE in the player death system. This fixes the crash with a `TODO` item to find and fix the root cause. See Terasology/CombatSystem#92 for first investigation results. In addition, this commit introduces an enum for the statistics type to update to avoid any bugs resulting from using plain string "constants" (we did not even use constants ...).
This should make it easier to find this value and adjust it later, e.g., for local testing or tweaking.
private static final int COUNTDOWN_IN_SECONDS = 30; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this reside with the other LAS constants in LASUtils?
* @param aliveCharacterComponent | ||
* @param event notification event that a player entity is about to be destroyed (usually sent on death) | ||
* @param player the player entity about to be destroyed | ||
* @param characterComponent ensures that the entity has a character (TODO: why do we need this?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure we only fetch this event for actual players? 🤔
As we only do something here if PlayerCharacterComponent
is present, maybe we want to "require" that one instead.
Combat system may assign
null
as instigator to some (Before)DestroyEvents which causes an NPE in the player death system.This fixes the crash with a
TODO
item to find and fix the root cause. See Terasology/CombatSystem#92 for first investigation results.In addition, this commit introduces an enum for the statistics type to update to avoid any bugs resulting from using plain string "constants" (we did not even use constants ...).
Furthermore, I've made the pre-game countdown a constant. This should make it easier to find this value and adjust it later, e.g., for local testing or tweaking.