Beispiel #1
0
 private static string GetCalledAlias(CommandArgs args) => args.Message.Split(' ')[0];
Beispiel #2
0
 public IEnumerable <string> GetHelpText(CommandArgs args)
 => Subcommands.Select(s => string.Format("{0}{1}: {2}",
                                          RShockAPI.Config.CommandPrefix, GetCalledAlias(args) + " " + s.Name,
                                          string.IsNullOrWhiteSpace(s.HelpText) ? "No help available." : s.HelpText));
Beispiel #3
0
 public static void InfiniteWings(CommandArgs args)
 {
     PlayerExtension.IsInfiniteWings = !PlayerExtension.IsInfiniteWings;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsInfiniteWings ? "En" : "Dis")}abled infinite wings.");
 }
Beispiel #4
0
        public static void Item(CommandArgs args)
        {
            if (args.Parameters.Count < 1)
            {
                throw new CommandException("Invalid syntax! Syntax: .item <item-name> [stack-size] [prefix]");
            }

            int amountParamIndex = -1;
            int itemAmount       = 1;

            for (int i = 1; i < args.Parameters.Count; i++)
            {
                if (int.TryParse(args.Parameters[i], out itemAmount))
                {
                    amountParamIndex = i;
                    break;
                }
            }

            string itemNameOrId;

            if (amountParamIndex == -1)
            {
                itemNameOrId = string.Join(" ", args.Parameters);
            }
            else
            {
                itemNameOrId = string.Join(" ", args.Parameters.Take(amountParamIndex));
            }

            Item        item;
            List <Item> matchedItems = Utils.GetItemsByNameOrId(itemNameOrId);

            if (matchedItems.Count == 0)
            {
                throw new CommandException("Invalid item type!");
            }
            else if (matchedItems.Count > 1)
            {
                throw new CommandException($"Multiple matches found: {matchedItems.Select(i => $"{ i.Name }({ i.netID})")}");
            }

            item = matchedItems[0];
            if (item.type < 1 && item.type >= Main.maxItemTypes)
            {
                throw new CommandException($"The item type {itemNameOrId} is invalid.");
            }

            int prefixId = 0;

            if (amountParamIndex != -1 && args.Parameters.Count > amountParamIndex + 1)
            {
                string prefixidOrName = args.Parameters[amountParamIndex + 1];
                int    prefix         = Utils.GetPrefixByNameOrId(prefixidOrName);

                if (prefix == -1)
                {
                    throw new CommandException($"Did not find prefix \"{prefixidOrName}\"!");
                }

                if (item.accessory && prefix == PrefixID.Quick)
                {
                    prefix = 76;
                }
                prefixId = prefix;
            }


            item.stack    = itemAmount;
            item.position = Utils.LocalPlayer.Center;
            item.Prefix(prefixId);

            Utils.LocalPlayer.GetItem(Utils.LocalPlayer.whoAmI, item, new GetItemSettings());
            Utils.ShowSuccessMessage($"Spawned {itemAmount} {item.Name}(s).");
        }
Beispiel #5
0
 public static void InfiniteHealth(CommandArgs args)
 {
     PlayerExtension.IsInfiniteHealth = !PlayerExtension.IsInfiniteHealth;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsInfiniteHealth ? "En" : "Dis")}abled infinite health.");
 }
Beispiel #6
0
 public static void InfiniteMana(CommandArgs args)
 {
     PlayerExtension.IsInfiniteMana = !PlayerExtension.IsInfiniteMana;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsInfiniteMana ? "En" : "Dis")}abled infinite mana.");
 }
Beispiel #7
0
 public static void InfiniteAmmo(CommandArgs args)
 {
     PlayerExtension.IsInfiniteAmmo = !PlayerExtension.IsInfiniteAmmo;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsInfiniteAmmo ? "En" : "Dis")}abled infinite ammo.");
 }
Beispiel #8
0
 public static void Reload(CommandArgs args)
 {
     RShockAPI.Config = Config.Read(RShockAPI.ConfigPath);
     Utils.ShowSuccessMessage($"Reloaded RaptorShock config!");
 }
Beispiel #9
0
 public static void GodMode(CommandArgs args)
 {
     PlayerExtension.IsGodMode = !PlayerExtension.IsGodMode;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsGodMode ? "En" : "Dis")}abled god mode.");
 }
Beispiel #10
0
 public static void FullBright(CommandArgs args)
 {
     PlayerExtension.IsFullBright = !PlayerExtension.IsFullBright;
     Utils.ShowSuccessMessage($"{(PlayerExtension.IsFullBright ? "En" : "Dis")}abled fullbright mode.");
 }
Beispiel #11
0
 public static void AutoReuse(CommandArgs args)
 {
     Utils.LocalPlayerItem.autoReuse = !Utils.LocalPlayerItem.autoReuse;
     Utils.ShowSuccessMessage($"{(Utils.LocalPlayerItem.autoReuse ? "En" : "Dis")}abled autoreuse.");
 }