Ejemplo n.º 1
0
        ////////////////

        /// @private
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 1)
            {
                LogHelpers.Log("ModLockWorldToggleCommand - Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                if (!UserHelpers.HasBasicServerPrivilege(caller.Player))
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            if (ModLockService.IsWorldLocked())
            {
                caller.Reply("World unlocked.", Color.Lime);
                ModLockService.UnlockWorld();
            }
            else
            {
                caller.Reply("World locked.", Color.Lime);
                ModLockService.LockWorld();
            }
        }
Ejemplo n.º 2
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            try {
                string className = args[0];
                string fieldName = args[1];

                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    foreach (var type in assembly.GetTypes())
                    {
                        if (type.Name == className)
                        {
                            foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic))
                            {
                                if (field.Name == fieldName)
                                {
                                    QuickTweakTool.AddTweak(field, $"{className}.{fieldName}");
                                    caller.Reply($"Quick tweak found and added for {className}.{fieldName}");
                                    return;
                                }
                            }
                        }
                    }
                }
                caller.Reply($"Static field {className}.{fieldName} not found");
            }
            catch (Exception) {
                throw;
            }
        }
Ejemplo n.º 3
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length > 0)
            {
                if (!CommandManager.GetCommand(caller, args[0], out ModCommand mc))
                {
                    throw new UsageException("Unknown command: " + args[0], Color.Red);
                }
                if (mc != null)
                {
                    caller.Reply(mc.Usage);
                    if (!string.IsNullOrEmpty(mc.Description))
                    {
                        caller.Reply(mc.Description);
                    }
                }
                return;
            }

            var help = CommandManager.GetHelp(caller.CommandType);

            caller.Reply(caller.CommandType + " Commands:", Color.Yellow);

            foreach (var entry in help)
            {
                caller.Reply(entry.Item1 + "   " + entry.Item2);
            }

            if (Main.netMode == 1)
            {
                //send the command to the server
                ChatHelper.SendChatMessageFromClient(new ChatMessage(input));
            }
        }
Ejemplo n.º 4
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length < 2 || args.Length > 2)
            {
                caller.Reply("Usage: " + Usage, new Color(255, 0, 0));
                return;
            }
            float n0;
            bool  i0 = float.TryParse(args[0], out n0);
            float n1;
            bool  i1 = float.TryParse(args[1], out n1);

            if (i0 && i1)
            {
                caller.Reply(n0 + " - " + n1 + " = " + (n0 - n1));
            }
            else
            {
                if (i0)
                {
                    caller.Reply("'" + args[0] + "' needs to be a number.", new Color(255, 0, 0));
                    return;
                }
                if (i1)
                {
                    caller.Reply("'" + args[1] + "' needs to be a number.", new Color(255, 0, 0));
                    return;
                }
                caller.Reply("'" + args[0] + "' and '" + args[1] + "' need to be numbers.", new Color(255, 0, 0));
                return;
            }
        }
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 2)
            {
                throw new HamstarException("No server.");
            }

            var mymod = (OnARailMod)this.mod;

            if (!mymod.Config.DebugModeEnableTrainRespawnCommand)
            {
                if (!UserHelpers.HasBasicServerPrivilege(caller.Player))
                {
                    caller.Reply("Train respawning disabled by config.", Color.Red);
                    return;
                }
                else
                {
                    Main.NewText("Priviledged player " + caller.Player.name + " respawns train.", Color.LightSteelBlue);
                }
            }

            int who = TrainEntity.FindMyTrain(caller.Player);

            if (who != -1)
            {
                CustomEntityManager.RemoveEntityByWho(who);
            }

            PacketProtocolRequestToServer.QuickRequest <TrainSpawnProtocol>();

            caller.Reply("Spawning train...", Color.LimeGreen);
        }
Ejemplo n.º 6
0
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player);

                if (!hasPriv)
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            var mymod = (ResetModeMod)this.mod;

            try {
                if (mymod.Session.StartSession())
                {
                    caller.Reply("Reset mode begun! This will continue until for each new world /rm-stop is called.", Color.YellowGreen);
                }
                else
                {
                    caller.Reply("Reset mode is already in session.", Color.Red);
                }
            } catch (Exception e) {
                LogHelpers.Log("!ResetMode.Commands.ResetModeStart - Failed to start: " + e.ToString());
                caller.Reply("Reset mode could not be started.", Color.Red);
            }
        }
Ejemplo n.º 7
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "fs":
                case "failsafe":
                    EmoticonHandler.failsafe = new[] { 0 };
                    caller.Reply("Failsafe cache cleared.");
                    break;

                case "cache":
                case "c":
                    EmoticonHandler.cache.Clear();
                    caller.Reply("Since now we use store, clearing cache only clear texture references.");
                    break;

                default:
                    caller.Reply(Usage);
                    return;
                }
            }
            else
            {
                caller.Reply(Usage);
            }
        }
Ejemplo n.º 8
0
 public override void Action(CommandCaller caller, string input, string[] args)
 {
     if (TerramonPlayer.starterNotChosen)
     {
         if (args.Length == 0)
         {
             caller.Reply("Ready to pick your Starter Pokémon? There are three options to choose from; [c/33FF33:Bulbasaur,] [c/00FFFF:Squirtle,] and [c/FF8C00:Charmander.]");
             caller.Reply("[c/C0C0C0:/choose (bulbasaur | squirtle | charmander)]");
             return;
         }
         if (args[0].ToLower() == "bulbasaur")
         {
             Main.NewText("You chose [c/33FF33:Bulbasaur, the Seed Pokémon.] Great choice!");
             TerramonPlayer.starterNotChosen = false;
             Item.NewItem(Main.LocalPlayer.getRect(), mod.ItemType("BulbasaurBall"));
         }
         if (args[0].ToLower() == "squirtle")
         {
             Main.NewText("You chose [c/00FFFF:Squirtle, the Tiny Turtle Pokémon.] Great choice!");
             TerramonPlayer.starterNotChosen = false;
         }
         if (args[0].ToLower() == "charmander")
         {
             Main.NewText("You chose [c/FF8C00:Charmander, the Fire Lizard Pokémon.] Great choice!");
             TerramonPlayer.starterNotChosen = false;
         }
     }
     else
     {
         Main.NewText("[c/FFA500:You've already chosen your Starter Pokémon!]");
     }
 }
Ejemplo n.º 9
0
 void Help(CommandCaller caller)
 {
     caller.Reply("/tt help");
     caller.Reply("  Display this information.");
     caller.Reply("/tt hand");
     caller.Reply("  Get information about item that you hold.");
 }
        ////////////////

        /// @private
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                LogHelpers.Warn("Not supposed to run on client.");
                return;
            }

            var cutMngr = CutsceneManager.Instance;
            var introId = new CutsceneID(CutsceneLibMod.Instance, typeof(IntroCutscene));

            if (cutMngr.CanBeginCutscene(false, introId, caller.Player, out string result))
            {
                if (cutMngr.TryBeginCutscene(false, introId, caller.Player, true, out result))
                {
                    caller.Reply(result, Color.Lime);
                }
                else
                {
                    caller.Reply(result, Color.Yellow);
                }
            }
            else
            {
                caller.Reply(result, Color.Red);
            }
        }
Ejemplo n.º 11
0
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 1)
            {
                LogHelpers.Log("!ResetMode.Commands.ResetModeStopCommand - Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player);

                if (!hasPriv)
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            var mymod = (ResetModeMod)this.mod;

            if (ResetModeAPI.StopSession())
            {
                caller.Reply("Reset mode ended.", Color.YellowGreen);
            }
            else
            {
                caller.Reply("Reset mode is not in session.", Color.Red);
            }
        }
Ejemplo n.º 12
0
        ////////////////

        /// @private
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                if (!UserHelpers.HasBasicServerPrivilege(caller.Player))
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            if (!ModHelpersMod.Config.ModCallCommandEnabled)
            {
                throw new UsageException("Mod.Call() command disabled by settings.");
            }

            if (args.Length < 2)
            {
                if (args.Length == 0)
                {
                    throw new UsageException("No arguments given.");
                }
                else
                {
                    throw new UsageException("More arguments needed.");
                }
            }

            Mod callmod = null;

            try {
                callmod = ModLoader.GetMod(args[0]);
                if (callmod == null)
                {
                    throw new ModHelpersException("Bad call mod.");
                }
            } catch (Exception) {
                throw new UsageException("Invald mod name " + args[0]);
            }

            try {
                object[] callArgs = new object[args.Length - 1];

                for (int i = 1; i < args.Length; i++)
                {
                    callArgs[i - 1] = DotNetHelpers.ParseToInferredPrimitiveType(args[i]);
                }

                callmod.Call(callArgs);
            } catch (Exception e) {
                caller.Reply(e.Message, Color.Red);
            }
        }
Ejemplo n.º 13
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            PrimalZergPlayer modPlayer = caller.Player.GetModPlayer <PrimalZergPlayer>();

            caller.Reply("spawn rate boost of the concoction : " + modPlayer.zergMucusSpawnRate.ToString(), Color.Purple);
            caller.Reply("spawn cap boost of the concoction : " + modPlayer.zergMucusMaxSpawns.ToString(), Color.Purple);
            PrimalZerg.showSpawnInfo = true;
        }
Ejemplo n.º 14
0
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            var mymod = (IntrinsicsMod)this.mod;

            if (!mymod.Config.DebugModeCheat)
            {
                caller.Reply("Cheat mode not active. See configs.", Color.Red);
                return;
            }

            if (Main.netMode == 1)
            {
                LogHelpers.Warn("Not supposed to run on client.");
                return;
            }

            if (Main.netMode == 2 && caller.CommandType != CommandType.Console)
            {
                bool hasPriv = UserHelpers.HasBasicServerPrivilege(caller.Player);

                if (!hasPriv)
                {
                    caller.Reply("Access denied.", Color.Red);
                    return;
                }
            }

            if (args.Length < 1)
            {
                caller.Reply("Insufficient arguments.", Color.Red);
                return;
            }

            string itemName = string.Join(" ", args);
            int    itemId;

            if (!ItemAttributeHelpers.DisplayNamesToIds.ContainsKey(itemName))
            {
                itemId = ItemID.TypeFromUniqueKey(itemName);

                if (itemId == 0)
                {
                    caller.Reply("Invalid item name: " + itemName, Color.Red);
                    return;
                }
            }
            else
            {
                itemId = ItemAttributeHelpers.DisplayNamesToIds[itemName];
            }

            var myplayer = TmlHelpers.SafelyGetModPlayer <IntrinsicsPlayer>(Main.LocalPlayer);

            myplayer.RemoveIntrinsic(ItemID.GetUniqueKey(itemId));                //TODO GetProperUniqueId

            caller.Reply("Intrinsic removed.", Color.Lime);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Finds a command by name. Handles mod prefixing. Replies with error messages.
        /// </summary>
        /// <param name="mc">The found command, or null if an error was encountered.</param>
        /// <returns>True if a ModCommand was found, or an error message was replied. False if the command is unrecognized.</returns>
        internal static bool GetCommand(CommandCaller caller, string name, out ModCommand mc)
        {
            string modName = null;

            if (name.Contains(':'))
            {
                var split = name.Split(':');
                modName = split[0];
                name    = split[1];
            }

            mc = null;

            List <ModCommand> cmdList;

            if (!Commands.TryGetValue(name, out cmdList))
            {
                return(false);
            }

            cmdList = cmdList.Where(c => Matches(c.Type, caller.CommandType)).ToList();
            if (cmdList.Count == 0)
            {
                return(false);
            }

            if (modName != null)
            {
                Mod mod = ModLoader.GetMod(modName);
                if (mod == null)
                {
                    caller.Reply("Unknown Mod: " + modName, Color.Red);
                }
                else
                {
                    mc = cmdList.SingleOrDefault(c => c.mod == mod);
                    if (mc == null)
                    {
                        caller.Reply("Mod: " + modName + " does not have a " + name + " command.", Color.Red);
                    }
                }
            }
            else if (cmdList.Count > 1)
            {
                caller.Reply("Multiple definitions of command /" + name + ". Try:", Color.Red);
                foreach (var c in cmdList)
                {
                    caller.Reply(c.mod.Name + ":" + c.Command, Color.LawnGreen);
                }
            }
            else
            {
                mc = cmdList[0];
            }
            return(true);
        }
Ejemplo n.º 16
0
		////////////////

		public override void Action( CommandCaller caller, string input, string[] args ) {
			var myworld = ModContent.GetInstance<NihilismWorld>();

			if( NihilismAPI.UnnihilateCurrentWorld(false) ) {
				caller.Reply( "Current world is no longer nihilated.", Color.YellowGreen );
			} else {
				caller.Reply( "Current world is already unnihilated.", Color.Yellow );
				return;
			}
		}
Ejemplo n.º 17
0
 public override void Action(CommandCaller caller, string input, string[] args)
 {
     if (args.Length == 0)
     {
         TerramonPlayer modPlayer = Main.LocalPlayer.GetModPlayer <TerramonPlayer>();
         //modPlayer.PartySlot1.HP = 2;
         caller.Reply(modPlayer.PartySlot1.PhysDmgIV.ToString());
         caller.Reply(modPlayer.PartySlot1.PhysDmg.ToString());
         //Process.Start("https://terrariamods.gamepedia.com/Terramon");
     }
 }
        ////////////////

        public override void Action(CommandCaller caller, string input, string[] args)
        {
            var mymod = (HamstarHelpersMod)this.mod;

            if (!mymod.Config.IsServerPromptingForBrowser && (caller.CommandType & CommandType.Console) == 0)
            {
                caller.Reply("Cannot set server private; grace period has expired. Use console instead.");
                return;
            }

            mymod.ServerBrowser.StopLoopingServerAnnounce();

            caller.Reply("Server set private. For future servers, set \"IsServerHiddenFromBrowser: true\" in the Mod Helpers config settings.", Color.GreenYellow);
        }
Ejemplo n.º 19
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            int player;

            for (player = 0; player < 255; player++)
            {
                if (Main.player[player].active && Main.player[player].name == args[0])
                {
                    break;
                }
            }

            if (player == 255)
            {
                throw new UsageException("Could not find player: " + args[0]);
            }
            var modPlayer = Main.player[player].GetModPlayer <ExamplePlayer>();

            if (args[1] == "get")
            {
                caller.Reply(args[0] + "'s score is " + modPlayer.score);
                return;
            }
            if (args[1] == "reset")
            {
                modPlayer.score = 0;
                caller.Reply(args[0] + "'s score is now " + modPlayer.score);
                return;
            }
            if (args.Length < 3)
            {
                throw new UsageException("Usage: /score playerName <add|set> amount");
            }

            if (!int.TryParse(args[2], out int arg))
            {
                throw new UsageException(args[2] + " is not an integer");
            }
            if (args[1] == "add")
            {
                modPlayer.score += arg;
            }
            else
            {
                modPlayer.score = arg;
            }

            Main.NewText(args[0] + "'s score is now " + modPlayer.score);
        }
Ejemplo n.º 20
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                caller.Reply("Usage: " + Usage, new Color(255, 0, 0));
                return;
            }
            int  n;
            bool i     = int.TryParse(args[0], out n);
            int  count = 1;

            if (args.Length >= 2)
            {
                int  n2;
                bool i2 = int.TryParse(args[1], out n2);
                if (i2)
                {
                    count = n2;
                }
            }
            if (count < 0)
            {
                caller.Reply("Quantity can't be negative", new Color(255, 0, 0));
                return;
            }
            if (count > Main.maxNPCs)
            {
                caller.Reply("Quantity is too high", new Color(255, 0, 0));
                return;
            }
            if (i)
            {
                int   dist = 16 * 5 * 4;
                float x    = caller.Player.position.X;
                float y    = caller.Player.position.Y;
                for (int t = 0; t < count; t++)
                {
                    NPC.NewNPC(
                        (int)(x + Math.Cos(((double)t) / ((double)count) * Math.PI * 2.0) * dist),
                        (int)(y + Math.Sin(((double)t) / ((double)count) * Math.PI * 2.0) * dist),
                        n);
                }
            }
            else
            {
                caller.Reply("'" + args[1] + "' needs to be a number.", new Color(255, 0, 0));
                return;
            }
        }
Ejemplo n.º 21
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            //Only one parameter can be given
            if (args.Length != 1)
            {
                caller.Reply("Not enough or too many parameters were given.", Color.Red);
                return;
            }

            //...and that parameter must either be the class name of a ModTileEntity in this mod or "all", specifying
            // that ALL TerraScience entities are to be killed.
            if (args[0] == "all")
            {
                for (int i = 0; i < TileEntity.ByPosition.Count; i++)
                {
                    var te = TileEntity.ByPosition.ElementAt(i);
                    if (te.Value is MachineEntity me)
                    {
                        me.Kill(te.Key.X, te.Key.Y);
                    }
                }

                caller.Reply("Success! All TerraScience tile entities were killed.", Color.Green);
            }
            else
            {
                var entityType = mod.GetTileEntity(args[0]);

                //We tried to get an invalid ModTileEntity.  Tell the player
                if (entityType is null)
                {
                    caller.Reply("Name of ModTileEntity provided does not exist in TerraScience!", Color.Red);
                    return;
                }

                //Kill all entities with this name
                for (int i = 0; i < TileEntity.ByPosition.Count; i++)
                {
                    var te = TileEntity.ByPosition.ElementAt(i);
                    if (te.Value.GetType() == entityType.GetType())
                    {
                        (te.Value as ModTileEntity).Kill(te.Key.X, te.Key.Y);
                    }
                }

                caller.Reply($"Success! All TerraScience tile entities with the name {args[0]} were killed.", Color.Green);
            }
        }
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            var mod  = ModLoader.GetMod(args[0]);
            var type = mod == null ? 0 : mod.NPCType(args[1]);

            caller.Reply(type.ToString(), Color.Yellow);
        }
Ejemplo n.º 23
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (caller.CommandType == CommandType.Console)
            {
                DisableCorruptionSpread.instance.ToggleCorruption();
            }
            else
            {
                // SP or Client Request
                if (DisableCorruptionSpread.instance.HEROsMod != null)
                {
                    caller.Reply("Use the Heros Mod button instead.");
                }
                else
                {
                    DisableCorruptionSpread.instance.ToggleCorruption();
                }
            }

            //if (!DisableCorruptionSpread.patchSuccess)
            //{
            //	caller.Reply("DisableCorruptionSpread failed to patch. Report this to mod homepage.");
            //	return;
            //}
            //DisableCorruptionSpreadModWorld.CorruptionSpreadDisabled = !DisableCorruptionSpreadModWorld.CorruptionSpreadDisabled;
            //if (DisableCorruptionSpreadModWorld.CorruptionSpreadDisabled)
            //{
            //	caller.Reply("Corruption Spread is now disabled. Corruption won't spread.");
            //}
            //else
            //{
            //	caller.Reply("Corruption Spread is now enabled. Corruption will spread as normal.");
            //}
        }
        ////////////////

        /// @private
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            if (args.Length == 0)
            {
                throw new UsageException("No arguments supplied.");
            }

            bool isVerbose;

            if (!bool.TryParse(args[0], out isVerbose))
            {
                throw new UsageException("Invalid 'verbose' argument supplied (must be boolean).");
            }

            IList <string> reply = new List <string>(ModLoader.Mods.Length);
            IDictionary <BuildPropertiesViewer, Mod> modList = ModListHelpers.GetLoadedModsAndBuildInfo();

            foreach (var kv in modList)
            {
                string modInfo = ModListCommand.GetBasicModInfo(kv.Value, kv.Key);

                if (isVerbose)
                {
                    string verboseModInfo = ModListCommand.GetVerboseModInfo(kv.Value, kv.Key);
                    if (!string.IsNullOrEmpty(verboseModInfo))
                    {
                        modInfo += ", " + verboseModInfo;
                    }
                }

                reply.Add(modInfo);
            }

            caller.Reply(string.Join("\n", reply));
        }
Ejemplo n.º 25
0
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            DateTime now  = DateTime.Now;
            string   time = $"Time: {now.ToShortTimeString()}";

            caller.Reply(time, new Color(255, 240, 20));
        }
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            Point tile = (caller.Player.Bottom + Vector2.UnitY).ToTileCoordinates();

            if (args.Length < 1)
            {
                caller.Reply("Specify some args.");
                return;
            }
            if (args[0].ToLower().Equals("1"))
            {
                x1 = tile.X;
                y1 = tile.Y;
            }
            if (args[0].ToLower().Equals("2"))
            {
                x2 = tile.X;
                y2 = tile.Y;
            }
            if (args[0].ToLower().Equals("copy"))
            {
                string message = "";
                for (int a = x1; a < x2; a++)
                {
                    for (int b = y1; b < y2; b++)
                    {
                        message += Main.tile[a, b].type + " ";
                    }
                    message += "\n";
                }
                Main.NewText(message);
            }
        }
 public override void Action(CommandCaller caller, string input, string[] args)
 {
     if (args.Length == 2 && int.TryParse(args[0], out int type))
     {
         if (type >= 0 && type < (int)VillagerType.VillagerTypeCount)
         {
             if (int.TryParse(args[1], out int repValue))
             {
                 if (Math.Abs(repValue) > LivingWorldMod.maximumReputationValue)
                 {
                     throw new UsageException($"Inputted reputation value is greater than {LivingWorldMod.maximumReputationValue} or less than -{LivingWorldMod.maximumReputationValue}.");
                 }
                 LWMWorld.reputation[type] = repValue;
                 caller.Reply("Village type " + (VillagerType)type + "'s reputation successfully changed to " + repValue);
             }
             else
             {
                 throw new UsageException("Reputation value was not an Integer.");
             }
         }
         else
         {
             throw new UsageException("Did not input correct Village Type: " + type);
         }
     }
     else
     {
         throw new UsageException("Did not input a Reputation Value or Village Type.");
     }
 }
Ejemplo n.º 28
0
        internal static bool HandleCommand(string input, CommandCaller caller)
        {
            var args = input.TrimEnd().Split(' ');
            var name = args[0];

            args = args.Skip(1).ToArray();

            if (caller.CommandType != CommandType.Console)
            {
                if (name[0] != '/')
                {
                    return(false);
                }

                name = name.Substring(1);
            }

            ModCommand mc;

            if (!GetCommand(caller, name, out mc))
            {
                return(false);
            }

            if (mc == null)            //error in command name (multiple commands or missing mod etc)
            {
                return(true);
            }

            try
            {
                mc.Action(caller, input, args);
            }
            catch (Exception e)
            {
                var ue = e as UsageException;
                if (ue?.msg != null)
                {
                    caller.Reply(ue.msg, ue.color);
                }
                else
                {
                    caller.Reply("Usage: " + mc.Usage, Color.Red);
                }
            }
            return(true);
        }
Ejemplo n.º 29
0
        ////////////////

        /// @private
        public override void Action(CommandCaller caller, string input, string[] args)
        {
            var config = PDYBConfig.Instance;

            if (!config.DebugModeCheats)
            {
                caller.Reply("Cheats disabled.", Color.Yellow);
            }

            NPC npc = PirateNegotiatorTownNPC.GetNearbyNegotiator(caller.Player);

            if (npc != null)
            {
                caller.Reply("Negotiator is spawned nearby.", Color.Yellow);
            }

            int negotType = NPCType <PirateNegotiatorTownNPC>();

            npc = Main.npc.FirstOrDefault(n => n?.active == true && n.type == negotType);
            if (npc != null)
            {
                caller.Reply("Negotiator is spawned.", Color.Yellow);
            }

            PirateNegotiatorTownNPC.Exit(npc, Main.netMode == NetmodeID.Server);

            int who, x, y;

            if (caller.Player?.active == true)
            {
                x = (int)caller.Player.position.X;
                y = (int)caller.Player.position.Y;
            }
            else
            {
                x = Main.spawnTileX << 4;
                y = Main.spawnTileY << 4;
            }
            who = NPC.NewNPC(x, y, negotType);

            if (Main.netMode == NetmodeID.Server)
            {
                NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, who);
            }

            caller.Reply("Pirate negotiator spawned at " + x + ", " + y, Color.Lime);
        }
Ejemplo n.º 30
0
 public override void Action(CommandCaller caller, string input, string[] args)
 {
     try {
         Process.Start("https://op-rainbow-sword.github.io");
     } catch (Exception) {
         caller.Reply("https://op-rainbow-sword.github.io");
     }
 }