MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.64k stars 1.32k forks source link

No UI error on headless server on player death #5251

Open jdrueckert opened 2 weeks ago

jdrueckert commented 2 weeks ago

What happened

I died in-game and the server logged an error.

How to reproduce

  1. Run a headless server
  2. Join the server
  3. Die
  4. Check the server logs and see the following error logged:
    18:28:18.165 [main] ERROR o.t.e.network.internal.NetClient - Error processing event
    java.lang.NullPointerException: Cannot invoke "org.terasology.engine.rendering.nui.NUIManager.getHUD()" because "this.nuiManager" is null
       at org.terasology.module.inventory.systems.CharacterInventorySystem.resetDropMark(CharacterInventorySystem.java:212)
       at org.terasology.module.inventory.systems.CharacterInventorySystem.onPlayerDeath(CharacterInventorySystem.java:241)

Proposed Fix

A headless server shouldn't try to run the respective code path in the first place as it is not expected to have a UI. If the respective code is relevant for players, this should be run client-side.