示例#1
0
 private static void SendErrorToPlayer(ScPlayer sPly, TSPlayer tPly, string message)
 {
     if (sPly.AlertPermissionCooldown == 0)
     {
         tPly.SendErrorMessage(message);
         sPly.AlertPermissionCooldown = 3;
     }
 }
示例#2
0
        private void SpawnMobs(Dictionary<string, int> mobs, ScPlayer sPly)
        {
            var mobList = new List<string>();
            foreach (var pair in mobs)
            {
                var amount = Math.Min(pair.Value, Main.maxNPCs);

                var npcs = TShock.Utils.GetNPCByIdOrName(pair.Key);
                if (npcs.Count == 0)
                    continue;

                if (npcs.Count > 1)
                    continue;

                var npc = npcs[0];
                if (npc.type >= 1 && npc.type < Main.maxNPCTypes && npc.type != 113)
                {
                    TSPlayer.Server.SpawnNPC(npc.type, npc.name, amount, _point.X, _point.Y, 50,
                        20);
                    mobList.Add(npc.name + " (" + amount + ")");
                }
                else if (npc.type == 113)
                {
                    if (Main.wof >= 0 || (_point.Y/16f < (Main.maxTilesY - 205)))
                        continue;
                    NPC.SpawnWOF(new Vector2(_point.X, _point.Y));
                    mobList.Add("the Wall of Flesh (" + amount + ")");
                }
            }

            TSPlayer.All.SendSuccessMessage("{0} has spawned {1}", sPly.TsPlayer.Name, string.Join(", ", mobList));

            TShock.Utils.SendLogs(
                         string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name,
                             TShock.Config.CommandSpecifier,
                             "/spawnmob " + string.Join(", ", mobList)), Color.PaleVioletRed, sPly.TsPlayer);
        }
示例#3
0
        private void SpawnBosses(Dictionary<string, int> bosses, ScPlayer sPly)
        {
            var bossList = new List<string>();
            foreach (var pair in bosses)
            {
                var npc = new NPC();
                switch (pair.Key.ToLower())
                {
                    case "*":
                    case "all":
                        int[] npcIds = {4, 13, 35, 50, 125, 126, 127, 134, 222, 245, 262, 266, 370};
                        TSPlayer.Server.SetTime(false, 0.0);
                        foreach (var i in npcIds)
                        {
                            npc.SetDefaults(i);
                            TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        }

                        bossList.Add("all bosses (" + pair.Value + ")");
                        break;
                    case "brain":
                    case "brain of cthulhu":
                        npc.SetDefaults(266);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "destroyer":
                        npc.SetDefaults(134);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "duke":
                    case "duke fishron":
                    case "fishron":
                        npc.SetDefaults(370);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "eater":
                    case "eater of worlds":
                        npc.SetDefaults(13);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "eye":
                    case "eye of cthulhu":
                        npc.SetDefaults(4);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "golem":
                        npc.SetDefaults(245);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "king":
                    case "king slime":
                        npc.SetDefaults(50);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "plantera":
                        npc.SetDefaults(262);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "prime":
                    case "skeletron prime":
                        npc.SetDefaults(127);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "queen":
                    case "queen bee":
                        npc.SetDefaults(222);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "skeletron":
                        npc.SetDefaults(35);
                        TSPlayer.Server.SetTime(false, 0.0);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add(npc.name + " (" + pair.Value + ")");
                        break;
                    case "twins":
                        TSPlayer.Server.SetTime(false, 0.0);
                        npc.SetDefaults(125);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        npc.SetDefaults(126);
                        TSPlayer.Server.SpawnNPC(npc.type, npc.name, pair.Value, _point.X, _point.Y);
                        bossList.Add("the Twins (" + pair.Value + ")");
                        break;
                    case "wof":
                    case "wall of flesh":
                        if (Main.wof >= 0)
                            return;
                        if (_point.Y/16f < Main.maxTilesY - 205)
                            break;
                        NPC.SpawnWOF(new Vector2(_point.X, _point.Y));
                        bossList.Add("the Wall of Flesh (" + pair.Value + ")");
                        break;
                }
            }

            TSPlayer.All.SendSuccessMessage("{0} has spawned {1}", sPly.TsPlayer.Name, string.Join(", ", bossList));
            TShock.Utils.SendLogs(
                          string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name,
                              TShock.Config.CommandSpecifier,
                              "/spawnboss " + string.Join(", ", bossList)), Color.PaleVioletRed, sPly.TsPlayer);
        }
示例#4
0
        public void ExecuteCommands(ScPlayer sPly)
        {
            var hasPerm = CheckPermissions(sPly.TsPlayer);

            if (!hasPerm)
                return;

            if (cooldown > 0)
            {
                if (sPly.AlertCooldownCooldown == 0)
                {
                    sPly.TsPlayer.SendErrorMessage("This sign is still cooling down. Please wait {0} more second{1}",
                        cooldown, cooldown.Suffix());
                    sPly.AlertCooldownCooldown = 3;
                }

                return;
            }

            if (_confirm && sPly.confirmSign != this)
            {
                sPly.confirmSign = this;
                sPly.TsPlayer.SendWarningMessage("Are you sure you want to execute this sign command?");
                sPly.TsPlayer.SendWarningMessage("Hit the sign again to confirm.");
                cooldown = 2;
                return;
            }

            if (_groups.Count > 0 && !_groups.Contains(sPly.TsPlayer.Group.Name))
            {
                if (sPly.AlertPermissionCooldown == 0)
                {
                    sPly.TsPlayer.SendErrorMessage("Your group does not have access to this sign");
                    sPly.AlertPermissionCooldown = 3;
                }
                return;
            }

            if (_users.Count > 0 && !_users.Contains(sPly.TsPlayer.User.Name))
            {
                if (sPly.AlertPermissionCooldown == 0)
                {
                    sPly.TsPlayer.SendErrorMessage("You do not have access to this sign");
                    sPly.AlertPermissionCooldown = 3;
                }
                return;
            }

            if (_mobs.Count > 0)
                SpawnMobs(_mobs, sPly);

            if (_bosses.Count > 0)
                SpawnBosses(_bosses, sPly);

            foreach (var cmdPair in commands)
            {
                //var args = new List<string>(cmdPair.Key);
                var cmd = cmdPair.Value;
                var cmdText = string.Join(" ", cmdPair.Key);
                cmdText = cmdText.Replace("{player}", sPly.TsPlayer.Name);
                //Create args straight from the command text, meaning no need to iterate through args to replace {player}
                var args = cmdText.Split(' ').ToList();

                //while (args.Any(s => s.Contains("{player}")))
                //	args[args.IndexOf("{player}")] = sPly.TsPlayer.Name;

                if (cmd.DoLog)
                    TShock.Utils.SendLogs(
                        string.Format("{0} executed: {1}{2} [Via sign command].", sPly.TsPlayer.Name,
                            TShock.Config.CommandSpecifier,
                            cmdText), Color.PaleVioletRed, sPly.TsPlayer);

                args.RemoveAt(0);

                cmd.CommandDelegate.Invoke(new CommandArgs(cmdText, sPly.TsPlayer, args));
            }

            cooldown = _cooldown;
            sPly.AlertCooldownCooldown = 3;
            sPly.confirmSign = null;
        }
示例#5
0
        public void ExecuteCommands(ScPlayer sPly)
        {
            CheckPermissions(sPly.TsPlayer);

            if (cooldown > 0)
            {
                if (!sPly.TsPlayer.Group.HasPermission("essentials.signs.nocd"))
                {
                    if (sPly.AlertCooldownCooldown == 0)
                    {
                        sPly.TsPlayer.SendErrorMessage("This sign is still cooling down. Please wait {0} more second{1}",
                                                       cooldown, cooldown.Suffix());
                        sPly.AlertCooldownCooldown = 3;
                    }

                    return;
                }
            }

            if (confirm && sPly.confirmSign != this)
            {
                sPly.confirmSign = this;
                sPly.TsPlayer.SendWarningMessage("Are you sure you want to execute this sign command?");
                sPly.TsPlayer.SendWarningMessage("Hit the sign again to confirm.");
                cooldown = 2;
                return;
            }

            if (_groups.Count > 0 && !_groups.Contains(sPly.TsPlayer.Group.Name))
            {
                if (sPly.AlertPermissionCooldown == 0)
                {
                    sPly.TsPlayer.SendErrorMessage("Your group does not have access to this sign");
                    sPly.AlertPermissionCooldown = 3;
                }
                return;
            }

            if (_users.Count > 0 && !_users.Contains(sPly.TsPlayer.Account.Name))
            {
                if (sPly.AlertPermissionCooldown == 0)
                {
                    sPly.TsPlayer.SendErrorMessage("You do not have access to this sign");
                    sPly.AlertPermissionCooldown = 3;
                }
                return;
            }

            foreach (var cmdPair in commands)
            {
                var cmd     = cmdPair.Value;
                var cmdText = string.Join(" ", cmdPair.Key);
                cmdText = cmdText.Replace("{player}", sPly.TsPlayer.Name);
                //Create args straight from the command text, meaning no need to iterate through args to replace {player}
                var args = cmdText.Split(' ').ToList();


                string log = string.Format("{0} executed: {1}{2} [Via sign command].",
                                           sPly.TsPlayer.Name, TShock.Config.CommandSpecifier, cmdText);

                if (!silent)
                {
                    TShock.Utils.SendLogs(log, Color.PaleVioletRed, sPly.TsPlayer);
                }
                else
                {
                    TShock.Log.Info(log);
                }

                args.RemoveAt(0);

                cmd.CommandDelegate.Invoke(new CommandArgs(cmdText, silent, sPly.TsPlayer, args));
            }

            cooldown = _cooldown;
            sPly.AlertCooldownCooldown = 3;
            sPly.confirmSign           = null;
        }