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


C# CommandEventArgs.Cancel方法代码示例

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


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

示例1: OnAllPlayersCommand_Normal

        void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs args) {
            if (args.Command != "ag")
                return;

            args.Cancel();

            if (args.Args.Length < 2) {
                Help(sender);
                return;
            }

            if (args.Args[0].ToLower() == "allow") {
                Player who = Player.Find(args.Args[1]);

                if (who == null || who is ConsolePlayer) {
                    sender.SendMessage("The specified player was not found");
                    return;
                }

                AllowList.AddValue<string, Player>(sender.Username, who);
                return;
            }

            else if (args.Args[0].ToLower() == "disallow") {
                Player who = Player.Find(args.Args[1]);

                if (who == null || who is ConsolePlayer) {
                    sender.SendMessage("The specified player was not found");
                    return;
                }

                AllowList.RemoveValue<string, Player>(sender.Username, who);
                return;
            }
        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:35,代码来源:PluginAntiGrief.cs

示例2: OnAllPlayersCommand_Normal

        public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
        {
            byte PerVisit = 0;
            Level l = null;

            ICommand cmdran = null;
            try
            {
                cmdran = Command.All[evt.Command];
            }
            catch { cmdran = null; }
            if (cmdran == null)
                return; // no use running this unless it exists
            else if (cmdran != Command.All["goto"])
                return; //yet again, no use to run this if the command aint /goto or a variant

            l = Level.FindLevel(evt.Args[0]);

            if (l == null)
                return;

                try
                {
                    PerVisit = (byte)l.Settings.pervisit;
                }
                catch
                {
                    PerVisit = 0;
                }

            if (sender.Group.Permission <= PerVisit)
            {
                sender.SendMessage("You cannot visit this map!");
                evt.Cancel();
            }
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:36,代码来源:CmdPerVisit.cs

示例3: OnCommand

        public void OnCommand(Player sender, CommandEventArgs e)
        {
            ICommand cmd = null;
            try
            {
                cmd = Command.All[e.Command];
            }
            catch
            {
                return;
            }

            byte perBuildMax = byte.MaxValue;

            if (sender.Level.ExtraData.ContainsKey("perbuildmax"))
            {
                try
                {
                    perBuildMax = (byte)sender.Level.ExtraData["perbuildmax"];
                }
                catch
                {
                    perBuildMax = byte.MaxValue;
                }
            }

            if (cmd == null) return;

            if (cmd.Type == CommandTypes.Building && sender.Group.Permission > perBuildMax && sender.Group.CanExecute(cmd))
            {
                sender.SendMessage("You cannot use building commands on this level!");
                e.Cancel();
            }
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:34,代码来源:CmdPerBuildMax.cs

示例4: OnCommand

 //yay for being smart, instead of recoding the command just over-ride it
 public void OnCommand(Player Player, CommandEventArgs args)
 {
     ExtraPlayerData TemporaryPlayer = FindPlayer(Player);
     if (args.Command.ToLower() == "tp" || args.Command.ToLower() == "summon" || args.Command.ToLower() == "s")
     {
         if (!TemporaryPlayer.Referee)
         {
             Player.SendMessage("You need to be a referee to do that!");
             args.Cancel();
             return;
         }
     }
     else if (args.Command.ToLower() == "rob" || args.Command.ToLower() == "run" || args.Command.ToLower() == "ascend"
         || args.Command.ToLower() == "bot" || args.Command.ToLower() == "test")
     {
         Player.SendMessage("Unknown command \"" + args.Command + "\"!");
         args.Cancel();
         return;
     }
     else if (args.Command.ToLower() == "spawn")
     {
         TemporaryPlayer.Spawning = true;
         if (!TemporaryPlayer.Infected && ZombieRoundEnabled)
         {
             ZombieHelper.InfectPlayer(TemporaryPlayer);
             ZombieHelper.DisplayInfectMessage(TemporaryPlayer.Player, null);
             EndGame();
         }
     }
     else
     {
         try
         {
             ICommand cmd = Command.Find(args.Command);
             if (cmd.Type == CommandTypes.Building)
             {
                 Player.SendMessage("Unknown command \"" + args.Command + "\"!");
                 args.Cancel();
                 return;
             }
         }
         catch { }
     }
 }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:45,代码来源:ZombiePlugin.cs

示例5: OnCommand

        public void OnCommand(Player sender, CommandEventArgs e)
        {
            ICommand cmd = null;
            try
            {
                cmd = Command.All[e.Command];
            }
            catch
            {
                return;
            }

            byte perBuild = 0;

            try
            {
                perBuild = (byte)sender.Level.Settings.perbuild;
            }
            catch
            {
            }

            if (cmd == null) return;

            if (cmd.Type == CommandTypes.Building && sender.Group.Permission < perBuild && sender.Group.CanExecute(cmd))
            {
                sender.SendMessage("You cannot use building commands on this level!");
                e.Cancel();
            }
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:30,代码来源:CmdPerBuild.cs

示例6: OnAllPlayersCommand_Normal

        public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
        {
            byte PerVisitMax = byte.MaxValue;
            Level l = null;

            ICommand cmdran = null;
            try
            {
                cmdran = Command.All[evt.Command];
            }
            catch { cmdran = null; }
            if (cmdran == null)
                return; // no use running this unless it exists
            else if (cmdran != Command.All["goto"])
                return; //yet again, no use to run this if the command aint /goto or a variant

            l = Level.FindLevel(evt.Args[0]);

            if (l.ExtraData.ContainsKey("pervisitmax"))
            {
                try
                {
                    PerVisitMax = (byte)l.ExtraData["pervisitmax"];
                }
                catch
                {
                    PerVisitMax = byte.MaxValue;
                }
            }

            if (sender.Group.Permission >= PerVisitMax)
            {
                sender.SendMessage("You cannot visit this map!");
                evt.Cancel();
            }
        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:36,代码来源:PerVisitMax.cs

示例7: OnAllPlayersCommand_Normal

        public void OnAllPlayersCommand_Normal(Player sender, CommandEventArgs evt)
        {
            byte PerVisitMax = byte.MaxValue;
            Level l = null;

            ICommand cmdran = null;
            try
            {
                cmdran = Command.All[evt.Command];
            }
            catch { cmdran = null; }
            if (cmdran == null || cmdran != Command.All["goto"])
                return; // no use running this unless it exists

            l = Level.FindLevel(evt.Args[0]);
            if (l == null && Level.UnloadedLevels.TrueForAll((s) => { return !s.ToLower().Contains(evt.Args[0].ToLower()); })) {
                cmdran.Use(sender, evt.Args);
                return;
            }
            if (l != null && l.ExtraData.ContainsKey("pervisitmax")) {
                try {
                    PerVisitMax = (byte)l.ExtraData["pervisitmax"];
                }
                catch {
                    PerVisitMax = byte.MaxValue;
                }
            }

            if (sender.Group.Permission >= PerVisitMax)
            {
                sender.SendMessage("You cannot visit this map!");
                evt.Cancel();
            }
        }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:34,代码来源:CmdPerVisitMax.cs

示例8: OnAllPlayersCommand_SystemLvl

 static void OnAllPlayersCommand_SystemLvl(Player sender, CommandEventArgs args)
 {
     if (sender.Group.Permission >= (byte)PermissionLevel.Operator) {
         if (args.Command.ToLower() == "update") {
             if (cmdupdate || plugupdate || coreupdate)
                 ManualUpdate(sender);
             else
                 sender.SendMessage("No updates are ready for install..");
             args.Cancel();
         }
     }
 }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:12,代码来源:Updater.cs


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