Inheritance: TerrariaPlugin
Exemplo n.º 1
0
        public static void HealPlayer(ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = (Player)sender;
                if (args.Count < 1)
                {
                    player.sendMessage("You did not specify the player, so you were healed");

                    for (int i = 0; i < player.statLifeMax - player.statLife; i++)
                    {
                        Item.NewItem((int)player.Position.X, (int)player.Position.Y, player.Width, player.Height, 58, 1, false);
                    }

                    Essentials.Log(player.Name + " healed " + player.Name + ".");
                }
                else
                {
                    try
                    {
                        Player targetPlayer = Server.GetPlayerByName(args[0]);
                        for (int i = 0; i < targetPlayer.statLifeMax - targetPlayer.statLife; i++)
                        {
                            Item.NewItem((int)targetPlayer.Position.X, (int)targetPlayer.Position.Y, targetPlayer.Width, targetPlayer.Height, 58, 1, false);
                        }

                        player.sendMessage("You have healed that player!");
                        Essentials.Log(player.Name + " healed " + targetPlayer.Name + ".");
                    }
                    catch (NullReferenceException)
                    {
                        player.sendMessage("Error: Player not online.");
                    }
                }
            }
            else
            {
                if (args.Count < 1)
                {
                    Essentials.Log("You cannot heal yourself as the console.");
                }
                else
                {
                    try
                    {
                        Player targetPlayer = Server.GetPlayerByName(args[0]);
                        for (int i = 0; i < targetPlayer.statLifeMax - targetPlayer.statLife; i++)
                        {
                            Item.NewItem((int)targetPlayer.Position.X, (int)targetPlayer.Position.Y, targetPlayer.Width, targetPlayer.Height, 58, 1, false);
                        }

                        Essentials.Log("Console healed " + targetPlayer.Name + ".");
                    }
                    catch (NullReferenceException)
                    {
                        Essentials.Log(ProgramLog.Error, "Player not online.");
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static void Kit(ISender sender, ArgumentList args)
        {
            Essentials Plugin = (Essentials)args.Plugin;

            Player player = args.GetOnlinePlayer(0);

            if (args.Count > 0)
            {
                if (KitManager.ContainsKit(args[0]))
                {
                    Kit kit = KitManager.GetKit(args[0]);
                    if (kit.ItemList != null && kit.ItemList.Count > 0)
                    {
                        foreach (KeyValuePair <Int32, Int32> ItemID in kit.ItemList)
                        {
                            Item.NewItem((int)player.Position.X, (int)player.Position.Y, player.Width, player.Height, ItemID.Key, ItemID.Value, false);
                        }

                        player.sendMessage("Recived the '" + kit.Name + "' Kit.");
                    }
                    else
                    {
                        player.sendMessage("Issue with null kit/list");
                    }
                }

                //Help ::: Shows what kits there are
                else if (args[0].Equals("help"))
                {
                    String Kits = "";
                    foreach (Kit kit in KitManager.KitList)
                    {
                        if (kit.Name.Trim().Length > 0)
                        {
                            Kits = Kits + ", " + kit.Name;
                        }
                    }
                    if (Kits.StartsWith(","))
                    {
                        Kits = Kits.Remove(0, 1).Trim();
                    }

                    if (Kits.Length > 0)
                    {
                        player.sendMessage("Available Kits: " + Kits);
                    }
                }

                //If kit does not exist
                else
                {
                    player.sendMessage("Error: specified kit " + args[0] + " does not exist. Please do /kit help");
                }
            }
            //Error message
            else
            {
                player.sendMessage("Error: You did not specify a kit! Do /kit help!");
            }
        }
Exemplo n.º 3
0
        public static void Slay(ISender sender, ArgumentList args)
        {
            var player = args.GetOnlinePlayer(0);

            NetMessage.SendData(26, -1, -1, " of unknown causes...", player.whoAmi, 0, (float)9999, (float)0);
            sender.sendMessage("OMG! You killed " + player.Name + "!", 255, 0f, 255f, 255f);
            Essentials.Log("Player " + player + " used /slay on " + player.Name);
        }
Exemplo n.º 4
0
        public static void LastCommand(ISender sender, ArgumentList args)
        {
            Essentials Plugin = (Essentials)args.Plugin;

            if (sender is Player)
            {
                if (args.Count > 1)
                {
                    if (args[1].Trim().ToLower().Equals("register"))
                    {
                        String Command = string.Join(" ", args);
                        Command = Command.Remove(0, Command.IndexOf(args[1]) + args[1].Length).Trim();
                        if (Command.Length > 0)
                        {
                            if (Plugin.lastEventByPlayer.Keys.Contains(sender.Name))
                            {
                                Plugin.lastEventByPlayer.Remove(sender.Name);
                            }

                            Plugin.lastEventByPlayer.Add(sender.Name, Command);
                            sender.sendMessage("Command registered!");
                        }
                        else
                        {
                            sender.sendMessage("Please specify a command");
                        }

                        return;
                    }
                }
                Player player = (Player)sender;
                String Message;
                Plugin.lastEventByPlayer.TryGetValue(player.Name, out Message);
                if (Message != null && Message.Length > 0)
                {
                    Essentials.Log("Executing last event: [" + Message + "]");

                    //This also calls to plugins
                    Program.commandParser.ParseAndProcess(player, Message);
                }
                else
                {
                    player.sendMessage("Error: no previous command on file");
                }
            }
            //return false;
        }
Exemplo n.º 5
0
 public static void BloodMoon(ISender sender, ArgumentList args)
 {
     if (sender is Player)
     {
         Player player = sender as Player;
         if (!Main.bloodMoon)
         {
             Main.bloodMoon = true;
             if (args.Count > 0)
             {
                 if (!args[0].ToLower().Equals("time:false"))
                 {
                     World.SetTime(53999, false, false);
                 }
             }
             Essentials.Log("Triggered blood moon phase.");
         }
         else
         {
             Server.notifyAll("Blood Moon disabled");
             Main.bloodMoon = false;
             Essentials.Log("Disabled blood moon phase.");
         }
         NetMessage.SendData((int)Packet.WORLD_DATA);
     }
     else
     {
         if (!Main.bloodMoon)
         {
             Main.bloodMoon = true;
             World.SetTime(0, false, false);
             NetMessage.SendData(25, -1, -1, "The Blood Moon is rising...", 255, 50f, 255f, 130f);
             Essentials.Log("Triggered blood moon phase.");
         }
         else
         {
             Server.notifyAll("Blood Moon disabled");
             Main.bloodMoon = false;
             Essentials.Log("Disabled blood moon phase.");
         }
         NetMessage.SendData((int)Packet.WORLD_DATA);
     }
 }
Exemplo n.º 6
0
        public static void GodMode(ISender sender, ArgumentList args)
        {
            Essentials Plugin = (Essentials)args.Plugin;

            Player player = args.GetOnlinePlayer(0);

            //if (!(sender is Player))
            //{
            //    if (!args.TryGetOnlinePlayer(1, out player))
            //    {
            //        sender.sendMessage("As a non player, Please specify one!");
            //        return;
            //    }
            //}

            if (player.HasClientMod)
            {
                //Tell the client to use God.
                bool On;
                if (Plugin.essentialsRPGPlayerList.TryGetValue(player.whoAmi, out On))
                {
                    NetMessage.SendData((int)Packets.CLIENT_MOD_GOD, player.whoAmi, -1, "", 0);
                    if (!Server.AllowTDCMRPG)
                    {
                        Plugin.essentialsRPGPlayerList.Remove(player.whoAmi);
                    }
                }
                else
                {
                    NetMessage.SendData((int)Packets.CLIENT_MOD_GOD, player.whoAmi, -1, "", 1);
                    if (!Server.AllowTDCMRPG)
                    {
                        Plugin.essentialsRPGPlayerList.Add(player.whoAmi, true);
                    }
                }

                return;
            }

            bool found         = false;
            bool godModeStatus = false;

            for (int i = 0; i < Plugin.essentialsPlayerList.Count; i++)
            {
                int    PlayerID = Plugin.essentialsPlayerList.Keys.ElementAt(i);
                Player eplayer  = Main.players[PlayerID];
                if (eplayer.Name.Equals(player.Name))
                {
                    bool GodMode = !Plugin.essentialsPlayerList.Values.ElementAt(i);
                    Plugin.essentialsPlayerList.Remove(PlayerID);
                    Plugin.essentialsPlayerList.Add(PlayerID, GodMode);
                    godModeStatus = GodMode;
                    found         = true;
                    break;
                }
            }
            if (!found)
            {
                godModeStatus = true;
                Plugin.essentialsPlayerList.Add(player.whoAmi, godModeStatus);
            }

            player.sendMessage("God Mode Status: " + godModeStatus.ToString());
        }