Ejemplo n.º 1
0
 private void OnUpdate(EventArgs e)
 {
     if (DateTime.Now.Minute - lastTime.Minute > config.AutoRefillTimerInMinutes)
     {
         lastTime = DateTime.Now;
         if (config.ReplenChests)
         {
             TShock.Log.ConsoleInfo("Auto generating chests...");
             PrivateReplenisher(GenType.chests, config.ChestAmount);
         }
         if (config.ReplenLifeCrystals)
         {
             TShock.Log.ConsoleInfo("Auto generating life crystals...");
             PrivateReplenisher(GenType.lifecrystals, config.LifeCrystalAmount);
         }
         if (config.ReplenOres)
         {
             TShock.Log.ConsoleInfo("Auto generating ores...");
             var    obj = new Terraria.ID.TileID();
             ushort oretype;
             try
             {
                 foreach (string s in config.OreToReplen)
                 {
                     oretype = (ushort)obj.GetType().GetField(s.FirstCharToUpper()).GetValue(obj);
                     PrivateReplenisher(GenType.ore, config.OreAmount, oretype);
                 }
             }
             catch (ArgumentException) { }
         }
         if (config.ReplenPots)
         {
             TShock.Log.ConsoleInfo("Auto generating pots...");
             PrivateReplenisher(GenType.pots, config.PotsAmount);
         }
         if (config.ReplenTrees)
         {
             TShock.Log.ConsoleInfo("Auto generating trees...");
             PrivateReplenisher(GenType.trees, config.TreesAmount);
         }
     }
 }
Ejemplo n.º 2
0
        public void Replen(CommandArgs args)
        {
            GenType type    = GenType.ore;
            int     amount  = -1;
            ushort  oretype = 0;
            int     counter = 0;

            if (args.Parameters.Count >= 2 && Enum.TryParse <GenType>(args.Parameters[0], true, out type) && int.TryParse(args.Parameters[1], out amount))
            {
                if (type == GenType.ore)
                {
                    if (args.Parameters.Count < 3)
                    {
                        args.Player.SendErrorMessage("Please enter a valid ore type.");
                        return;
                    }
                    var obj = new Terraria.ID.TileID();
                    try { oretype = (ushort)obj.GetType().GetField(args.Parameters[2].FirstCharToUpper()).GetValue(obj); }
                    catch (ArgumentException) { args.Player.SendErrorMessage("Please enter a valid ore type."); }
                }
                else if (type == GenType.trees)
                {
                    if (args.Parameters.Count >= 3)
                    {
                        args.Player.SendInfoMessage("CAUTION: The number entered is not the number of trees total. It refers to the number of batches of trees to generate.");
                    }
                }
                if (PrivateReplenisher(type, amount, out counter, oretype, args))
                {
                    args.Player.SendInfoMessage(type.ToString().FirstCharToUpper() + " generated successfully.");
                    return;
                }
                args.Player.SendErrorMessage("Failed to generate all the " + type.ToString() + ". Generated " + counter + " " + type.ToString() + ".");
            }
            else
            {
                args.Player.SendErrorMessage("Incorrect usage. Correct usage: /replen <ore|chests|pots|lifecrystals|altars|trees|floatingisland> <amount> (oretype)\r\nNote: when generating trees, the amount is in batches not specific trees.");
            }
        }
Ejemplo n.º 3
0
 private void OnUpdate(EventArgs e)
 {
     if (DateTime.Now.Minute - lastTime.Minute > config.AutoRefillTimerInMinutes)
     {
         lastTime = DateTime.Now;
         if (config.ReplenChests)
         {
             TShock.Log.ConsoleInfo("Auto generating chests...");
             PrivateReplenisher(GenType.chests, config.ChestAmount);
         }
         if (config.ReplenLifeCrystals)
         {
             TShock.Log.ConsoleInfo("Auto generating life crystals...");
             PrivateReplenisher(GenType.lifecrystals, config.LifeCrystalAmount);
         }
         if (config.ReplenOres)
         {
             TShock.Log.ConsoleInfo("Auto generating ores...");
             var obj = new Terraria.ID.TileID();
             ushort oretype;
             try
             {
                 foreach (string s in config.OreToReplen)
                 {
                     oretype = (ushort)obj.GetType().GetField(s.FirstCharToUpper()).GetValue(obj);
                     PrivateReplenisher(GenType.ore, config.OreAmount, oretype);
                 }
             }
             catch (ArgumentException) { }
         }
         if (config.ReplenPots)
         {
             TShock.Log.ConsoleInfo("Auto generating pots...");
             PrivateReplenisher(GenType.pots, config.PotsAmount);
         }
         if (config.ReplenTrees)
         {
             TShock.Log.ConsoleInfo("Auto generating trees...");
             PrivateReplenisher(GenType.trees, config.TreesAmount);
         }
     }
 }
Ejemplo n.º 4
0
 public void Replen(CommandArgs args)
 {
     GenType type = GenType.ore;
     int amount = -1;
     ushort oretype = 0;
     int counter = 0;
     if (args.Parameters.Count >= 2 && Enum.TryParse<GenType>(args.Parameters[0], true, out type) && int.TryParse(args.Parameters[1], out amount))
     {
         if (type == GenType.ore)
         {
             if (args.Parameters.Count < 3)
             {
                 args.Player.SendErrorMessage("Please enter a valid ore type.");
                 return;
             }
             var obj = new Terraria.ID.TileID();
             try { oretype = (ushort)obj.GetType().GetField(args.Parameters[2].FirstCharToUpper()).GetValue(obj); }
             catch (ArgumentException) { args.Player.SendErrorMessage("Please enter a valid ore type."); }
         }
         else if (type == GenType.trees)
         {
             if (args.Parameters.Count >= 3)
                 args.Player.SendInfoMessage("CAUTION: The number entered is not the number of trees total. It refers to the number of batches of trees to generate.");
         }
         if (PrivateReplenisher(type, amount, out counter, oretype, args))
         {
             args.Player.SendInfoMessage(type.ToString().FirstCharToUpper() + " generated successfully.");
             return;
         }
         args.Player.SendErrorMessage("Failed to generate all the " + type.ToString() + ". Generated " + counter + " " + type.ToString() + ".");
     }
     else
         args.Player.SendErrorMessage("Incorrect usage. Correct usage: /replen <ore|chests|pots|lifecrystals|altars|trees|floatingisland> <amount> (oretype)\r\nNote: when generating trees, the amount is in batches not specific trees.");
 }