Beispiel #1
0
        public static void OnJoin(JoinEventArgs args)
        {
            TSPlayer plr = TShock.Players[args.Who];

            if (plr == null)
            {
                return;
            }

            TempGroupPlayer tgplr = TempGroupDbManage.GetTempGroup(plr.Name);

            if (tgplr.ActualGroup == null)
            {
                return;
            }

            if ((DateTime.Now - tgplr.ExpireDate).TotalMilliseconds > 0)
            {
                plr.Group         = TShock.Groups.GetGroupByName(tgplr.PrimaryGroup);
                plr.Account.Group = tgplr.PrimaryGroup;
                TShock.UserAccounts.SetUserGroup(plr.Account, tgplr.PrimaryGroup);

                TempGroupDbManage.RemoveTempGroup(plr.Name);

                plr.SendMessage($"[c/595959:»]  Waznosc twojej rangi [c/ffff66:{tgplr.ActualGroup}] wygasla.", Color.Gray);
                return;
            }

            Players.Add(plr.Name, tgplr);
        }
        private void OnJoinReceived(object sender, JoinEventArgs e)
        {
            // is this me?
            if (e.User.Nickname == this.ircClient.Nickname)
            {
                this.logger.Debug("Seen self-join");

                var channel = e.Channel.ToLowerInvariant();

                // is this one of our channels?
                if (this.watchedChannels.ContainsKey(channel))
                {
                    this.logger.DebugFormat("Self-join monitored channel {0}", channel);

                    lock (this.channelStatus)
                    {
                        if (this.channelStatus.ContainsKey(channel))
                        {
                            this.channelStatus.Remove(channel);
                        }

                        this.channelStatus.Add(channel, new ChannelStatus());
                    }

                    this.logger.InfoFormat("Requesting ban/quiet lists for {0}", channel);
                    this.ircClient.Mode(channel, "b");
                    this.ircClient.Mode(channel, "q");
                }
            }
        }
Beispiel #3
0
 private void IrcPartReceived(object sender, JoinEventArgs e)
 {
     if (e.Channel == this.targetChannel)
     {
         this.RemoveTracking(e.User);
     }
 }
Beispiel #4
0
        public void ShouldNotWelcomeUserOnUnknownChannel()
        {
            // arrange
            this.joinMessageService.Setup(x => x.GetWelcomeUsers("cd"))
            .Returns(new List <WelcomeUser>());
            this.joinMessageService.Setup(x => x.GetExceptions("cd"))
            .Returns(new List <WelcomeUser>());

            var networkUser = new Mock <IUser>();

            networkUser.SetupAllProperties();
            networkUser.Object.Nickname = "ab";
            networkUser.Object.Username = "******";
            networkUser.Object.Hostname = "ab/test";

            this.joinMessageService.Object.ClearRateLimitCache();
            var ea = new JoinEventArgs(null, networkUser.Object, "cd", this.ircClient.Object);

            // act
            this.joinMessageService.Object.OnJoinEvent(this.ircClient.Object, ea);

            // assert
            this.ircClient.Verify(x => x.SendMessage("cd", It.IsAny <string>()), Times.Never());
            this.ircClient.Verify(x => x.SendMessage("ab", It.IsAny <string>()), Times.Never());
        }
Beispiel #5
0
        public void OnJoin(JoinEventArgs e)
        {
            hasChosenClass[e.Who] = false;

            #region Team Set
            Utils.SetTeam(e.Who, Utils.GetPlayerTeam(Main.player[e.Who].name));

            Block roster;
            if (!Plugin.Instance.teamData.BlockExists(Delegates.Roster))
            {
                roster = Plugin.Instance.teamData.NewBlock(new string[] { Delegates.Key }, Delegates.Roster);
            }
            else
            {
                roster = Plugin.Instance.teamData.GetBlock(Delegates.Roster);
            }
            string userName = TShock.Players[e.Who].Name;
            string list     = roster.GetValue(Delegates.Key);
            if (!list.Contains(";"))
            {
                roster.WriteValue(Delegates.Key, userName + ";");
                return;
            }
            for (int i = 0; i < list.Length; i++)
            {
                if (list.Substring(i).StartsWith(userName))
                {
                    return;
                }
            }
            roster.AddValue(Delegates.Key, ';', userName);
            #endregion
        }
        private void OnServerJoin(JoinEventArgs args)
        {
            var player = TShock.Players[args.Who];

            Bank.EnsureBankAccountsExist(player.Name);
            PlayerSessionTracker.AddPlayer(player);
        }
Beispiel #7
0
        private void OnJoin(JoinEventArgs args)
        {
            TSPlayer    tSPlayer = TShock.Players[args.Who];
            UserAccount user     = tSPlayer.Account;

            try
            {
                if (!PlayTime.ContainsKey((byte)args.Who))
                {
                    PlayTime.Add((byte)args.Who, new Stopwatch());
                }
                user             = TShock.UserAccounts.GetUserAccountByName(tSPlayer.Name);
                tSPlayer.Group   = TShock.Groups.GetGroupByName(user.Group);
                tSPlayer.Account = user;
                if (IsReload && !tSPlayer.HasPermission("server.mod"))
                {
                    tSPlayer.SendData(PacketTypes.Disconnect, "Serwer jest w trakcie ladowania zasobow. Sprobuj dolaczyc za chwile.");
                    args.Handled = true;
                    return;
                }
                if (tSPlayer.HasPermission("tshock.godmode"))
                {
                    tSPlayer.GodMode = true;
                }
            }
            catch (NullReferenceException)
            {
            }
            if (user == null)
            {
                return;
            }
            SrvPlayers[args.Who] = DataBase.GetSrvPlayer(user);
            PlayTime[(byte)args.Who].Start();
        }
Beispiel #8
0
 private void OnJoin(JoinEventArgs args)
 {
     if (!TShock.Players[args.Who].IsLoggedIn)
     {
         Players[args.Who] = StarverPlayer.GetGuest(args.Who);
     }
 }
Beispiel #9
0
        private void OnServerJoin(JoinEventArgs args)
        {
            var player = TShock.Players[args.Who];
            var user   = TShock.Users.GetUserByName(player.Name);

            if (user != null)
            {
                return;
            }

            if (Config.NameOnlyLetterOrDigit && !player.Name.All(c => char.IsLower(c) || char.IsUpper(c) || char.IsDigit(c)))
            {
                TShock.Utils.ForceKick(player, Message.UnavailableCharacterWarning);
                return;
            }

            user = new User
            {
                Name  = player.Name,
                UUID  = player.UUID,
                Group = TShock.Config.DefaultRegistrationGroupName
            };
            var password = _random.NewPassword();

            user.CreateBCryptHash(password);
            TShock.Users.AddUser(user);

            player.SetData(DataKey, password);
            Log.ConsoleInfo(Message.LogFormat, user.Name, password);
        }
 void OnJoin(object sender, JoinEventArgs e)
 {
     if (e.Who == BotMethods.Nickname)
     {
         games.Add(e.Channel, new PokerGame(BotMethods, e.Channel));
     }
 }
        /// <summary>
        /// Fired when a new user joins the server.
        /// </summary>
        /// <param name="args"></param>
        void OnServerJoin(JoinEventArgs args)
        {
            if (TShock.ServerSideCharacterConfig.Enabled)
            {
                var player = TShock.Players[args.Who];

                // Get the user using a combo of their UUID/name, as this is what's required for uuid login to function it seems
                var users = TShock.UserAccounts.GetUserAccounts().Where(u => u.UUID == player.UUID && u.Name == player.Name);
                if (users.Count() == 0)
                {
                    Log($"Creating new user for {player.Name}...");

                    // If the user didn't exist, generate a password for them then create a new user based on their uuid/username
                    tmpPasswords[player.Name + player.UUID + player.IP] = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).Substring(0, 10);
                    TShock.UserAccounts.AddUserAccount(new UserAccount(
                                                           player.Name,
                                                           BCrypt.Net.BCrypt.HashPassword(tmpPasswords[player.Name + player.UUID + player.IP].Trim()),
                                                           player.UUID,
                                                           TShock.Config.DefaultRegistrationGroupName,
                                                           DateTime.UtcNow.ToString("s"),
                                                           DateTime.UtcNow.ToString("s"),
                                                           ""));

                    Log("Success!");
                }
            }
        }
        private void JoinHandler(object sender, JoinEventArgs e)
        {
            lock (seenData)
            {
                var result = seenData.SeenEntries.Where(s => s.Nick == e.Who).FirstOrDefault();

                if (result != null)
                {
                    result.LastSeenTime = DateTime.Now;
                    result.LastAction   = "(JOIN)";
                    result.OnStatus     = true;
                }
                else
                {
                    var seenEntry = new SeenEntry();
                    seenData.SeenEntries.InsertOnSubmit(seenEntry);

                    seenEntry.Nick         = e.Who;
                    seenEntry.LastSeenTime = DateTime.Now;
                    seenEntry.LastAction   = "(JOIN)";
                    seenEntry.LastMessage  = "<no message yet>";
                    seenEntry.TimesSeen    = 0;
                    seenEntry.OnStatus     = true;
                }
                SaveDb();
            }
        }
Beispiel #13
0
 private void OnJoin(JoinEventArgs args)
 {
     if (!_playerList.ContainsKey(TShock.Players[args.Who].UUID))
     {
         _playerList.Add(TShock.Players[args.Who].UUID, new Player());
     }
 }
Beispiel #14
0
 private void IrcJoinReceived(object sender, JoinEventArgs e)
 {
     if (e.Channel == this.targetChannel)
     {
         this.AddNetworkTracking(e.User);
     }
 }
Beispiel #15
0
 private void OnJoin(JoinEventArgs e)
 {
     shp.Add(new SHPlayer()
     {
         who = e.Who
     });
 }
Beispiel #16
0
        public void OnJoin(JoinEventArgs e)
        {
            string   name;
            TSPlayer ts = TShock.Players[e.Who];

            if (IsFrozen(ts, out name))
            {
                FrozenPlayers.Add(new FrozenPlayer(ts.Index, true));
                IpNames.Remove(ts.IP);

                TShock.Log.ConsoleInfo(string.Format("{0} a.k.a. ({1}) has been re-frozen", ts.Name, name));

                if (name != ts.Name)
                {
                    foreach (TSPlayer tsplr in TShock.Players)
                    {
                        if (tsplr == null)
                        {
                            continue;
                        }

                        if (tsplr.Group.HasPermission("freeze.use"))
                        {
                            tsplr.SendSuccessMessage(string.Format("{0} a.k.a. ({1}) has been re-frozen", ts.Name, name));
                        }
                    }
                }
            }
        }
Beispiel #17
0
 // When someone joins the IRC
 void OnJoin(object sender, JoinEventArgs e)
 {
     Server.s.Log(Server.IRCColour + e.Data.Nick + "&g has joined the " + (e.Data.Channel.ToLower() == opchannel.ToLower() ? "operator " : "") + "channel");
     Player.GlobalChat(null, Server.IRCColour + e.Data.Nick + "&g has joined the " + (e.Data.Channel.ToLower() == opchannel.ToLower() ? "operator " : "") + "channel", false);
     irc.RfcNames(channel);
     irc.RfcNames(opchannel);
 }
Beispiel #18
0
        public void ShouldWelcomeUser()
        {
            // arrange
            var networkUser = new Mock <IUser>();

            networkUser.SetupAllProperties();
            networkUser.Object.Nickname = "ab";
            networkUser.Object.Username = "******";
            networkUser.Object.Hostname = "ab/test";

            this.joinMessageService.Object.ClearRateLimitCache();
            var ea = new JoinEventArgs(null, networkUser.Object, "ab", this.ircClient.Object);

            this.joinMessageService.Setup(x => x.GetOverride(It.IsAny <string>())).Returns(() => null);

            this.responderMock.Setup(
                x => x.Respond(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <object[]>(),
                    null,
                    CommandResponseDestination.Default,
                    CommandResponseType.Message,
                    false,
                    null))
            .Returns(new[] { new CommandResponse {
                                 Message = "ab"
                             } });

            // act
            this.joinMessageService.Object.OnJoinEvent(this.ircClient.Object, ea);

            // assert
            this.ircClient.Verify(x => x.SendMessage("ab", It.IsAny <string>()), Times.Once());
        }
Beispiel #19
0
 internal void HandleOnJoin(object sender, JoinEventArgs e)
 {
     if (OnJoin != null)
     {
         OnJoin(this, e);
     }
 }
        private async void OnJoin(JoinEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            TSPlayer player = TShock.Players[e.Who];

            if (player == null)
            {
                return;
            }

            DateTime muteExpiration = await Mutes.GetExpirationAsync(player);

            if (DateTime.UtcNow < muteExpiration)
            {
                player.mute = true;
                try
                {
                    await Task.Delay(muteExpiration - DateTime.UtcNow, player.GetPlayerInfo().MuteToken);

                    player.mute = false;
                    player.SendInfoMessage("You have been unmuted.");
                }
                catch (TaskCanceledException)
                {
                }
            }
        }
Beispiel #21
0
 void ClientOnJoin(object sender, JoinEventArgs e)
 {
     _events.Enqueue(new IrcEvent {
         Type = IrcEvent.EventType.Join, Event = e
     });
     _waitHandle.Set();
 }
Beispiel #22
0
 void ircClient_OnJoin(object sender, JoinEventArgs e)
 {
     if (e.Data.Nick != m_Nick)
     {
         m_IRCClient.RfcNames(e.Data.Channel);
         System.Console.WriteLine(e.Data.Nick + " Came Online");
     }
 }
Beispiel #23
0
 public void ServerJoin(JoinEventArgs e)
 {
     ListBoxUsernames.MainThreadInvoke(() =>
     {
         ListBoxUsernames.Clear();
         ListBoxUsernames.AddRange((from tsplr in TShock.Players where tsplr != null orderby tsplr.Name select tsplr.Name).ToArray());
     });
 }
Beispiel #24
0
 private void serverWindow_NewWindow(object sender, JoinEventArgs e)
 {
     if (e.Window.WindowName == this.data.Channel)
     {
         serverWindow.NewWindow -= new EventHandler <JoinEventArgs>(serverWindow_NewWindow);
         Futher2();
     }
 }
Beispiel #25
0
 void irc_OnJoin(object sender, JoinEventArgs e)
 {
     while (ircMessageQueue.Count > 0)
     {
         var msg = ircMessageQueue.Dequeue();
         IrcSendMessage(msg);
     }
 }
        private void OnServerJoin(JoinEventArgs args)
        {
            Debug.Print("OnServerJoin");

            var player = TShock.Players[args.Who];

            RunScript(ScriptServerJoin, player);
        }
Beispiel #27
0
 private void OnJoin(JoinEventArgs e)
 {
     if (enabled)
     {
         TSPlayer player = TShock.Players[e.Who];
         Player   p      = Main.player[e.Who];
         player.Teleport(p.SpawnX, p.SpawnY);
     }
 }
Beispiel #28
0
 private void OnJoin(JoinEventArgs e)
 {
     invp.Add(new InvPlayer()
     {
         who        = e.Who,
         death      = false,
         justJoined = true
     });
 }
Beispiel #29
0
        private void OnJoin(object sender, JoinEventArgs e)
        {
            // TODO: Network
            // Load server
            var server = KnownActiveGameServers[e.ServersListIndex];

            // Switch tab
            throw new NotImplementedException();
        }
Beispiel #30
0
 private void Server_OnJoin(object sender, JoinEventArgs e)
 {
     using (var context = new BotContext())
     {
         SeenEntry entry = GetSeenEntry(context, e.Who);
         entry.LastSeen = null;
         context.SaveChanges();
     }
 }