// This check was moved here, because player's rank's are set AFTER OnPlayerJoin()
        public void OnSetClass(ChangingRoleEventArgs ev)
        {
            try
            {
                if (ev.Player == null)
                {
                    return;
                }
                AFKComponent afkComponent = ev.Player.GameObject.gameObject.GetComponent <AFKComponent>();

                if (afkComponent != null)
                {
                    if (!plugin.Config.IgnorePermissionsAndIP)
                    {
                        if (ev.Player.CheckPermission("uafk.ignore") || ev.Player.IPAddress == "127.0.0.1")                         //127.0.0.1 is sometimes used for "Pets" which causes issues
                        {
                            afkComponent.disabled = true;
                        }
                    }
                    if (IsGhost(ev.Player))
                    {
                        afkComponent.disabled = true;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"ERROR In OnSetClass(): {e}");
            }
        }
        public void OnPlayerVerified(VerifiedEventArgs ev)
        {
            // Add a component to the player to check AFK status.
            AFKComponent afkComponent = ev.Player.GameObject.gameObject.AddComponent <AFKComponent>();

            afkComponent.plugin = plugin;
        }
 public void OnPlayerJoin(JoinedEventArgs ev)
 {
     if (ev.Player.IPAddress != "127.0.0.1")            // Do not assign AFK component to localized pet objects
     {
         // Add a component to the player to check AFK status.
         AFKComponent afkComponent = ev.Player.GameObject.gameObject.AddComponent <AFKComponent>();
         afkComponent.plugin = this.plugin;
     }
 }
        /// <summary>
        /// Reset the AFK time of a player.
        /// Thanks iopietro!
        /// </summary>
        /// <param name="player"></param>
        public void ResetAFKTime(Player player)
        {
            try
            {
                if (player == null)
                {
                    return;
                }

                AFKComponent afkComponent = player.GameObject.gameObject.GetComponent <AFKComponent>();

                if (afkComponent != null)
                {
                    afkComponent.AFKTime = 0;
                }
            }
            catch (Exception e)
            {
                Log.Error($"ERROR In ResetAFKTime(): {e}");
            }
        }
        // This check was moved here, because player's rank's are set AFTER OnPlayerJoin()
        public void OnSetClass(ChangingRoleEventArgs ev)
        {
            try
            {
                if (ev.Player == null)
                {
                    return;
                }
                AFKComponent afkComponent = ev.Player.GameObject.gameObject.GetComponent <AFKComponent>();

                if (afkComponent != null)
                {
                    if (ev.Player.CheckPermission("uafk.ignore"))
                    {
                        afkComponent.disabled = true;
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"ERROR In OnSetClass(): {e}");
            }
        }