Ejemplo n.º 1
0
 private static void Set(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.Setting ||
         ChestControl.Players[args.Player.Index].GetState() == SettingState.PublicSetting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else if (args.Parameters.Count == 1)
         switch (args.Parameters[0])
         {
             case "public":
                 ChestControl.Players[args.Player.Index].SetState(SettingState.PublicSetting);
                 args.Player.SendMessage("Open a chest to protect it (public).", Color.BlueViolet);
                 break;
             case "private":
                 ChestControl.Players[args.Player.Index].SetState(SettingState.Setting);
                 args.Player.SendMessage("Open a chest to protect it (private).", Color.BlueViolet);
                 break;
             default:
                 args.Player.SendMessage("Wrong subcommand, use \"public\" or \"private\".", Color.BlueViolet);
                 break;
         }
     else
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.Setting);
         args.Player.SendMessage("Open a chest to protect it.", Color.BlueViolet);
     }
 }
Ejemplo n.º 2
0
 private static void SetPasswordChest(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.PasswordSetting ||
         ChestControl.Players[args.Player.Index].GetState() == SettingState.PasswordUnSetting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else
     {
         if (args.Parameters.Count != 1)
         {
             args.Player.SendMessage(
                 "You must enter password! Or use \"remove\" as password to remove password.", Color.Red);
             return;
         }
         if (args.Parameters[0] == "del" || args.Parameters[0] == "delete" || args.Parameters[0] == "rm" ||
             args.Parameters[0] == "remove" || args.Parameters[0] == "unlock" || args.Parameters[0] == "unset")
         {
             ChestControl.Players[args.Player.Index].SetState(SettingState.PasswordUnSetting);
             args.Player.SendMessage("Open a chest to remove password.", Color.BlueViolet);
         }
         else
         {
             ChestControl.Players[args.Player.Index].PasswordForChest = args.Parameters[0];
             ChestControl.Players[args.Player.Index].SetState(SettingState.PasswordSetting);
             args.Player.SendMessage("Open a chest to set password.", Color.BlueViolet);
         }
     }
 }
Ejemplo n.º 3
0
        public void OverrideSSI( CommandArgs args )
        {
            if( args.Parameters.Count < 1 )
            {
                args.Player.SendErrorMessage("Correct usage: /overridessi(/ossi) <player name>");
                return;
            }

            var players = tPulse.PlayerHandle.FindPlayer(args.Parameters[0]);
            if( players.Count < 1 )
            {
                args.Player.SendErrorMessage("No players match " + args.Parameters[0] + "!");
            }
            else if( players.Count > 1 )
            {
                args.Player.SendErrorMessage( players.Count + " players matched " + args.Parameters[0] + "!");
            }
            else if (tPulse.Config.ServerSideInventory)
            {
                if( players[0] != null && players[0].IsLoggedIn && !players[0].IgnoreActionsForClearingTrashCan)
                {
                    args.Player.SendSuccessMessage( players[0].Name + " has been exempted and updated.");
                    tPulse.InventoryDB.InsertPlayerData(players[0]);
                }
            }
        }
Ejemplo n.º 4
0
        protected void JoinCommand(CommandArgs args)
        {
            TPPlayer player = args.Player;

            if (args.Parameters.Count == 1)
            {
                string cname = args.Parameters[0];

                if (Manager.Contains(cname))
                {
                    foreach (Channel c in Channels)
                    {
                        if (c.ContainsPlayer(player))
                        {
                            c.Leave(player);
                        }
                    }

                    foreach (Channel c in Channels)
                    {
                        if (c.Name == cname)
                        {
                            c.Join(player);
                            player.SendInfoMessage(String.Format("Channels: You've entered {0} channel", cname));
                            break;
                        }
                    }

                }
                else
                {
                    player.SendErrorMessage(String.Format("Channels: {0} doesn't exists!", cname));
                }

            }
            else
            {
                player.SendErrorMessage("Channels: Missing or too much arguments!");
            }
        }
Ejemplo n.º 5
0
        protected void ChannelCommand(CommandArgs args)
        {
            TPPlayer player = args.Player;

            if (args.Parameters.Count > 1)
            {
                if ((player.Group.ContainsGroup("admin") || player.Group.ContainsGroup("superadmin")) && player.IsLoggedIn)
                {
                    string pram = args.Parameters[0];

                    if (pram == "add")
                    {
                        //adding channel
                        string cname = args.Parameters[1];

                        if (Manager.Contains(cname))
                        {
                            player.SendErrorMessage(String.Format("Channels: {0} already exists!"));
                        }
                        else
                        {
                            Channel c;
                            if (args.Parameters.Count == 5)
                            {
                                //with custom color
                                byte r = 0;
                                byte g = 0;
                                byte b = 0;

                                byte.TryParse(args.Parameters[2], out r);
                                byte.TryParse(args.Parameters[3], out g);
                                byte.TryParse(args.Parameters[4], out b);
                                c = new Channel(cname, r, g, b);
                            }
                            else
                            {
                                c = new Channel(cname);
                            }

                            Manager.Add(c);
                            Channels.Add(c);

                            player.SendInfoMessage(String.Format("Channels: {0} channel added with success!", cname));
                        }
                    }
                    else if (pram == "del")
                    {
                        //deleting channel
                        string cname = args.Parameters[1];

                        Channel c = RemoveChannel(cname);

                        if (c != null)
                        {
                            Manager.Remove(cname);
                            player.SendInfoMessage(String.Format("Channels: {0} channel removed!", cname));
                        }
                        else
                        {
                            player.SendErrorMessage("Channels: This channel doesn't exists!");
                        }

                    }
                    else
                    {
                        player.SendErrorMessage("Channels: Invalid command!");
                    }
                }
                else
                {
                    player.SendErrorMessage("Channels: You don't have the right to do this!");
                }
            }
            else if (args.Parameters.Count == 1 && args.Parameters[0] == "list")
            {
                //listing channels
                player.SendInfoMessage("Channels: Listing channels");
                foreach (Channel c in Channels)
                {
                    player.SendInfoMessage(String.Format("{0} : {1}", c.Name, c.Count));

                }

                player.SendInfoMessage(String.Format("{0} channel(s)", Channels.Count));
            }
            else
            {
                player.SendErrorMessage("Channels: Invalid command");
            }
        }
Ejemplo n.º 6
0
 protected void SetAterMatch(CommandArgs args)
 {
     if (args.Player.Group.ContainsGroup("superadmin"))
     {
         Setting.AfterMatchRoom.X = args.Player.TileX;
         Setting.AfterMatchRoom.Y = args.Player.TileY;
         args.Player.SendInfoMessage(String.Format("Arena: After Match Room setted at [{0}, {1}]", Setting.AfterMatchRoom.X, Setting.AfterMatchRoom.Y));
         Setting.Save(ArenaSettingFile);
     }
     else
     {
         args.Player.SendErrorMessage("Only superadmin can use this command!");
     }
 }
Ejemplo n.º 7
0
 protected void PreparePlayers(CommandArgs args)
 {
     if (args.Player.Group.ContainsGroup("superadmin") && State == ArenaState.Idle)
     {
         PrepareBattle();
     }
 }
Ejemplo n.º 8
0
 private static void CancelSet(CommandArgs args)
 {
     ChestControl.Players[args.Player.Index].SetState(SettingState.None);
     args.Player.SendMessage("Selection of chest canceled.", Color.BlueViolet);
 }
Ejemplo n.º 9
0
        private void AddItemGroup(CommandArgs args)
        {
            if (args.Parameters.Count == 2)
            {
                var items = GameResources.GetItemByIdOrName(args.Parameters[0]);
                if (items.Count == 0)
                {
                    args.Player.SendErrorMessage("Invalid item type!");
                }
                else if (items.Count > 1)
                {
                    args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched!", items.Count));
                }
                else
                {
                    var item = items[0];
                    if (item.type >= 1)
                    {
                        if(tPulse.Groups.GroupExists(args.Parameters[1]))
                        {
                            ItemBan ban = tPulse.Itembans.GetItemBanByName(item.name);

                            if(!ban.AllowedGroups.Contains(args.Parameters[1]))
                            {
                                tPulse.Itembans.AllowGroup(item.name, args.Parameters[1]);
                                args.Player.SendSuccessMessage("Banned item " + item.name + " has been allowed for group " + args.Parameters[1] + ".");
                            }
                            else
                            {
                                args.Player.SendWarningMessage("Banned item " + item.name + " is already allowed for group " + args.Parameters[1] + "!");
                            }
                        }
                        else
                        {
                            args.Player.SendErrorMessage("Group " + args.Parameters[1] + " not found!");
                        }
                    }
                    else
                    {
                        args.Player.SendErrorMessage("Invalid item type!");
                    }
                }
            }
            else
            {
                args.Player.SendErrorMessage("Invalid use: /additemgroup \"item name\" \"group name\"");
            }
        }
Ejemplo n.º 10
0
 private void AddItem(CommandArgs args)
 {
     if (args.Parameters.Count == 1)
     {
         var items = GameResources.GetItemByIdOrName(args.Parameters[0]);
         if (items.Count == 0)
         {
             args.Player.SendErrorMessage("Invalid item type!");
         }
         else if (items.Count > 1)
         {
             args.Player.SendErrorMessage(string.Format("More than one ({0}) item matched!", items.Count));
         }
         else
         {
             var item = items[0];
             if (item.type >= 1)
             {
                 tPulse.Itembans.AddNewBan(item.name);
                 args.Player.SendErrorMessage(item.name + " has been banned.");
             }
             else
             {
                 args.Player.SendErrorMessage("Invalid item type!");
             }
         }
     }
     else
     {
         args.Player.SendErrorMessage("Invalid use: /additem \"item name\" or /additem ##.");
     }
 }
Ejemplo n.º 11
0
        private void AddGroup(CommandArgs args)
        {
            if (args.Parameters.Count > 0)
            {
                String groupname = args.Parameters[0];
                args.Parameters.RemoveAt(0);
                String permissions = String.Join(",", args.Parameters);

                String response = tPulse.Groups.AddGroup(groupname, permissions);
                if (response.Length > 0)
                    args.Player.SendSuccessMessage(response);
            }
            else
            {
                args.Player.SendErrorMessage("Incorrect format: /addgroup <group name> [optional permissions]");
            }
        }
Ejemplo n.º 12
0
 public void WorldInfo(CommandArgs args)
 {
     args.Player.SendInfoMessage("World name: " + Main.worldName);
     args.Player.SendInfoMessage("World ID: " + Main.worldID);
 }
Ejemplo n.º 13
0
 public void Whitelist(CommandArgs args)
 {
     if (args.Parameters.Count == 1)
     {
         using (var tw = new StreamWriter(FileTools.WhitelistPath, true))
         {
             tw.WriteLine(args.Parameters[0]);
         }
         args.Player.SendSuccessMessage("Added " + args.Parameters[0] + " to the whitelist.");
     }
 }
Ejemplo n.º 14
0
 public void ServerInfo(CommandArgs args)
 {
     args.Player.SendInfoMessage("Memory usage: " + Process.GetCurrentProcess().WorkingSet64);
     args.Player.SendInfoMessage("Allocated memory: " + Process.GetCurrentProcess().VirtualMemorySize64);
     args.Player.SendInfoMessage("Total processor time: " + Process.GetCurrentProcess().TotalProcessorTime);
     args.Player.SendInfoMessage("WinVer: " + Environment.OSVersion);
     args.Player.SendInfoMessage("Proc count: " + Environment.ProcessorCount);
     args.Player.SendInfoMessage("Machine name: " + Environment.MachineName);
 }
Ejemplo n.º 15
0
 public void SaveSSI(CommandArgs args )
 {
     if (tPulse.Config.ServerSideInventory)
     {
         args.Player.SendSuccessMessage("SSI has been saved.");
         foreach (TPPlayer player in tPulse.Players)
         {
             if (player != null && player.IsLoggedIn && !player.IgnoreActionsForClearingTrashCan)
             {
                 tPulse.InventoryDB.InsertPlayerData(player);
             }
         }
     }
 }
Ejemplo n.º 16
0
        private static void UnLockChest(CommandArgs args)
        {
            if (ChestControl.Players[args.Player.Index].GetState() == SettingState.UnLocking)
            {
                ChestControl.Players[args.Player.Index].PasswordForChest = "";
                ChestControl.Players[args.Player.Index].SetState(SettingState.None);
                args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
            }
            else
            {
                if (args.Parameters.Count != 1)
                {
                    args.Player.SendMessage("You must enter password to unlock chest!", Color.Red);
                    return;
                }

                ChestControl.Players[args.Player.Index].PasswordForChest = args.Parameters[0];
                ChestControl.Players[args.Player.Index].SetState(SettingState.UnLocking);
                args.Player.SendMessage("Open a chest to unlock it.", Color.BlueViolet);
            }
        }
Ejemplo n.º 17
0
 private static void UnSet(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.Deleting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.Deleting);
         args.Player.SendMessage("Open a chest to delete it's protection.", Color.BlueViolet);
     }
 }
Ejemplo n.º 18
0
        private void Annoy(CommandArgs args)
        {
            if (args.Parameters.Count != 2)
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /annoy <player> <seconds to annoy>");
                return;
            }
            int annoy = 5;
            int.TryParse(args.Parameters[1], out annoy);

            var players = tPulse.PlayerHandle.FindPlayer(args.Parameters[0]);
            if (players.Count == 0)
                args.Player.SendErrorMessage("Invalid player!");
            else if (players.Count > 1)
                args.Player.SendErrorMessage("More than one player matched!");
            else
            {
                var ply = players[0];
                args.Player.SendSuccessMessage("Annoying " + ply.Name + " for " + annoy + " seconds.");
                (new Thread(ply.Whoopie)).Start(annoy);
            }
        }
Ejemplo n.º 19
0
        private void AuthToken(CommandArgs args)
        {
            if (TPulse.AuthToken == 0)
            {
                args.Player.SendWarningMessage("Auth is disabled. This incident has been logged.");
                Log.Warn(args.Player.IP + " attempted to use /auth even though it's disabled.");
                return;
            }
            int givenCode = Convert.ToInt32(args.Parameters[0]);
            if (givenCode == TPulse.AuthToken && args.Player.Group.Name != "superadmin")
            {
                try
                {
                    tPulse.Users.AddUser(new User(args.Player.IP, "", "", "superadmin"));
                    args.Player.Group = tPulse.GetGroup("superadmin");
                    args.Player.SendInfoMessage("This IP address is now superadmin. Please perform the following command:");
                    args.Player.SendInfoMessage("/user add <username>:<password> superadmin");
                    args.Player.SendInfoMessage("Creates: <username> with the password <password> as part of the superadmin group.");
                    args.Player.SendInfoMessage("Please use /login <username> <password> to login from now on.");
                    args.Player.SendInfoMessage("If you understand, please /login <username> <password> now, and type /auth-verify.");
                }
                catch (UserManagerException ex)
                {
                    Log.ConsoleError(ex.ToString());
                    args.Player.SendErrorMessage(ex.Message);
                }
                return;
            }

            if (args.Player.Group.Name == "superadmin")
            {
                args.Player.SendInfoMessage("Please disable the auth system!");
                args.Player.SendInfoMessage("This IP address is now superadmin. Please perform the following command:");
                args.Player.SendInfoMessage("/user add <username>:<password> superadmin");
                args.Player.SendInfoMessage("Creates: <username> with the password <password> as part of the superadmin group.");
                args.Player.SendInfoMessage("Please use /login <username> <password> to login from now on.");
                args.Player.SendInfoMessage("If you understand, please /login <username> <password> now, and type /auth-verify.");
                return;
            }

            args.Player.SendErrorMessage("Incorrect auth code. This incident has been logged.");
            Log.Warn(args.Player.IP + " attempted to use an incorrect auth code.");
        }
Ejemplo n.º 20
0
        private void AuthVerify(CommandArgs args)
        {
            if (TPulse.AuthToken == 0)
            {
                args.Player.SendWarningMessage("It appears that you have already turned off the auth token.");
                args.Player.SendWarningMessage("If this is a mistake, delete auth.lck.");
                return;
            }

            if (!args.Player.IsLoggedIn)
            {
                args.Player.SendWarningMessage("You must be logged in to disable the auth system.");
                args.Player.SendWarningMessage("This is a security measure designed to prevent insecure administration setups.");
                args.Player.SendWarningMessage("Please re-run /auth and read the instructions!");
                return;
            }

            args.Player.SendSuccessMessage("Your new account has been verified, and the /auth system has been turned off.");
            args.Player.SendSuccessMessage("You can always use the /user command to manage players. Don't just delete the auth.lck.");
            args.Player.SendSuccessMessage("Thank you for using TPulse!");
            FileTools.CreateFile(Path.Combine(TPulse.SavePath, "auth.lck"));
            File.Delete(Path.Combine(TPulse.SavePath, "authcode.txt"));
            TPulse.AuthToken = 0;
        }
Ejemplo n.º 21
0
        protected void AssignPlayerTeam(CommandArgs args)
        {
            if (args.Player.Group.ContainsGroup("superadmin"))
            {
                if (args.Parameters.Count != 2)
                {
                    args.Player.SendInfoMessage("Arena: you must specify a player name and a team id");
                    args.Player.SendInfoMessage("Arena: /aassign [player] [1|2] ");
                }
                else
                {
                    string pname = args.Parameters[0];
                    int teamid = int.MinValue;
                    int.TryParse(args.Parameters[1], out teamid);
                    TPPlayer tp = tPulse.GetPlayerByName(pname);

                    if (tp == null)
                    {
                        args.Player.SendErrorMessage(String.Format("Arena: {0} not found!", pname));
                    }
                    else
                    {
                        if (IsInTeam(tp))
                        {
                            args.Player.SendErrorMessage(String.Format("Arena: {0} is already assigned to a team!", pname));
                            return;
                        }

                        if (teamid == 1)
                        {
                            Team1.Add(tp);
                            args.Player.SendInfoMessage(String.Format("Arena: {0} added to the team 1", pname));
                        }
                        else if (teamid == 2)
                        {
                            Team2.Add(tp);
                            args.Player.SendInfoMessage(String.Format("Arena: {0} added to the team 2", pname));
                        }
                        else
                        {
                            args.Player.SendErrorMessage("Arena: invalid team id!");
                        }
                    }
                }
            }
            else
            {
                args.Player.SendErrorMessage("Only superadmin can use this command!");
            }
        }
Ejemplo n.º 22
0
        private void Ban(CommandArgs args)
        {
            if (args.Parameters.Count == 0 || args.Parameters[0].ToLower() == "help")
            {
                args.Player.SendInfoMessage("Syntax: /ban [option] [arguments]");
                args.Player.SendInfoMessage("Options: list, listip, clear, add, addip, del, delip");
                args.Player.SendInfoMessage("Arguments: list, listip, clear [code], add [name], addip [ip], del [name], delip [name]");
                args.Player.SendInfoMessage("In addition, a reason may be provided for all new bans after the arguments.");
                return;
            }
            if (args.Parameters[0].ToLower() == "list")
            {
                #region List bans
                if (tPulse.Bans.GetBans().Count == 0)
                {
                    args.Player.SendErrorMessage("There are currently no players banned.");
                    return;
                }

                string banString = "";
                foreach (Ban b in tPulse.Bans.GetBans())
                {

                    if (b.Name.Trim() == "")
                    {
                        continue;
                    }

                    if (banString.Length == 0)
                    {
                        banString = b.Name;
                    }
                    else
                    {
                        int length = banString.Length;
                        while (length > 60)
                        {
                            length = length - 60;
                        }
                        if (length + b.Name.Length >= 60)
                        {
                            banString += "|, " + b.Name;
                        }
                        else
                        {
                            banString += ", " + b.Name;
                        }
                    }
                }

                String[] banStrings = banString.Split('|');

                if (banStrings.Length == 0)
                {
                    args.Player.SendErrorMessage("There are currently no players with valid names banned.");
                    return;
                }

                if (banStrings[0].Trim() == "")
                {
                    args.Player.SendErrorMessage("There are currently no bans with valid names found.");
                    return;
                }

                args.Player.SendInfoMessage("List of banned players:");
                foreach (string s in banStrings)
                {
                    args.Player.SendInfoMessage(s);
                }
                return;
                #endregion List bans
            }

            if (args.Parameters[0].ToLower() == "listip")
            {
                #region List ip bans
                if (tPulse.Bans.GetBans().Count == 0)
                {
                    args.Player.SendWarningMessage("There are currently no players banned.");
                    return;
                }

                string banString = "";
                foreach (Ban b in tPulse.Bans.GetBans())
                {

                    if (b.IP.Trim() == "")
                    {
                        continue;
                    }

                    if (banString.Length == 0)
                    {
                        banString = b.IP;
                    }
                    else
                    {
                        int length = banString.Length;
                        while (length > 60)
                        {
                            length = length - 60;
                        }
                        if (length + b.Name.Length >= 60)
                        {
                            banString += "|, " + b.IP;
                        }
                        else
                        {
                            banString += ", " + b.IP;
                        }
                    }
                }

                String[] banStrings = banString.Split('|');

                if (banStrings.Length == 0)
                {
                    args.Player.SendErrorMessage("There are currently no players with valid IPs banned.");
                    return;
                }

                if (banStrings[0].Trim() == "")
                {
                    args.Player.SendErrorMessage("There are currently no bans with valid IPs found.");
                    return;
                }

                args.Player.SendInfoMessage("List of IP banned players:");
                foreach (string s in banStrings)
                {
                    args.Player.SendInfoMessage(s);
                }
                return;
                #endregion List ip bans
            }

            if (args.Parameters.Count >= 2)
            {
                if (args.Parameters[0].ToLower() == "add")
                {
                    #region Add ban
                    string plStr = args.Parameters[1];
                    var players = tPulse.PlayerHandle.FindPlayer(plStr);
                    if (players.Count == 0)
                    {
                        args.Player.SendErrorMessage("Invalid player!");
                    }
                    else if (players.Count > 1)
                    {
                        var plrMatches = "";
                        foreach (TPPlayer plr in players)
                        {
                            if (plrMatches.Length != 0)
                            {
                                plrMatches += ", " + plr.Name;
                            }
                            else
                            {
                                plrMatches += plr.Name;
                            }
                        }
                        args.Player.SendErrorMessage("More than one player matched! Matches: " + plrMatches);
                    }
                    else
                    {
                        string reason = args.Parameters.Count > 2
                                            ? String.Join(" ", args.Parameters.GetRange(2, args.Parameters.Count - 2))
                                            : "Misbehavior.";
                        if (!tPulse.Ban(players[0], reason, !args.Player.RealPlayer, args.Player.Name))
                        {
                            args.Player.SendErrorMessage("You can't ban another admin!");
                        }
                    }
                    return;
                    #endregion Add ban
                }
                else if (args.Parameters[0].ToLower() == "addip")
                {
                    #region Add ip ban
                    string ip = args.Parameters[1];
                    string reason = args.Parameters.Count > 2
                                        ? String.Join(" ", args.Parameters.GetRange(2, args.Parameters.Count - 2))
                                        : "Manually added IP address ban.";
                    tPulse.Bans.AddBan(ip, "", reason);
                    args.Player.SendSuccessMessage(ip + " banned.");
                    return;
                    #endregion Add ip ban
                }
                else if (args.Parameters[0].ToLower() == "delip")
                {
                    #region Delete ip ban
                    var ip = args.Parameters[1];
                    var ban = tPulse.Bans.GetBanByIp(ip);
                    if (ban != null)
                    {
                        if (tPulse.Bans.RemoveBan(ban.IP))
                            args.Player.SendSuccessMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP));
                        else
                            args.Player.SendErrorMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP));
                    }
                    else
                    {
                        args.Player.SendErrorMessage(string.Format("No bans for ip {0} exist", ip));
                    }
                    return;
                    #endregion Delete ip ban
                }
                else if (args.Parameters[0].ToLower() == "del")
                {
                    #region Delete ban
                    string plStr = args.Parameters[1];
                    var ban = tPulse.Bans.GetBanByName(plStr, false);
                    if (ban != null)
                    {
                        if (tPulse.Bans.RemoveBan(ban.Name, true))
                            args.Player.SendSuccessMessage(string.Format("Unbanned {0} ({1})!", ban.Name, ban.IP));
                        else
                            args.Player.SendErrorMessage(string.Format("Failed to unban {0} ({1})!", ban.Name, ban.IP));
                    }
                    else
                    {
                        args.Player.SendErrorMessage(string.Format("No bans for player {0} exist", plStr));
                    }
                    return;
                    #endregion Delete ban
                }

                #region Clear bans
                if (args.Parameters[0].ToLower() == "clear")
                {
                    if (args.Parameters.Count < 1 && ClearBansCode == -1)
                    {
                        ClearBansCode = new Random().Next(0, short.MaxValue);
                        args.Player.SendInfoMessage("ClearBans Code: " + ClearBansCode);
                        return;
                    }
                    if (args.Parameters.Count < 1)
                    {
                        args.Player.SendErrorMessage("Invalid syntax! Proper syntax: /ban clear <code>");
                        return;
                    }

                    int num;
                    if (!int.TryParse(args.Parameters[1], out num))
                    {
                        args.Player.SendErrorMessage("Invalid syntax! Expected a number, didn't get one.");
                        return;
                    }

                    if (num == ClearBansCode)
                    {
                        ClearBansCode = -1;
                        if (tPulse.Bans.ClearBans())
                        {
                            Log.ConsoleInfo("Bans cleared.");
                            args.Player.SendSuccessMessage("Bans cleared.");
                        }
                        else
                        {
                            args.Player.SendErrorMessage("Failed to clear bans.");
                        }
                    }
                    else
                    {
                        args.Player.SendErrorMessage("Incorrect clear code.");
                    }
                }
                return;
                #endregion Clear bans
            }
            args.Player.SendErrorMessage("Invalid syntax or old command provided.");
            args.Player.SendErrorMessage("Type /ban help for more information.");
        }
Ejemplo n.º 23
0
 protected void ResetTeams(CommandArgs args)
 {
     if (args.Player.Group.ContainsGroup("superadmin"))
     {
         Team1.Clear();
         Team2.Clear();
         args.Player.SendInfoMessage("Arena: Team cleared!");
     }
     else
     {
         args.Player.SendErrorMessage("Arena: You can't do this!");
     }
 }
Ejemplo n.º 24
0
 private static void SetPublicChest(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.PublicSetting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.PublicSetting);
         args.Player.SendMessage("Open a chest to set/unset it public.", Color.BlueViolet);
     }
 }
Ejemplo n.º 25
0
        protected void SetTeamStart(CommandArgs args)
        {
            if (args.Player.Group.ContainsGroup("superadmin"))
            {
                if (args.Parameters.Count == 0)
                {
                    args.Player.SendInfoMessage("You must specify team index [1|2] after /asetstart");
                }
                else
                {
                    int teamid = int.MinValue;
                    int.TryParse(args.Parameters[0], out teamid);

                    if (teamid == 1)
                    {

                        Setting.TeamStart1.X = args.Player.TileX;
                        Setting.TeamStart1.Y = args.Player.TileY;
                        args.Player.SendInfoMessage(String.Format("Arena: Team 1 Starting position set at : [{0}, {1}]", Setting.TeamStart1.X, Setting.TeamStart1.Y));
                        Setting.Save(ArenaSettingFile);
                    }
                    else if (teamid == 2)
                    {
                        Setting.TeamStart2.X = args.Player.TileX;
                        Setting.TeamStart2.Y = args.Player.TileY;
                        args.Player.SendInfoMessage(String.Format("Arena: Team 2 Starting position set at : [{0}, {1}]", Setting.TeamStart2.X, Setting.TeamStart2.Y));
                        Setting.Save(ArenaSettingFile);
                    }
                    else
                    {
                        args.Player.SendErrorMessage("Arena: Invalid team id!");
                    }

                }

            }
            else
            {
                args.Player.SendErrorMessage("Only superadmin can use this command!");
            }
        }
Ejemplo n.º 26
0
 private static void SetRefillChest(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.RefillSetting ||
         ChestControl.Players[args.Player.Index].GetState() == SettingState.PasswordUnSetting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else if (args.Parameters.Count == 1)
     {
         if (args.Parameters[0] == "unset" || args.Parameters[0] == "unlock" || args.Parameters[0] == "remove" ||
             args.Parameters[0] == "rm" || args.Parameters[0] == "delete" || args.Parameters[0] == "del")
         {
             ChestControl.Players[args.Player.Index].SetState(SettingState.RefillUnSetting);
             args.Player.SendMessage("Open a chest to remove refill.", Color.BlueViolet);
         }
     }
     else
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.RefillSetting);
         args.Player.SendMessage("Open a chest to set refill.", Color.BlueViolet);
     }
 }
Ejemplo n.º 27
0
        protected void ChannelMessage(CommandArgs args)
        {
            TPPlayer player = args.Player;

            Channel pChannel = null;

            foreach (Channel c in Channels)
            {
                if (c.ContainsPlayer(player))
                {
                    pChannel = c;
                    break;
                }
            }

            if (pChannel == null)
            {
                player.SendErrorMessage("Channels: You're not in a channel!");
            }
            else
            {
                string message = "";

                for(int i=0; i<args.Parameters.Count; i++)
                {
                    message += args.Parameters[i] + " ";
                }

                pChannel.Send(player, message);
            }
        }
Ejemplo n.º 28
0
 private static void SetRegionChest(CommandArgs args)
 {
     if (ChestControl.Players[args.Player.Index].GetState() == SettingState.RegionSetting)
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.None);
         args.Player.SendMessage("You are no longer selecting a chest.", Color.BlueViolet);
     }
     else
     {
         ChestControl.Players[args.Player.Index].SetState(SettingState.RegionSetting);
         args.Player.SendMessage("Open a chest in region to set/unset it region shareable.", Color.BlueViolet);
     }
 }
Ejemplo n.º 29
0
        protected void LeaveCommand(CommandArgs args)
        {
            TPPlayer player = args.Player;

            foreach (Channel c in Channels)
            {
                if (c.ContainsPlayer(player))
                {
                    c.Leave(player);
                    player.SendInfoMessage("Channels: Channel left");
                    return;
                }
            }

            player.SendErrorMessage("Channels: You're not in any channel!");
        }
Ejemplo n.º 30
0
 private void WoF(CommandArgs args)
 {
     if (Main.wof >= 0 || (args.Player.Y / 16f < (Main.maxTilesY - 205)))
     {
         args.Player.SendMessage("Can't spawn Wall of Flesh!", Color.Red);
         return;
     }
     NPC.SpawnWOF(new Vector2(args.Player.X, args.Player.Y));
     Utils.Broadcast(string.Format("{0} has spawned Wall of Flesh!", args.Player.Name));
 }