from terrabot.util.streamer import Streamer

from terrabot.events.events import Events


class PacketEParser(object):
    def parse(self, world, player, data, ev_man):

        #If player is active
        if data[2] == 1:
            #Raise event with player_id
            ev_man.raise_event(Events.NewPlayer, data[1])

from terrabot.util.streamer import Streamer

from terrabot.events.events import Events


class PacketEParser(object):
    def parse(self, world, player, data, ev_man):

        #If player is active
        if data[2] == 1 and player.logged_in:
            #Raise event with player_id
            ev_man.raise_event(Events.NewPlayer, data[1])

Fix with 'newPlayer' event triggering on load
Fix with 'newPlayer' event triggering on load

  from terrabot.util.streamer import Streamer
  
  from terrabot.events.events import Events
  
  
  class PacketEParser(object):
      def parse(self, world, player, data, ev_man):
  
          #If player is active
-         if data[2] == 1:
+         if data[2] == 1 and player.logged_in:
              #Raise event with player_id
              ev_man.raise_event(Events.NewPlayer, data[1])
  
Fix with 'newPlayer' event triggering on load
## Code Before:
from terrabot.util.streamer import Streamer

from terrabot.events.events import Events


class PacketEParser(object):
    def parse(self, world, player, data, ev_man):

        #If player is active
        if data[2] == 1:
            #Raise event with player_id
            ev_man.raise_event(Events.NewPlayer, data[1])

## Instruction:
Fix with 'newPlayer' event triggering on load
## Code After:
from terrabot.util.streamer import Streamer

from terrabot.events.events import Events


class PacketEParser(object):
    def parse(self, world, player, data, ev_man):

        #If player is active
        if data[2] == 1 and player.logged_in:
            #Raise event with player_id
            ev_man.raise_event(Events.NewPlayer, data[1])
