diff --git a/faf-commons-data/src/main/java/com/faforever/commons/replay/ReplayDataParser.java b/faf-commons-data/src/main/java/com/faforever/commons/replay/ReplayDataParser.java index 3f52348d..5a13cccf 100644 --- a/faf-commons-data/src/main/java/com/faforever/commons/replay/ReplayDataParser.java +++ b/faf-commons-data/src/main/java/com/faforever/commons/replay/ReplayDataParser.java @@ -379,13 +379,23 @@ private void parseGiveResourcesToPlayer(Map lua) { void parseModeratorEvent(Map lua, Integer player) { - String messageContent = (String) lua.get("Message"); - int fromInt = ((Number) lua.get("From")).intValue(); - int activeCommandSource = player; + String messageContent = "Content of Message Missing"; + int fromInt = -1; // Default Value + int activeCommandSource = -1; // Default Value + + if (lua.containsKey("Message") && lua.get("Message") instanceof String value) { + messageContent = value; + } + if (lua.containsKey("From") && lua.get("From") instanceof Number value) { + fromInt = value.intValue(); + } + if (player != null) { + activeCommandSource = player; + } + moderatorEvents.add(new ModeratorEvent(tickToTime(ticks), Integer.toString(fromInt), messageContent, activeCommandSource)); } - private Duration tickToTime(int tick) { return Duration.ofSeconds(tick / 10); }