diff --git a/Config/ServerProperties.cs b/Config/ServerProperties.cs index 98f929bc8..2cd63b45b 100644 --- a/Config/ServerProperties.cs +++ b/Config/ServerProperties.cs @@ -42,7 +42,6 @@ namespace MCGalaxy { public static void Load(string givenPath, bool skipSalt = false) { if (!skipSalt) GenerateSalt(); - Server.s.Log(Server.salt); oldPerms = new OldPerms(); if (PropertiesFile.Read(givenPath, ref oldPerms, LineProcessor)) Server.s.SettingsUpdate(); diff --git a/Scripting/Scripting.cs b/Scripting/Scripting.cs index b053b634d..e8ad54e4a 100644 --- a/Scripting/Scripting.cs +++ b/Scripting/Scripting.cs @@ -186,7 +186,7 @@ namespace MCGalaxy { List commands = new List(); foreach (Type t in lib.GetTypes()) { - if (t.IsAbstract || t.IsInterface || !t.IsSubclassOf(typeof(Command)))continue; + if (t.IsAbstract || t.IsInterface || !t.IsSubclassOf(typeof(Command))) continue; object instance = Activator.CreateInstance(t); if (instance == null) { diff --git a/sharkbite.thresher/Rfc2812Util.cs b/sharkbite.thresher/Rfc2812Util.cs index 5862b516b..cacc90043 100644 --- a/sharkbite.thresher/Rfc2812Util.cs +++ b/sharkbite.thresher/Rfc2812Util.cs @@ -21,7 +21,7 @@ */ using System; -using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Text.RegularExpressions; @@ -44,7 +44,6 @@ namespace Sharkbite.Irc private const string ActionModes = "+-"; private const string UserModes = "awiorOs"; private const string ChannelModes = "OohvaimnqpsrtklbeI"; - private const string Space = " "; internal static TraceSwitch IrcTrace = new TraceSwitch("IrcTraceSwitch", "Debug level for RFC2812 classes."); // Odd chars that IRC allows in nicknames @@ -197,142 +196,98 @@ namespace Sharkbite.Irc return true; } - /// - /// Convert a ModeAction into its RFC2812 character. - /// + /// Convert a ModeAction into its RFC2812 character. /// The action enum. /// Either '+' or '-'. - public static char ModeActionToChar( ModeAction action ) - { - return Convert.ToChar( (byte) action, CultureInfo.InvariantCulture ) ; + public static char ModeActionToChar( ModeAction action ) { + return (char)((byte)action); } - /// - /// Converts the char received from the IRC server into - /// its enum equivalent. - /// + /// Converts the char received from the IRC server into its enum equivalent. /// Either '+' or '-'. /// An action enum. - public static ModeAction CharToModeAction( char action ) - { - byte b = Convert.ToByte( action, CultureInfo.InvariantCulture ); + public static ModeAction CharToModeAction( char action ) { + byte b = (byte)action; return (ModeAction) Enum.Parse( typeof( ModeAction), b.ToString( CultureInfo.InvariantCulture), false ); } - /// - /// Converts a UserMode into its RFC2812 character. - /// + /// Converts a UserMode into its RFC2812 character. /// The mode enum. /// The corresponding char. - public static char UserModeToChar( UserMode mode ) - { - return Convert.ToChar( (byte) mode, CultureInfo.InvariantCulture ) ; + public static char UserModeToChar( UserMode mode ) { + return (char)((byte)mode); } - /// - /// Convert a string of UserModes characters to - /// an array of UserMode enums. - /// + /// Convert a string of UserModes characters to an array of UserMode enums. /// A string of UserMode chars from the IRC server. /// An array of UserMode enums. Charactres that are not from RFC2812 will be droppped. - public static UserMode[] UserModesToArray( string modes ) - { - ArrayList list = new ArrayList(); - for( int i = 0; i < modes.Length; i++ ) - { - if( IsValidModeChar( modes[i], UserModes ) ) - { + public static UserMode[] UserModesToArray( string modes ) { + List list = new List(); + for( int i = 0; i < modes.Length; i++ ) { + if( IsValidModeChar( modes[i], UserModes ) ) { list.Add( CharToUserMode( modes[i] )); } } - return (UserMode[]) list.ToArray( typeof(UserMode) ); + return list.ToArray(); } - /// - /// Converts the char recived from the IRC server into - /// its enum equivalent. - /// + /// Converts the char recived from the IRC server into its enum equivalent. /// One of the IRC mode characters, e.g. 'a','i', etc... /// An mode enum. - public static UserMode CharToUserMode( char mode ) - { - byte b = Convert.ToByte( mode, CultureInfo.InvariantCulture ); + public static UserMode CharToUserMode( char mode ) { + byte b = (byte)mode; return (UserMode) Enum.Parse( typeof( UserMode), b.ToString(CultureInfo.InvariantCulture), false ); } - /// - /// Convert a string of ChannelModes characters to - /// an array of ChannelMode enums. - /// + /// Convert a string of ChannelModes characters to an array of ChannelMode enums. /// A string of ChannelMode chars from the IRC server. /// An array of ChannelMode enums. Charactres that are not from RFC2812 will be droppped. - public static ChannelMode[] ChannelModesToArray( string modes ) - { - ArrayList list = new ArrayList(); - for( int i = 0; i < modes.Length; i++ ) - { - if( IsValidModeChar( modes[i], ChannelModes ) ) - { + public static ChannelMode[] ChannelModesToArray( string modes ) { + List list = new List(); + for( int i = 0; i < modes.Length; i++ ) { + if( IsValidModeChar( modes[i], ChannelModes ) ) { list.Add( CharToChannelMode( modes[i] )); } } - return (ChannelMode[]) list.ToArray( typeof(ChannelMode) ); + return list.ToArray(); } - /// - /// Converts a ChannelMode into its RFC2812 character. - /// + /// Converts a ChannelMode into its RFC2812 character. /// The mode enum. /// The corresponding char. - public static char ChannelModeToChar( ChannelMode mode ) - { - return Convert.ToChar( (byte) mode, CultureInfo.InvariantCulture ) ; + public static char ChannelModeToChar( ChannelMode mode ) { + return (char)((byte)mode); } - /// - /// Converts the char recived from the IRC server into - /// its enum equivalent. - /// + + /// Converts the char recived from the IRC server into its enum equivalent. /// One of the IRC mode characters, e.g. 'O','i', etc... /// An mode enum. - public static ChannelMode CharToChannelMode( char mode ) - { - byte b = Convert.ToByte( mode, CultureInfo.InvariantCulture ); - return (ChannelMode) Enum.Parse( typeof( ChannelMode), b.ToString( CultureInfo.InvariantCulture), false ); + public static ChannelMode CharToChannelMode( char mode ) { + byte b = (byte)mode; + return (ChannelMode) Enum.Parse( typeof( ChannelMode ), b.ToString(CultureInfo.InvariantCulture), false ); } - /// - /// Converts a StatQuery enum value to its RFC2812 character. - /// + /// Converts a StatQuery enum value to its RFC2812 character. /// The query enum. /// The corresponding char. - public static char StatsQueryToChar( StatsQuery query ) - { - return Convert.ToChar( (byte) query, CultureInfo.InvariantCulture ) ; + public static char StatsQueryToChar( StatsQuery query ) { + return (char)((byte)query); } - /// - /// Converts the char recived from the IRC server into - /// its enum equivalent. - /// + /// Converts the char recived from the IRC server into its enum equivalent. /// One of the IRC stats query characters, e.g. 'u','l', etc... /// An StatsQuery enum. - public static StatsQuery CharToStatsQuery( char queryType ) - { - byte b = Convert.ToByte( queryType, CultureInfo.InvariantCulture ); + public static StatsQuery CharToStatsQuery( char queryType ) { + byte b = (byte)queryType; return (StatsQuery) Enum.Parse( typeof( StatsQuery), b.ToString(CultureInfo.InvariantCulture), false ); } - - - - private static bool IsValidModeChar( char c, string validList ) - { + private static bool IsValidModeChar( char c, string validList ) { return validList.IndexOf( c ) != -1; } - private static bool ContainsSpace( string text ) - { - return text.IndexOf( Space, 0, text.Length ) != -1; + private static bool ContainsSpace( string text ) { + return text.IndexOf( ' ' ) != -1; } } }