package skadistats.clarity.parser.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import skadistats.clarity.match.Match;
import skadistats.clarity.model.UserMessage;
import skadistats.clarity.parser.Handler;
import skadistats.clarity.parser.HandlerHelper;
import skadistats.clarity.parser.RegisterHandler;

import com.dota2.proto.DotaUsermessages.CDOTAUserMsg_DodgeTrackingProjectiles;

@RegisterHandler(CDOTAUserMsg_DodgeTrackingProjectiles.class)
public class UserMsgDodgeTrackingProjectilesHandler implements Handler<CDOTAUserMsg_DodgeTrackingProjectiles> {

    private final Logger log = LoggerFactory.getLogger(getClass());
    
    @Override
    public void apply(int peekTick, CDOTAUserMsg_DodgeTrackingProjectiles message, Match match) {
        HandlerHelper.traceMessage(log, peekTick, message);
        log.debug("{} DODGE_TRACKING_PROJECTILES [target={}]",
            match.getReplayTimeAsString(),
            match.getEntities().getByIndex(message.getEntindex()).getDtClass().getDtName() 
        );
        match.getUserMessages().add(UserMessage.build(message, match));
    }

}

@@ -897,16 +897,22 @@
  %5Btarget
+_index
 =%7B%7D%5D%22,%0D%0A
@@ -972,86 +972,28 @@
    m
-atch.getEntities().getByIndex(message.getEntindex()).getDtClass().getDtName() 
+essage.getEntindex()
 %0D%0A  

Fix NullPointerException when referencing an already deleted ent