Esempio n. 1
0
 void VaultChCreate(CAPlayer player, int chID, CommandArgs args)
 {
     try
     {
         if (Vault.Vault.ModifyBalance(args.Player.Name, -config.ChanelCreatingCost))
         {
             var newchannel = new Channel(chID, args.Parameters[0]);
             if (args.Parameters.Count > 1)
             {
                 newchannel.Password = args.Parameters[1];
             }
             Channels[chID] = newchannel;
             NetMessage.SendData((int)PacketTypes.ChatText, -1, -1, "New channel created", 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, chID + 1);
             Channels[chID].JoinChannel(player);
         }
         else
         {
             args.Player.SendMessage(String.Format("Channel not found and insufficient founds to create a new channel. (costs: {0})", Vault.Vault.MoneyToString(config.ChanelCreatingCost)), Color.LightSalmon);
         }
     }
     catch (Exception ex)
     {
         Log.ConsoleError(ex.ToString());
     }
 }
Esempio n. 2
0
        internal static List <MenuItem> GetContentsPersonalSettings(CAPlayer player)
        {
            List <MenuItem> returnList = new List <MenuItem>();

            if (CAMain.config.EnableJoinQuitFilter)
            {
                returnList.Add(new MenuItem(String.Format("Display join/quit messages [{0}]", (player.Flags.HasFlag(PlayerSettings.HideJoinQuitMsg)) ? "OFF" : "ON"), 41, Color.AntiqueWhite));
            }
            else
            {
                returnList.Add(new MenuItem(String.Format("Display join/quit messages [{0}] <option disabled>", (player.Flags.HasFlag(PlayerSettings.HideJoinQuitMsg)) ? "OFF" : "ON"), 0, false, Color.AntiqueWhite));
            }
            if (CAMain.config.EnableDeathMsgFilter)
            {
                returnList.Add(new MenuItem(String.Format("Display death messages [{0}]", (player.Flags.HasFlag(PlayerSettings.HideDeathMsg)) ? "OFF" : "ON"), 42, Color.AntiqueWhite));
            }
            else
            {
                returnList.Add(new MenuItem(String.Format("Display death messages [{0}] <option disabled>", (player.Flags.HasFlag(PlayerSettings.HideDeathMsg)) ? "OFF" : "ON"), 0, false, Color.AntiqueWhite));
            }
            if (player.Ignores.Count == 0)
            {
                returnList.Add(new MenuItem("Ignore list [empty]", 0, false, Color.AntiqueWhite));
            }
            else
            {
                returnList.Add(new MenuItem(String.Format("Ignore list [{0}]", player.Ignores.Count), 43, Color.AntiqueWhite));
            }
            returnList.Add(new MenuItem("[ Back ]", 1, Color.LightGray));
            return(returnList);
        }
Esempio n. 3
0
 public static void DisplayMainMenu(CAPlayer player)
 {
     if (player.InMenu)
     {
         player.Menu.Close(true);
     }
     player.Menu = new Menu(player.Index, "Chat Assistant menu", MainMenuBuilder.GetContentsMain(), new CAMain.MenuAction(MainMenuBuilder.MainMenuCallback));
 }
Esempio n. 4
0
        internal static List <MenuItem> GetContentsLog(CAPlayer player)
        {
            var             log     = player.GetCombinedLog(50);
            List <MenuItem> logMenu = new List <MenuItem>();

            foreach (ChatMessage msg in log)
            {
                logMenu.Add(new MenuItem(msg.Text, 0, false, false, msg.Color));
            }
            return(logMenu);
        }
Esempio n. 5
0
        internal static List <MenuItem> GetContentsIgnoreList(CAPlayer player)
        {
            List <MenuItem> returnList = new List <MenuItem>();

            foreach (int i in player.Ignores)
            {
                returnList.Add(new MenuItem(CAMain.PlayerList[i].TSPlayer.Name, 0, false, Color.AntiqueWhite));
            }
            returnList.Add(new MenuItem("[ Back ]", 4, Color.LightGray));
            return(returnList);
        }
Esempio n. 6
0
        public static void DisplayLog(CAPlayer player, int offset)
        {
            if (player == null)
            {
                return;
            }
            var log = player.GetCombinedLog(offset);

            foreach (ChatMessage msg in log)
            {
                player.TSPlayer.SendData(PacketTypes.ChatText, msg.Text, 255, msg.Color.R, msg.Color.G, msg.Color.B, 1);
            }
        }
Esempio n. 7
0
 public void LeaveChannel(CAPlayer player)
 {
     this.Users.Remove(player.Index);
     player.Channel = 0;
     if (!this.Flags.HasFlag(ChannelFlags.Permanent) && this.Users.Count == 0)
     {
         DeleteChannel(this.ID);
     }
     else if (!this.Flags.HasFlag(ChannelFlags.BlockJoinLeaveMsg))
     {
         NetMessage.SendData((int)PacketTypes.ChatText, -1, player.Index, String.Format("[Leave] {0} has left the channel", player.TSPlayer.Name), 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, this.ID + 1);
     }
 }
Esempio n. 8
0
 void IgnoreCommand(CommandArgs args)
 {
     try
     {
         var player = PlayerList[args.Player.Index];
         if (player != null)
         {
             if (args.Parameters.Count > 0)
             {
                 string plyName      = string.Join(" ", args.Parameters.GetRange(0, args.Parameters.Count));
                 var    ignorePlayer = CAPlayer.GetPlayerByName(plyName);
                 if (ignorePlayer != null)
                 {
                     if (ignorePlayer.TSPlayer.Name == player.TSPlayer.Name)
                     {
                         args.Player.SendMessage("You cannot ignore yourself..", Color.Red);
                     }
                     else if (ignorePlayer.TSPlayer.Group.HasPermission("CA.ignore.bypass"))
                     {
                         args.Player.SendMessage(String.Format("Player {0} cannot be ignored", ignorePlayer.TSPlayer.Name), Color.Red);
                     }
                     else if (player.Ignores.Remove(ignorePlayer.Index))
                     {
                         args.Player.SendMessage(String.Format("Player {0} removed from your Ignore list", ignorePlayer.TSPlayer.Name), Color.DarkGreen);
                     }
                     else
                     {
                         player.Ignores.Add(ignorePlayer.Index);
                         args.Player.SendMessage(String.Format("Player {0} added to your Ignore list", ignorePlayer.TSPlayer.Name), Color.DarkGreen);
                     }
                 }
                 else
                 {
                     args.Player.SendMessage(String.Format("Player {0} is not on this server", plyName), Color.Red);
                 }
             }
             else
             {
                 args.Player.SendMessage("Syntax: /ignore <player name> - toggle ignore player messages", Color.Red);
             }
         }
     }
     catch (Exception ex)
     {
         Log.ConsoleError(ex.ToString());
     }
 }
Esempio n. 9
0
 private static void OnJoin(int who, HandledEventArgs args)
 {
     try
     {
         lock (PlayerList)
         {
             PlayerList[who] = new CAPlayer(who);
         }
         if (Channels[0] != null)
         {
             Channels[0].JoinChannel(PlayerList[who]);
         }
     }
     catch (Exception ex)
     {
         Log.ConsoleError(ex.ToString());
     }
 }
Esempio n. 10
0
 public void JoinChannel(CAPlayer player)
 {
     if (player == null)
     {
         return;
     }
     if (player.Channel >= 0 && player.Channel != this.ID && CAMain.Channels[player.Channel] != null)
     {
         CAMain.Channels[player.Channel].LeaveChannel(player);
     }
     player.Channel = this.ID;
     if (!this.Users.Contains(player.Index))
     {
         this.Users.Add(player.Index);
         CAMain.DisplayLog(player, 6);
         if (!this.Flags.HasFlag(ChannelFlags.BlockJoinLeaveMsg))
         {
             NetMessage.SendData((int)PacketTypes.ChatText, -1, player.Index, String.Format("[Join] {0} has joined the channel", player.TSPlayer.Name), 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, this.ID + 1);
         }
     }
 }
Esempio n. 11
0
 public static void DisplayLog(CAPlayer player, int offset)
 {
     if (player == null)
         return;
     var log = player.GetCombinedLog(offset);
     foreach (ChatMessage msg in log)
     {
         player.TSPlayer.SendData(PacketTypes.ChatText, msg.Text, 255, msg.Color.R, msg.Color.G, msg.Color.B, 1);
     }
 }
Esempio n. 12
0
 private static void OnJoin(int who, HandledEventArgs args)
 {
     try
     {
         lock (PlayerList)
         {
             PlayerList[who] = new CAPlayer(who);
         }
         if (Channels[0] != null)
             Channels[0].JoinChannel(PlayerList[who]);
     }
     catch (Exception ex)
     {
         Log.ConsoleError(ex.ToString());
     }
 }
Esempio n. 13
0
 internal static List<MenuItem> GetContentsIgnoreList(CAPlayer player)
 {
     List<MenuItem> returnList = new List<MenuItem>();
     foreach (int i in player.Ignores)
     {
         returnList.Add(new MenuItem(CAMain.PlayerList[i].TSPlayer.Name, 0, false, Color.AntiqueWhite));
     }
     returnList.Add(new MenuItem("[ Back ]", 4, Color.LightGray));
     return returnList;
 }
Esempio n. 14
0
        void VaultChCreate(CAPlayer player, int chID, CommandArgs args)
        {
            try
            {

                var economyPlayer = Wolfje.Plugins.SEconomy.SEconomyPlugin.Instance.GetBankAccount(player.Index);
                var commandCost = new Wolfje.Plugins.SEconomy.Money(config.cost);

                //Vault.Vault.ModifyBalance(args.Player.Name, -config.ChanelCreatingCost))

                if (!economyPlayer.IsAccountEnabled)
                {
                    player.TSPlayer.SendErrorMessage("You cannot use this command because your account is disabled.");
                }

                else if (economyPlayer.Balance != null && economyPlayer.Balance >= config.cost)
                {
                    Wolfje.Plugins.SEconomy.Journal.BankTransferEventArgs trans = economyPlayer.TransferTo(
                    Wolfje.Plugins.SEconomy.SEconomyPlugin.Instance.WorldAccount, commandCost,
                    Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.AnnounceToSender |
                    Wolfje.Plugins.SEconomy.Journal.BankAccountTransferOptions.IsPayment, "", string.Format("charge to {0}", player.TSPlayer.Name));

                    var newchannel = new Channel(chID, args.Parameters[0]);
                    if (args.Parameters.Count > 1)
                        newchannel.Password = args.Parameters[1];
                    Channels[chID] = newchannel;
                    NetMessage.SendData((int)PacketTypes.ChatText, -1, -1, "New channel created", 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, chID + 1);
                    Channels[chID].JoinChannel(player);
                }
                else
                    args.Player.SendMessage(String.Format("Channel not found and insufficient founds to create a new channel. (costs: {0})", economyPlayer.Balance.ToString()), Color.LightSalmon);
                                                                                                                                             //Vault.Vault.MoneyToString(this.parseCost))
            }
            catch (Exception ex)
            {
                TShock.Log.ConsoleError(ex.ToString());
            }
        }
Esempio n. 15
0
        public static void SendData(SendDataEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }
            try
            {
                if (e.MsgID == PacketTypes.ChatText)
                {
                    //   Log.ConsoleInfo(String.Format("ChatText> 1: {0}, 2: {4}, 3: {5}, 4: {6}, 5: {1}, remote: {2}, ignore: {3}", e.number, e.number5, e.remoteClient, e.ignoreClient, e.number2, e.number3, e.number4));
                    int sender = e.ignoreClient; // -1 = system
                    if (sender == -1 && TShock.Config.EnableChatAboveHeads)
                    {
                        sender = e.number;
                    }
                    if (e.remoteClient == -1) // message to all players
                    {
                        if (e.number5 == 0)   // Default message, needs processing
                        {
                            if (sender >= 0 && sender != 255)
                            {
                                var player = PlayerList[sender];
                                if (player != null && !player.InMenu && !player.TSPlayer.mute)
                                {
                                    //   Console.WriteLine("sender {0} in channel {1}", sender, player.Channel);
                                    var playerGroup = player.TSPlayer.Group;
                                    int number1     = 255;
                                    if (TShock.Config.EnableChatAboveHeads)
                                    {
                                        number1 = e.ignoreClient;
                                    }
                                    NetMessage.SendData((int)PacketTypes.ChatText, -1, sender, e.text, e.number, e.number2, e.number3, e.number4, player.Channel + 2);
                                }
                            }
                            else
                            {
                                NetMessage.SendData((int)PacketTypes.ChatText, -1, -1, e.text, e.number, e.number2, e.number3, e.number4, 1);
                            }
                        }
                        else
                        {
                            int     channel = e.number5 - 2;
                            MsgType msgType = MsgType.Global;
                            if (channel >= 0)
                            {
                                msgType = MsgType.Channel;
                                if (TShock.Config.EnableChatAboveHeads && sender != -1 && sender != 255)
                                {
                                    TSPlayer tsplr = TShock.Players[sender];
                                    string   msg   = String.Format(TShock.Config.ChatFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix, e.text);
                                    Channels[channel].AddToLog(new ChatMessage(msg, new Color((byte)e.number2, (byte)e.number3, (byte)e.number4), msgType, sender)); // add to channel log
                                }
                                else
                                {
                                    Channels[channel].AddToLog(new ChatMessage(e.text, new Color((byte)e.number2, (byte)e.number3, (byte)e.number4), msgType, sender)); // add to channel log
                                }
                            }
                            else
                            {
                                AddLogItem(new ChatMessage(e.text, new Color((byte)e.number2, (byte)e.number3, (byte)e.number4), msgType, sender)); // add to global log
                                if (config.EnableDeathMsgFilter || config.EnableJoinQuitFilter)
                                {
                                    var plyName = StartsWithPlayerName(e.text);
                                    if (plyName != "")
                                    {
                                        if (config.EnableJoinQuitFilter && e.text == String.Format("{0} has joined.", plyName))
                                        {
                                            msgType = MsgType.Join;
                                        }
                                        else if (config.EnableJoinQuitFilter && e.text == String.Format("{0} left", plyName))
                                        {
                                            msgType = MsgType.Quit;
                                        }
                                        else if (config.EnableDeathMsgFilter && IsDeathMsg(e.text, plyName))
                                        {
                                            msgType = MsgType.Death;
                                        }
                                    }
                                }
                            }
                            for (int i = 0; i < PlayerList.Length; i++)
                            {
                                if (PlayerList[i] != null && !PlayerList[i].InMenu && !PlayerList[i].Ignores.Contains(sender) && (msgType == MsgType.Global || channel == PlayerList[i].Channel || (msgType == MsgType.Death && !PlayerList[i].Flags.HasFlag(PlayerSettings.HideDeathMsg)) || ((msgType == MsgType.Join || msgType == MsgType.Quit) && !PlayerList[i].Flags.HasFlag(PlayerSettings.HideJoinQuitMsg))))
                                {
                                    NetMessage.SendData((int)PacketTypes.ChatText, PlayerList[i].Index, sender, e.text, e.number, e.number2, e.number3, e.number4, 1); // custom message > e.number5 = 1, e.ignoreClient = sender
                                }
                            }

                            String logMessage = String.Format("[Chat][{1}]{2} {0}", e.text, msgType.ToString(), (msgType == MsgType.Channel && Channels[channel] != null) ? String.Format("[{0}]", Channels[channel].Name) : "");
                            Console.WriteLine(logMessage);
                            Log.Data(logMessage);
                        }
                        e.Handled = true;
                    }
                    else // message for player id = e.remoteClient
                    {
                        var player = PlayerList[e.remoteClient];
                        if (player == null)
                        {
                            return;
                        }
                        if (e.number5 == 0) // default message
                        {
                            if (e.text.StartsWith("(Whisper From)<"))
                            {
                                var senderName = e.text.Substring(15, e.text.IndexOf('>', 14) - 15);
                                var wPly       = CAPlayer.GetPlayerByName(senderName);
                                if (wPly != null && player.Ignores.Contains(wPly.Index))  //  Private message from ignored player
                                {
                                    e.Handled = true;
                                    return;
                                }
                            }
                            player.AddToLog(new ChatMessage(e.text, new Color((byte)e.number2, (byte)e.number3, (byte)e.number4), MsgType.Private, sender));
                            if (player.InMenu)
                            {
                                e.Handled = true;
                            }
                        }
                    }
                }
                else if (e.MsgID == PacketTypes.PlayerInfo)
                {
                    //  Console.WriteLine(String.Format("PlayerInfo> 1: {0}, 2: {4}, 3: {5}, 4: {6}, 5: {1}, remote: {2}, ignore: {3} text: {7}", e.number, e.number5, e.remoteClient, e.ignoreClient, e.number2, e.number3, e.number4, e.text));
                    if (TShock.Config.EnableChatAboveHeads && e.number5 == 0) //default message
                    {
                        var player = PlayerList[e.number];
                        if (player != null)
                        {
                            e.Handled = true;
                            NetMessage.SendData((int)PacketTypes.PlayerInfo, e.remoteClient, e.ignoreClient, String.Format(TShock.Config.ChatFormat, player.TSPlayer.Group.Name, player.TSPlayer.Group.Prefix, player.TSPlayer.Name, player.TSPlayer.Group.Suffix, ""), e.number, e.number2, e.number3, e.number4, 1);
                        }
                    }
                }
            }
            catch (Exception ex) { Log.ConsoleError(ex.ToString()); }
        }
Esempio n. 16
0
 internal static List<MenuItem> GetContentsLog(CAPlayer player)
 {
     var log = player.GetCombinedLog(50);
     List<MenuItem> logMenu = new List<MenuItem>();
     foreach (ChatMessage msg in log)
     {
         logMenu.Add(new MenuItem(msg.Text, 0, false, false, msg.Color));
     }
     return logMenu;
 }
Esempio n. 17
0
 internal static List<MenuItem> GetContentsPersonalSettings(CAPlayer player)
 {
     List<MenuItem> returnList = new List<MenuItem>();
     if (CAMain.config.EnableJoinQuitFilter)
         returnList.Add(new MenuItem(String.Format("Display join/quit messages [{0}]", (player.Flags.HasFlag(PlayerSettings.HideJoinQuitMsg)) ? "OFF" : "ON"), 41, Color.AntiqueWhite));
     else
         returnList.Add(new MenuItem(String.Format("Display join/quit messages [{0}] <option disabled>", (player.Flags.HasFlag(PlayerSettings.HideJoinQuitMsg)) ? "OFF" : "ON"), 0, false, Color.AntiqueWhite));
     if (CAMain.config.EnableDeathMsgFilter)
         returnList.Add(new MenuItem(String.Format("Display death messages [{0}]", (player.Flags.HasFlag(PlayerSettings.HideDeathMsg)) ? "OFF" : "ON"), 42, Color.AntiqueWhite));
     else
         returnList.Add(new MenuItem(String.Format("Display death messages [{0}] <option disabled>", (player.Flags.HasFlag(PlayerSettings.HideDeathMsg)) ? "OFF" : "ON"), 0, false, Color.AntiqueWhite));
     if (player.Ignores.Count == 0)
         returnList.Add(new MenuItem("Ignore list [empty]", 0, false, Color.AntiqueWhite));
     else
         returnList.Add(new MenuItem(String.Format("Ignore list [{0}]", player.Ignores.Count), 43, Color.AntiqueWhite));
     returnList.Add(new MenuItem("[ Back ]", 1, Color.LightGray));
     return returnList;
 }
Esempio n. 18
0
 public static void DisplayMainMenu(CAPlayer player)
 {
     if (player.InMenu)
         player.Menu.Close(true);
     player.Menu = new Menu(player.Index, "Chat Assistant menu", MainMenuBuilder.GetContentsMain(), new CAMain.MenuAction(MainMenuBuilder.MainMenuCallback));
 }
Esempio n. 19
0
 public void JoinChannel(CAPlayer player)
 {
     if (player == null)
         return;
     if (player.Channel >= 0 && player.Channel != this.ID && CAMain.Channels[player.Channel] != null)
         CAMain.Channels[player.Channel].LeaveChannel(player);
     player.Channel = this.ID;
     if (!this.Users.Contains(player.Index))
     {
         this.Users.Add(player.Index);
         CAMain.DisplayLog(player, 6);
         if (!this.Flags.HasFlag(ChannelFlags.BlockJoinLeaveMsg))
             NetMessage.SendData((int)PacketTypes.ChatText, -1, player.Index, String.Format("[Join] {0} has joined the channel", player.TSPlayer.Name), 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, this.ID + 1);
     }
 }
Esempio n. 20
0
 public void LeaveChannel(CAPlayer player)
 {
     this.Users.Remove(player.Index);
     player.Channel = 0;
     if (!this.Flags.HasFlag(ChannelFlags.Permanent) && this.Users.Count == 0)
         DeleteChannel(this.ID);
     else if (!this.Flags.HasFlag(ChannelFlags.BlockJoinLeaveMsg))
         NetMessage.SendData((int)PacketTypes.ChatText, -1, player.Index, String.Format("[Leave] {0} has left the channel", player.TSPlayer.Name), 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, this.ID + 1);
 }
Esempio n. 21
0
 void VaultChCreate(CAPlayer player, int chID, CommandArgs args)
 {
     try
     {
         if (Vault.Vault.ModifyBalance(args.Player.Name, -config.ChanelCreatingCost))
         {
             var newchannel = new Channel(chID, args.Parameters[0]);
             if (args.Parameters.Count > 1)
                 newchannel.Password = args.Parameters[1];
             Channels[chID] = newchannel;
             NetMessage.SendData((int)PacketTypes.ChatText, -1, -1, "New channel created", 255, Color.LightSalmon.R, Color.LightSalmon.G, Color.LightSalmon.B, chID + 1);
             Channels[chID].JoinChannel(player);
         }
         else
             args.Player.SendMessage(String.Format("Channel not found and insufficient founds to create a new channel. (costs: {0})", Vault.Vault.MoneyToString(config.ChanelCreatingCost)), Color.LightSalmon);
     }
     catch (Exception ex)
     {
         Log.ConsoleError(ex.ToString());
     }
 }