コード例 #1
0
ファイル: Commands.cs プロジェクト: cynricthehun/UOLegends
        public static void Access( string command, AccessLevel level )
        {
            try{

            if ( Server.Commands.Entries[command] == null )
                return;

            DefaultInfo info = new DefaultInfo();

            if ( !HasMod( command ) )
            {
                info = new DefaultInfo();
                info.OldCommand = command;
                info.NewCommand = command;
                info.NewAccess = level;
                info.OldAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel;
                s_Defaults[command] = info;
            }
            else
            {
                info = (DefaultInfo)s_Defaults[command];
                info.NewAccess = level;
            }

            CommandEntry entry = new CommandEntry( command, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.NewAccess );
            Server.Commands.Entries[command] = entry;

            foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
                foreach( string str in new ArrayList( imp.Commands.Keys ) )
                    if ( str == command )
                        ((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;

            }catch{ Errors.Report( "Commands-> Access-> AccessLevel" ); }
        }
コード例 #2
0
ファイル: Commands.cs プロジェクト: zerodowned/angelisland
		public static void Register(string command, AccessLevel access, CommandEventHandler handler)
		{
			m_Entries[command] = new CommandEntry(command, handler, access);
		}
コード例 #3
0
ファイル: Commands.cs プロジェクト: cynricthehun/UOLegends
        public static void RestoreCommand( string command )
        {
            try{

            if ( !HasMod( command ) )
            {
                s_Defaults.Remove( command );
                Server.Commands.Entries.Remove( command );
                return;
            }

            DefaultInfo info = (DefaultInfo)s_Defaults[command];
            CommandEntry entry = new CommandEntry( info.OldCommand, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.OldAccess );
            Server.Commands.Entries.Remove( command );

            if ( HasMod( info.OldCommand ) )
                RestoreCommand( info.OldCommand );

            Server.Commands.Entries[info.OldCommand] = entry;

            s_Defaults.Remove( command );

            foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
                foreach( string str in new ArrayList( imp.Commands.Keys ) )
                    if ( str == command )
                    {
                        imp.Commands[info.OldCommand] = imp.Commands[str];
                        ((BaseCommand)imp.Commands[str]).AccessLevel = info.OldAccess;

                        if ( str != info.OldCommand )
                            imp.Commands.Remove( str );
                    }

            }catch{ Errors.Report( "Commands-> RestoreDefault" ); }
        }
コード例 #4
0
ファイル: CommandSystem.cs プロジェクト: Ravenwolfe/xrunuo
 public static void Register( string[] commands, AccessLevel access, CommandEventHandler handler )
 {
     foreach ( string command in commands )
         m_Entries[command] = new CommandEntry( command, handler, access );
 }
コード例 #5
0
ファイル: Commands.cs プロジェクト: zerodowned/angelisland
        public static bool Handle(Mobile from, string text)
        {
            if (text.StartsWith(m_CommandPrefix))
            {
                text = text.Substring(m_CommandPrefix.Length);

                int indexOf = text.IndexOf(' ');

                string   command;
                string[] args;
                string   argString;

                if (indexOf >= 0)
                {
                    argString = text.Substring(indexOf + 1);

                    command = text.Substring(0, indexOf);
                    args    = Split(argString);
                }
                else
                {
                    argString = "";
                    command   = text.ToLower();
                    args      = new string[0];
                }

                CommandEntry entry = (CommandEntry)m_Entries[command];

                if (entry != null)
                {
                    if (from.AccessLevel >= entry.AccessLevel)
                    {
                        if (entry.Handler != null)
                        {
                            CommandEventArgs e = new CommandEventArgs(from, command, argString, args);
                            entry.Handler(e);
                            EventSink.InvokeCommand(e);
                        }
                    }
                    else
                    {
                        if (from.AccessLevel <= m_BadCommandIngoreLevel)
                        {
                            return(false);
                        }

                        from.SendMessage("You do not have access to that command.");
                    }
                }
                else
                {
                    if (from.AccessLevel <= m_BadCommandIngoreLevel)
                    {
                        return(false);
                    }

                    from.SendMessage("That is not a valid command.");
                }

                return(true);
            }

            return(false);
        }
コード例 #6
0
ファイル: Commands.cs プロジェクト: zerodowned/angelisland
 public static void Register(string command, AccessLevel access, CommandEventHandler handler)
 {
     m_Entries[command] = new CommandEntry(command, handler, access);
 }