Beispiel #1
0
 public static void run(JoinEventArgs e)
 {
     if (!(Variables.playersData.ContainsKey(TShock.Players[e.Who].Name)))
     {
         Variables.playersData.Add(TShock.Players[e.Who].Name, new Variables.informations { ActualClass = Variables.startClass });
     }
 }
Beispiel #2
0
        internal bool InvokeServerJoin(int who)
        {
            JoinEventArgs args = new JoinEventArgs
            {
                Who = who
            };

            this.ServerJoin.Invoke(args);
            return(args.Handled);
        }
Beispiel #3
0
        private void PlayerJoin(TerrariaApi.Server.JoinEventArgs args)
        {
            TSPlayer target  = TShock.Players[args.Who];
            String   message = target.Name;

            if (!target.HasPermission("tagblock.allow.name.color"))
            {
                if (message.Contains("[c:") || message.Contains("[c/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Color Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.item"))
            {
                if (message.Contains("[i:") || message.Contains("[i/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Item Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.achievement"))
            {
                if (message.Contains("[a:") || message.Contains("[a/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Achievement Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;

            if (!target.HasPermission("tagblock.allow.name.player"))
            {
                if (message.Contains("[n:") || message.Contains("[n/") && message.Contains("]"))
                {
                    TShock.Utils.ForceKick(target, "Please remove the Player Name Tag from your username.\n  You can a character editor to do this.", true, true);
                    args.Handled = true;
                }
            }
            ;
        }
Beispiel #4
0
 private async void OnJoin(JoinEventArgs e)
 {
     string ip = TShock.Players[e.Who].IP;
     string plrhost;
     plrhost = await GetHost(ip);
     if (string.IsNullOrEmpty(plrhost))
     {
         Log.ConsoleError("Could not find hostname for " + TShock.Players[e.Who].Name + ".");
         Log.Warn("Could not find hostname for " + TShock.Players[e.Who].Name + ".");
         return;
     }
     Config.Read(path);
     List<BannedHost> bannedhosts = Config.BannedHostnames;
     foreach (BannedHost host in bannedhosts)
     {
         if (plrhost.Contains(host.hostname))
         {
             TShock.Players[e.Who].Disconnect("You are banned: " + host.reason + ".");
         }
     }
 }
		internal bool InvokeServerJoin(int who)
		{
			JoinEventArgs args = new JoinEventArgs
			{
				Who = who
			};

			this.ServerJoin.Invoke(args);
			return args.Handled;
		}
Beispiel #6
0
 public void OnJoin(JoinEventArgs args)
 {
     Playerlist[args.Who] = new CPlayers(args.Who);
 }
        public void OnJoin(JoinEventArgs args)
        {
            scPlayers[args.Who] = new scPlayer(args.Who);

            if (OfflineCooldowns.ContainsKey(TShock.Players[args.Who].Name))
            {
                scPlayers[args.Who].Cooldowns = OfflineCooldowns[TShock.Players[args.Who].Name];
                OfflineCooldowns.Remove(TShock.Players[args.Who].Name);
            }
        }
Beispiel #8
0
 private void OnJoin(JoinEventArgs e)
 {
     var plr = TShock.Players[e.Who];
     if (!IsValid(plr.Name))
         TShock.Utils.Kick(plr, "Please use valid English for your character name.", false, true);
 }
 //Hook Handlers
 private void HandleConnection(JoinEventArgs args)
 {
     Ban ban = new Ban(Netplay.serverSock[args.Who].tcpClient.Client.RemoteEndPoint.ToString().Split(':')[0], -1, "", Main.player[args.Who].name);
     var bans = banManager.GetBans(ban).ToList();
     if (bans.Count > 0)
     {
         TShock.Players[args.Who].Disconnect(String.Format("Banned: {0}", String.IsNullOrEmpty(ban.BanReason) ? "No reason specified." : ban.BanReason));
         args.Handled = true;
     }
 }
Beispiel #10
0
 /* OnServerJoin
  *
  * Called when player joined to server
  *
  * */
 private void OnServerJoin(JoinEventArgs args)
 {
 }
Beispiel #11
0
		void OnJoin(JoinEventArgs e)
		{
			lock (this)
			{
				TSPlayer ply = TShock.Players[e.Who];
				if (ply == null)
					return;

				Player plr;
				if (StatDB.PlayerExists(ply.Name))
					plr = StatDB.PullPlayer(ply.Name);
				else
					plr = new Player(e.Who, ply.Name);

				players[e.Who] = plr;
			}
		}
Beispiel #12
0
 private void OnJoin(JoinEventArgs args)
 {
     PlayerList[args.Who] = new CAPlayer();
     try
     {
         if (PlayerList[args.Who] != null && args.Who >= 0)
         {
             lock (PlayerList)
             {
                 PlayerList[args.Who] = new CAPlayer(args.Who);
             }
             if (Channels[0] != null)
                 Channels[0].JoinChannel(PlayerList[args.Who]);
         }
     }
     catch (Exception ex)
     {
         TShock.Log.ConsoleError(ex.ToString());
     }
 }
Beispiel #13
0
 private void OnJoin(JoinEventArgs args)
 {
     ATPlayers[args.Who] = new ATPlayer();
 }
Beispiel #14
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 #15
0
        public static void OnJoin(JoinEventArgs args)
        {
            var player = TShock.Players[args.Who];
            int index = Config.Warrior.FindIndex(v => v.PlayerName == player.Name);

            if (index == -1)
            {
                Config.Warrior.Add(new Warrior(player.Name));
                Config.Paladin.Add(new Paladin(player.Name));
                Config.Wizard.Add(new Wizard(player.Name));
                Config.settings.Add(new Config.Settings { currentVocation = "warrior" });
            }
        }
Beispiel #16
0
 ///<summary>
 /// This event happens every time a player joins the server.
 ///</summary>
 ///<param name="args">Containing event data.</param>
 private void OnJoin(JoinEventArgs args)
 {
 }
Beispiel #17
0
 /// <summary>
 /// ServerJoin callback.
 /// </summary>
 /// <param name="args"></param>
 private void OnServerJoin(JoinEventArgs args)
 {
     lock (this.m_AddonsLock)
     {
         this.m_Addons.ForEach(a =>
             {
                 var ret = a.Value.InvokeEvent("ServerJoin", args);
                 if (ret != null && ret.Length >= 1)
                 {
                     bool result;
                     if (bool.TryParse(ret[0].ToString(), out result) && result)
                         args.Handled = true;
                 }
             });
     }
 }
		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 #19
0
 void OnServerJoin(JoinEventArgs e)
 {
     Player player = players.Where(p => p.Name == Main.player[e.Who].name).FirstOrDefault();
     if (player == null)
     {
         players.Add(new Player(e.Who, Main.player[e.Who].name));
     }
     else
     {
         //Log.ConsoleInfo("Player exists.");
         player.Index = e.Who;
     }
 }
Beispiel #20
0
        private void OnJoin(JoinEventArgs e)
        {
            var player = TShock.Players[e.Who];
            if (player == null)
            {
                e.Handled = true;
                return;
            }

            string[] ban = EBUtils.PlayerBanInfo(player.Name);

            if (ban[0] == "banned")
            {
                TShock.Utils.Kick(player, string.Format("You are banned: {0}", ban[5]), true, true, null, true);
                e.Handled = true;
                return;
            }
        }
Beispiel #21
0
		/// <summary>
		/// Occurs when someone joins the game.
		/// </summary>
		protected void ServerHooks_Join(JoinEventArgs args)
		{
            
		}
        private static void OnJoin(JoinEventArgs args)
        {
            ScPlayers[args.Who] = new ScPlayer(args.Who);

              //if (OfflineCooldowns.ContainsKey(TShock.Players[args.Who].Name))
              //{
              //ScPlayers[args.Who].Cooldowns = OfflineCooldowns[TShock.Players[args.Who].Name];
              //OfflineCooldowns.Remove(TShock.Players[args.Who].Name);
              //}
        }
Beispiel #23
0
        /// <summary>OnJoin - Internal hook called when a player joins. This is called after OnConnect.</summary>
        /// <param name="args">args - The JoinEventArgs object.</param>
        private void OnJoin(JoinEventArgs args)
        {
            var player = Players[args.Who];
            if (player == null)
            {
                args.Handled = true;
                return;
            }

            if (Config.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID))
            {
                Utils.ForceKick(player, "客户端异常,请重新连接。", true);
                args.Handled = true;
                return;
            }

            Ban ban = null;
            if (Config.EnableBanOnUsernames)
            {
                var newban = Bans.GetBanByName(player.Name);
                if (null != newban)
                    ban = newban;
            }

            if (Config.EnableIPBans && null == ban)
            {
                ban = Bans.GetBanByIp(player.IP);
            }

            if (Config.EnableUUIDBans && null == ban && !String.IsNullOrWhiteSpace(player.UUID))
            {
                ban = Bans.GetBanByUUID(player.UUID);
            }

            if (ban != null)
            {
                if (!Utils.HasBanExpired(ban))
                {
                    DateTime exp;
                    if (!DateTime.TryParse(ban.Expiration, out exp))
                    {
                        player.Disconnect("你被永久封禁 " + ban.Reason);
                    }
                    else
                    {
                        TimeSpan ts = exp - DateTime.UtcNow;
                        int months = ts.Days / 30;
                        if (months > 0)
                        {
                            player.Disconnect(String.Format("你被封禁 {0} 月 {2} 日: {4}",
                                months, months == 1 ? "" : "s", ts.Days, ts.Days == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Days > 0)
                        {
                            player.Disconnect(String.Format("你被封禁 {0} 日 {2} 时: {4}",
                                ts.Days, ts.Days == 1 ? "" : "s", ts.Hours, ts.Hours == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Hours > 0)
                        {
                            player.Disconnect(String.Format("你被封禁 {0} 时 {2} 分: {4}",
                                ts.Hours, ts.Hours == 1 ? "" : "s", ts.Minutes, ts.Minutes == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Minutes > 0)
                        {
                            player.Disconnect(String.Format("你被封禁 {0} 分 {2} 秒: {4}",
                                ts.Minutes, ts.Minutes == 1 ? "" : "s", ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
                        }
                        else
                        {
                            player.Disconnect(String.Format("你被封禁 {0} 秒: {2}",
                                ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
                        }
                    }
                    args.Handled = true;
                }
            }
        }
Beispiel #24
0
        /// <summary>OnJoin - Internal hook called when a player joins. This is called after OnConnect.</summary>
        /// <param name="args">args - The JoinEventArgs object.</param>
        private void OnJoin(JoinEventArgs args)
        {
            var player = Players[args.Who];
            if (player == null)
            {
                args.Handled = true;
                return;
            }

            if (Config.KickEmptyUUID && String.IsNullOrWhiteSpace(player.UUID))
            {
                Utils.ForceKick(player, "Your client did not send a UUID, this server is not configured to accept such a client.", true);
                args.Handled = true;
                return;
            }

            Ban ban = null;
            if (Config.EnableBanOnUsernames)
            {
                var newban = Bans.GetBanByName(player.Name);
                if (null != newban)
                    ban = newban;
            }

            if (Config.EnableIPBans && null == ban)
            {
                ban = Bans.GetBanByIp(player.IP);
            }

            if (Config.EnableUUIDBans && null == ban && !String.IsNullOrWhiteSpace(player.UUID))
            {
                ban = Bans.GetBanByUUID(player.UUID);
            }

            if (ban != null)
            {
                if (!Utils.HasBanExpired(ban))
                {
                    DateTime exp;
                    if (!DateTime.TryParse(ban.Expiration, out exp))
                    {
                        player.Disconnect("You are banned forever: " + ban.Reason);
                    }
                    else
                    {
                        TimeSpan ts = exp - DateTime.UtcNow;
                        int months = ts.Days / 30;
                        if (months > 0)
                        {
                            player.Disconnect(String.Format("You are banned for {0} month{1} and {2} day{3}: {4}",
                                months, months == 1 ? "" : "s", ts.Days, ts.Days == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Days > 0)
                        {
                            player.Disconnect(String.Format("You are banned for {0} day{1} and {2} hour{3}: {4}",
                                ts.Days, ts.Days == 1 ? "" : "s", ts.Hours, ts.Hours == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Hours > 0)
                        {
                            player.Disconnect(String.Format("You are banned for {0} hour{1} and {2} minute{3}: {4}",
                                ts.Hours, ts.Hours == 1 ? "" : "s", ts.Minutes, ts.Minutes == 1 ? "" : "s", ban.Reason));
                        }
                        else if (ts.Minutes > 0)
                        {
                            player.Disconnect(String.Format("You are banned for {0} minute{1} and {2} second{3}: {4}",
                                ts.Minutes, ts.Minutes == 1 ? "" : "s", ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
                        }
                        else
                        {
                            player.Disconnect(String.Format("You are banned for {0} second{1}: {2}",
                                ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
                        }
                    }
                    args.Handled = true;
                }
            }
        }
		public void OnJoin(JoinEventArgs args)
		{
			esPlayers[args.Who] = new esPlayer(args.Who);

            if (esPlayers[args.Who] != null && TShock.Players[args.Who] != null)
            {
                if (Disabled.ContainsKey(TShock.Players[args.Who].Name))
                {
                    var ePly = esPlayers[args.Who];
                    ePly.DisabledX = Disabled[TShock.Players[args.Who].Name][0];
                    ePly.DisabledY = Disabled[TShock.Players[args.Who].Name][1];
                    ePly.TSPlayer.Teleport(ePly.DisabledX * 16F, ePly.DisabledY * 16F);
                    ePly.Disabled = true;
                    ePly.Disable();
                    ePly.LastDisabledCheck = DateTime.UtcNow;
                    ePly.TSPlayer.SendErrorMessage("You are still disabled.");
                }

                string nickname;
                if (esSQL.GetNickname(TShock.Players[args.Who].Name, out nickname))
                {
                    var ePly = esPlayers[args.Who];
                    ePly.HasNickName = true;
                    ePly.OriginalName = ePly.TSPlayer.Name;
                    ePly.Nickname = nickname;
                }
            }
		}
Beispiel #26
0
 public void OnJoin(JoinEventArgs e)
 {
     PlayerList[e.Who] = new PlayerData(this, TShock.Players[e.Who]);
 }
Beispiel #27
0
 void OnJoin(JoinEventArgs args)
 {
     if (cannonPlayers.Keys.Contains(args.Who))
     {
         cannonPlayers.Remove(args.Who);
     }
 }
Beispiel #28
0
 /// <summary>Fired when a player joins the server</summary>
 /// <param name="args">The JoinEventArgs object</param>
 public void OnJoin(JoinEventArgs args)
 {
     //If player was disconnected by another component, skip
     if (args.Handled)
         return;
     //If IP banning isn't used, skip
     if (!TShock.Config.EnableIPBans)
         return;
     //Creates TSPlayer player object for easy access
     TSPlayer player = TShock.Players[args.Who];
     //Searches a ban by player's IP
     CIDRBan ban = cidrbans.GetCIDRBanByIP(player.IP);
     //If no ban is found or ban has expired, skip
     if (ban == null)
         return;
     //DateTime exp object
     DateTime exp;
     //If player's ban has no expiration date, say ban forever
     if (!DateTime.TryParse(ban.Expiration, out exp))
         player.Disconnect("You are banned forever: " + ban.Reason);
     //If player's ban is temporary, check if it has expired or not
     else
     {
         //If player's ban has expired, remove the ban
         if (DateTime.UtcNow >= exp)
         {
             cidrbans.DelCIDRBanByRange(ban.CIDR);
             return;
         }
         //Finds time left from now to expiration date
         TimeSpan ts = exp - DateTime.UtcNow;
         //Makes 30 days count shows as one month
         int months = ts.Days / 30;
         //Converts timespan object into time string to inform player
         if (months > 0)
         {
             player.Disconnect(String.Format("You are banned for {0} month{1} and {2} day{3}: {4}",
                 months, months == 1 ? "" : "s", ts.Days, ts.Days == 1 ? "" : "s", ban.Reason));
         }
         else if (ts.Days > 0)
         {
             player.Disconnect(String.Format("You are banned for {0} day{1} and {2} hour{3}: {4}",
                 ts.Days, ts.Days == 1 ? "" : "s", ts.Hours, ts.Hours == 1 ? "" : "s", ban.Reason));
         }
         else if (ts.Hours > 0)
         {
             player.Disconnect(String.Format("You are banned for {0} hour{1} and {2} minute{3}: {4}",
                 ts.Hours, ts.Hours == 1 ? "" : "s", ts.Minutes, ts.Minutes == 1 ? "" : "s", ban.Reason));
         }
         else if (ts.Minutes > 0)
         {
             player.Disconnect(String.Format("You are banned for {0} minute{1} and {2} second{3}: {4}",
                 ts.Minutes, ts.Minutes == 1 ? "" : "s", ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
         }
         else
         {
             player.Disconnect(String.Format("You are banned for {0} second{1}: {2}",
                 ts.Seconds, ts.Seconds == 1 ? "" : "s", ban.Reason));
         }
     }
     //Sets player's connection handled
     args.Handled = true;
 }
Beispiel #29
0
 private void onPlayerJoin(TerrariaApi.Server.JoinEventArgs e)
 {
     lock (players)
         players.Add(new Player(e.Who));
 }
Beispiel #30
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);
                if (name != ts.Name)
                {
                    foreach (TSPlayer tsplr in TShock.Players)
                    {
                        if (tsplr == null)
                            continue;

                        if (tsplr.Group.HasPermission("freeze.use"))
                        {
                            TShock.Log.ConsoleInfo(string.Format("{0} a.k.a ({1}) has been re-frozen", ts.Name, name));
                            tsplr.SendSuccessMessage(string.Format("{0} a.k.a ({1}) has been re-frozen", ts.Name, name));
                        }
                    }
                }
            }
        }
Beispiel #31
0
        public void OnJoin(JoinEventArgs args)
        {
            esPlayers[args.Who] = new esPlayer(args.Who);

            if (Disabled.ContainsKey(TShock.Players[args.Who].Name))
            {
                var ePly = esPlayers[args.Who];
                ePly.DisabledX = Disabled[TShock.Players[args.Who].Name][0];
                ePly.DisabledY = Disabled[TShock.Players[args.Who].Name][1];
                ePly.TSPlayer.Teleport(ePly.DisabledX * 16F, ePly.DisabledY * 16F);
                ePly.Disabled = true;
                ePly.TSPlayer.Disable();
                ePly.LastDisabledCheck = DateTime.UtcNow;
                Send.Error(ePly.TSPlayer, "Voce continua desabilitado.");
            }

            string nickname;
            if (esSQL.GetNickname(TShock.Players[args.Who].Name, out nickname))
            {
                var ePly = esPlayers[args.Who];
                ePly.HasNickName = true;
                ePly.OriginalName = ePly.TSPlayer.Name;
                ePly.Nickname = nickname;
            }
        }