Beispiel #1
0
        public static void OnLeave(LeaveEventArgs args)
        {
            if (args.Who >= TShockB.Players.Length || args.Who < 0)
            {
                //Something not right has happened
                return;
            }

            var tsplr = TShockB.Players[args.Who];

            TShockB.Players[args.Who] = null;

            if (tsplr != null && tsplr.ReceivedInfo)
            {
                if (!tsplr.SilentKickInProgress && tsplr.State >= 3)
                {
                    string playername = $"[c/4747BF:{tsplr.Name}]";
                    if (!tsplr.TPlayer.Male)
                    {
                        playername = $"[c/800080:{tsplr.Name}]";
                    }
                    TShock.AllSendMessagev2($"{playername} saiu do servidor.",
                                            $"{playername} has left the server.", Color.Gray);
                }

                Logger.doLog($"{tsplr.Name} has left the server.", Config.DebugLevel.Info);

                if (tsplr.IsLoggedIn && !tsplr.IgnoreActionsForClearingTrashCan && Main.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2))
                {
                    tsplr.PlayerData.CopyCharacter(tsplr);
                    TShock.CharacterDB.InsertPlayerData(tsplr);
                }

                if (TShock.Config.RememberLeavePos && !tsplr.LoginHarassed)
                {
                    TShock.RememberedPos.InsertLeavePos(tsplr.Name, tsplr.IP, (int)(tsplr.X / 16), (int)(tsplr.Y / 16));
                }

                if (tsplr.tempGroupTimer != null)
                {
                    tsplr.tempGroupTimer.Stop();
                }
            }

            // Fire the OnPlayerLogout hook too, if the player was logged in and they have a TSPlayer object.
            if (tsplr != null && tsplr.IsLoggedIn)
            {
                TShockAPI.Hooks.PlayerHooks.OnPlayerLogout(tsplr);
            }

            // The last player will leave after this hook is executed.
            if (UtilsB.ActivePlayers() == 1)
            {
                if (TShock.Config.SaveWorldOnLastPlayerExit)
                {
                    SaveManagerB.Instance.SaveWorld();
                }
                TShockB.SetConsoleTitle(true);
            }
        }
        public void TestModInterop()
        {
            typeof(UtilsC).ModInterop();
            typeof(UtilsD).ModInterop();

            typeof(UtilsA).ModInterop();
            Assert.AreEqual(UtilsA.Something(2, 3), UtilsC.Something(2, 3));
            Assert.AreEqual(UtilsA.AnotherThing(2, 3), UtilsC.AnotherThing(2, 3));

            typeof(UtilsB).ModInterop();
            Assert.AreEqual(UtilsA.Something(2, 3), UtilsC.Something(2, 3));
            Assert.AreEqual(UtilsB.AnotherThing(2, 3), UtilsC.AnotherThing(2, 3));

            Assert.AreEqual(UtilsB.Something(2, 3), UtilsD.Something(2, 3));
            Assert.AreEqual(UtilsB.AnotherThing(2, 3), UtilsD.AnotherThing(2, 3));
        }