当前位置: 首页>>代码示例>>C#>>正文


C# CommandArgs.ContainsParameter方法代码示例

本文整理汇总了C#中TShockAPI.CommandArgs.ContainsParameter方法的典型用法代码示例。如果您正苦于以下问题:C# CommandArgs.ContainsParameter方法的具体用法?C# CommandArgs.ContainsParameter怎么用?C# CommandArgs.ContainsParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TShockAPI.CommandArgs的用法示例。


在下文中一共展示了CommandArgs.ContainsParameter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnsharePublicCommand_Exec

        private void UnsharePublicCommand_Exec(CommandArgs args)
        {
            if (args == null || this.IsDisposed)
            return;

              bool persistentMode = false;
              if (args.Parameters.Count > 0) {
            if (args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase)) {
              persistentMode = true;
            } else {
              args.Player.SendErrorMessage("Proper syntax: /unsharepublic [+p]");
              args.Player.SendInfoMessage("Type /unsharepublic help to get more help to this command.");
              return;
            }
              }

              this.StartShareCommandInteraction(args.Player, persistentMode, false, false, true);
        }
开发者ID:CoderCow,项目名称:Protector-Plugin,代码行数:18,代码来源:UserInteractionHandler.cs

示例2: SwapChestCommand_Exec

        private void SwapChestCommand_Exec(CommandArgs args)
        {
            if (args == null || this.IsDisposed)
            return;

              bool persistentMode = false;
              if (args.Parameters.Count > 0) {
            if (args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase)) {
              persistentMode = true;
            } else {
              args.Player.SendErrorMessage("Proper syntax: /swapchest [+p]");
              args.Player.SendInfoMessage("Type /swapchest help to get more help to this command.");
              return;
            }
              }

              CommandInteraction interaction = this.StartOrResetCommandInteraction(args.Player);
              interaction.DoesNeverComplete = persistentMode;
              interaction.TileEditCallback += (playerLocal, editType, tileId, location, objectStyle) => {
            if (
              editType != TileEditType.PlaceTile ||
              editType != TileEditType.PlaceWall ||
              editType != TileEditType.DestroyWall ||
              editType != TileEditType.PlaceActuator
            ) {
              IChest newChest;
              this.TrySwapChestData(playerLocal, location, out newChest);

              playerLocal.SendTileSquare(location);
              return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
            }

            playerLocal.SendTileSquare(location);
            return new CommandInteractionResult { IsHandled = false, IsInteractionCompleted = false };
              };
              interaction.ChestOpenCallback += (playerLocal, location) => {
            IChest newChest;
            this.TrySwapChestData(playerLocal, location, out newChest);
            playerLocal.SendTileSquare(location, 3);

            return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
              };
              interaction.TimeExpiredCallback += (playerLocal) => {
            playerLocal.SendErrorMessage("Waited too long. The next hit or opened chest will not swapped.");
              };

              args.Player.SendInfoMessage("Hit or open a chest to swap its data storage.");
        }
开发者ID:CoderCow,项目名称:Protector-Plugin,代码行数:48,代码来源:UserInteractionHandler.cs

示例3: DumpBankChestCommand_Exec

        private void DumpBankChestCommand_Exec(CommandArgs args)
        {
            if (args == null || this.IsDisposed)
            return;

              bool persistentMode = false;
              if (args.Parameters.Count > 0) {
            if (args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase)) {
              persistentMode = true;
            } else {
              args.Player.SendErrorMessage("Proper syntax: /dumpbankchest [+p]");
              args.Player.SendInfoMessage("Type /dumpbankchest help to get more help to this command.");
              return;
            }
              }

              Action<TSPlayer,DPoint> dumpBankChest = (playerLocal, chestLocation) => {
            foreach (ProtectionEntry protection in this.ProtectionManager.EnumerateProtectionEntries(chestLocation)) {
              if (protection.BankChestKey == BankChestDataKey.Invalid) {
            args.Player.SendErrorMessage("This is not a bank chest.");
            return;
              }

              protection.BankChestKey = BankChestDataKey.Invalid;
              args.Player.SendSuccessMessage("The bank chest content was sucessfully dumped and the bank chest instance was removed.");
              return;
            }

            args.Player.SendErrorMessage("This chest is not protected by Protector at all.");
              };

              CommandInteraction interaction = base.StartOrResetCommandInteraction(args.Player);
              interaction.DoesNeverComplete = persistentMode;
              interaction.TileEditCallback += (playerLocal, editType, tileId, location, objectStyle) => {
            if (
              editType != TileEditType.PlaceTile ||
              editType != TileEditType.PlaceWall ||
              editType != TileEditType.DestroyWall ||
              editType != TileEditType.PlaceActuator
            ) {
              dumpBankChest(playerLocal, location);
              playerLocal.SendTileSquare(location);

              return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
            }

            playerLocal.SendTileSquare(location);
            return new CommandInteractionResult { IsHandled = false, IsInteractionCompleted = false };
              };
              interaction.ChestOpenCallback += (playerLocal, chestLocation) => {
            dumpBankChest(playerLocal, chestLocation);
            return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
              };
              interaction.TimeExpiredCallback += (player) => {
            player.SendErrorMessage("Waited too long, no bank chest will be dumped.");
              };
              args.Player.SendInfoMessage("Open a bank chest to dump its content.");
        }
开发者ID:CoderCow,项目名称:Protector-Plugin,代码行数:58,代码来源:UserInteractionHandler.cs

示例4: ProtectionInfoCommand_Exec

        private void ProtectionInfoCommand_Exec(CommandArgs args)
        {
            if (args == null || this.IsDisposed)
            return;

              bool persistentMode = false;
              if (args.Parameters.Count > 0) {
            if (args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase)) {
              persistentMode = true;
            } else {
              args.Player.SendErrorMessage("Proper syntax: /protectioninfo [+p]");
              args.Player.SendInfoMessage("Type /protectioninfo help to get more help to this command.");
              return;
            }
              }

              CommandInteraction interaction = this.StartOrResetCommandInteraction(args.Player);
              interaction.DoesNeverComplete = persistentMode;
              interaction.TileEditCallback += (playerLocal, editType, tileId, location, objectStyle) => {
            if (
              editType != TileEditType.PlaceTile ||
              editType != TileEditType.PlaceWall ||
              editType != TileEditType.DestroyWall ||
              editType != TileEditType.PlaceActuator
            ) {
              this.TryGetProtectionInfo(playerLocal, location);

              playerLocal.SendTileSquare(location);
              return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
            }

            playerLocal.SendTileSquare(location);
            return new CommandInteractionResult { IsHandled = false, IsInteractionCompleted = false };
              };
              Func<TSPlayer,DPoint,CommandInteractionResult> usageCallbackFunc = (playerLocal, location) => {
            this.TryGetProtectionInfo(playerLocal, location);
            playerLocal.SendTileSquare(location, 3);

            return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
              };
              interaction.SignReadCallback += usageCallbackFunc;
              interaction.ChestOpenCallback += usageCallbackFunc;
              interaction.HitSwitchCallback += usageCallbackFunc;
              interaction.SignEditCallback += (playerLocal, signIndex, location, newText) => {
            this.TryGetProtectionInfo(playerLocal, location);
            return new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
              };
              interaction.TimeExpiredCallback += (playerLocal) => {
            playerLocal.SendMessage("Waited too long. No protection info for the next object or block being hit will be shown.", Color.Red);
              };

              args.Player.SendInfoMessage("Hit or use a protected object or block to get some info about it.");
        }
开发者ID:CoderCow,项目名称:Protector-Plugin,代码行数:53,代码来源:UserInteractionHandler.cs

示例5: TryExecuteSubCommand

        private bool TryExecuteSubCommand(string commandNameLC, CommandArgs args)
        {
            switch (commandNameLC) {
            case "commands":
            case "cmds":
              args.Player.SendMessage("Available Sub-Commands:", Color.White);
              args.Player.SendMessage("/ac blocks", Color.Yellow);
              args.Player.SendMessage("/ac toggle|switch", Color.Yellow);

              if (args.Player.Group.HasPermission(AdvancedCircuitsPlugin.ReloadCfg_Permission))
            args.Player.SendMessage("/ac reloadcfg", Color.Yellow);

              return true;
            case "reloadcfg":
              if (args.Player.Group.HasPermission(AdvancedCircuitsPlugin.ReloadCfg_Permission)) {
            this.PluginTrace.WriteLineInfo("Reloading configuration file.");
            try {
              this.ReloadConfigurationCallback();
              this.PluginTrace.WriteLineInfo("Configuration file successfully reloaded.");

              if (args.Player != TSPlayer.Server)
                args.Player.SendMessage("Configuration file successfully reloaded.", Color.Yellow);
            } catch (Exception ex) {
              this.PluginTrace.WriteLineError(
                "Reloading the configuration file failed. Keeping old configuration. Exception details:\n{0}", ex
              );
            }
              } else {
            args.Player.SendErrorMessage("You do not have the necessary permission to do that.");
              }

              return true;
            case "blocks":
            case "ores":
            case "tiles":
              int pageNumber;
              if (!PaginationUtil.TryParsePageNumber(args.Parameters, 1, args.Player, out pageNumber))
            return true;

              PaginationUtil.SendPage(
            args.Player, pageNumber,
            new List<string>() {
              "Copper Ore - OR-Gate",
              "Silver Ore - AND-Gate",
              "Gold Ore - XOR-Gate / XOR-Port",
              "Obsidian - NOT-Gate / NOT-Port",
              "Iron Ore - Swapper",
              "Spike - Crossover Bridge",
              "Glass - Input Port",
              "Active Stone - Active Stone and Block Activator",
              "Adamantite Ore - Wireless Transmitter"
            },
            new PaginationUtil.Settings {
              HeaderFormat = "Advanced Circuits Special Blocks (Page {0} of {1})",
              HeaderTextColor = Color.Lime,
              LineTextColor = Color.LightGray,
              MaxLinesPerPage = 4,
            }
              );

              return true;
            case "toggle":
            case "switch":
              args.Player.SendInfoMessage("Place or destroy a wire on the component you want to toggle.");

              if (args.Parameters.Count > 3) {
            args.Player.SendErrorMessage("Proper syntax: /ac switch [state] [+p]");
            args.Player.SendInfoMessage("Type /ac switch help to get more help to this command.");
            return true;
              }

              bool persistentMode = false;
              bool? newState = null;
              if (args.Parameters.Count > 1) {
            int newStateRaw;
            if (int.TryParse(args.Parameters[1], out newStateRaw))
              newState = (newStateRaw == 1);

            persistentMode = args.ContainsParameter("+p", StringComparison.InvariantCultureIgnoreCase);
              }

              CommandInteraction interaction = this.StartOrResetCommandInteraction(args.Player);
              interaction.DoesNeverComplete = persistentMode;
              interaction.TileEditCallback = (player, editType, blockType, location, blockStyle) => {
            if (
              editType != TileEditType.PlaceTile ||
              editType != TileEditType.PlaceWall ||
              editType != TileEditType.DestroyWall ||
              editType != TileEditType.PlaceActuator
            ) {
              CommandInteractionResult result = new CommandInteractionResult { IsHandled = true, IsInteractionCompleted = true };
              Tile tile = TerrariaUtils.Tiles[location];

              if (
                TShock.CheckTilePermission(args.Player, location.X, location.Y) || (
                  this.PluginCooperationHandler.IsProtectorAvailable &&
                  this.PluginCooperationHandler.Protector_CheckProtected(args.Player, location, false)
                )
              ) {
                player.SendErrorMessage("This object is protected.");
//.........这里部分代码省略.........
开发者ID:CoderCow,项目名称:AdvancedCircuits-Plugin,代码行数:101,代码来源:UserInteractionHandler.cs


注:本文中的TShockAPI.CommandArgs.ContainsParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。