From f45b9bffb076a8177cd3273446ef94164c89bf38 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 2 Aug 2017 12:37:28 +1000 Subject: [PATCH] Minimise usage of inequliaty comparison against empty string --- MCGalaxy/Chat/ProfanityFilter.cs | 2 +- MCGalaxy/Commands/Bots/CmdBotAI.cs | 3 ++- MCGalaxy/Commands/CPE/CmdCustomColors.cs | 4 ++-- MCGalaxy/Commands/CPE/CmdEnvironment.cs | 3 +-- MCGalaxy/Commands/Chat/CmdAdminChat.cs | 2 +- MCGalaxy/Commands/Chat/CmdIgnore.cs | 2 +- MCGalaxy/Commands/Chat/CmdOpChat.cs | 2 +- MCGalaxy/Commands/Command.Helpers.cs | 2 +- MCGalaxy/Commands/Economy/CmdAwards.cs | 2 +- MCGalaxy/Commands/Information/CmdBlocks.cs | 2 +- MCGalaxy/Commands/Information/CmdCommands.cs | 2 +- MCGalaxy/Commands/Information/CmdDevs.cs | 2 +- MCGalaxy/Commands/Information/CmdHasirc.cs | 2 +- MCGalaxy/Commands/Information/CmdHelp.cs | 2 +- MCGalaxy/Commands/Information/CmdMapInfo.cs | 2 +- MCGalaxy/Commands/Information/CmdOpRules.cs | 2 +- MCGalaxy/Commands/Information/CmdOpStats.cs | 2 +- MCGalaxy/Commands/Information/CmdPlayers.cs | 4 ++-- MCGalaxy/Commands/Information/CmdRules.cs | 2 +- MCGalaxy/Commands/Information/CmdServerInfo.cs | 2 +- MCGalaxy/Commands/Maintenance/CmdRestart.cs | 2 +- MCGalaxy/Commands/Moderation/CmdModerate.cs | 2 +- MCGalaxy/Commands/Moderation/CmdPatrol.cs | 2 +- MCGalaxy/Commands/World/CmdPause.cs | 2 +- MCGalaxy/Commands/World/CmdSetspawn.cs | 2 +- MCGalaxy/Commands/World/CmdSpawn.cs | 2 +- MCGalaxy/Commands/building/CmdDelete.cs | 2 +- MCGalaxy/Commands/building/CmdDrill.cs | 2 +- MCGalaxy/Commands/building/CmdMark.cs | 2 +- MCGalaxy/Commands/building/CmdMeasure.cs | 2 +- MCGalaxy/Commands/building/CmdPaint.cs | 2 +- MCGalaxy/Commands/building/CmdRedo.cs | 2 +- MCGalaxy/Commands/building/CmdRestartPhysics.cs | 2 +- MCGalaxy/Commands/other/QuitCmds.cs | 4 ++-- MCGalaxy/Config/StringAttributes.cs | 2 +- MCGalaxy/Economy/Awards.cs | 8 +++++--- MCGalaxy/Games/LavaSurvival/LavaSurvival.Settings.cs | 2 +- MCGalaxy/util/App.cs | 6 +----- 38 files changed, 46 insertions(+), 48 deletions(-) diff --git a/MCGalaxy/Chat/ProfanityFilter.cs b/MCGalaxy/Chat/ProfanityFilter.cs index 4191c2e45..2c6ed8f3d 100644 --- a/MCGalaxy/Chat/ProfanityFilter.cs +++ b/MCGalaxy/Chat/ProfanityFilter.cs @@ -82,7 +82,7 @@ namespace MCGalaxy { foreach (string line in lines) { if (line.StartsWith("#") || line.Trim().Length == 0) continue; - string word = Reduce(line.ToLower()); + string word = Reduce(line); filters.Add(word); } } diff --git a/MCGalaxy/Commands/Bots/CmdBotAI.cs b/MCGalaxy/Commands/Bots/CmdBotAI.cs index 7f4e8b32c..06e1f3bd2 100644 --- a/MCGalaxy/Commands/Bots/CmdBotAI.cs +++ b/MCGalaxy/Commands/Bots/CmdBotAI.cs @@ -119,8 +119,9 @@ namespace MCGalaxy.Commands.Bots{ using (StreamWriter w = new StreamWriter("bots/" + ai, true)) { for (int i = allLines.Length - 1; i > 0; i--) { - if (allLines[i][0] != '#' && allLines[i] != "") + if (allLines[i].Length > 0 && allLines[i][0] != '#') { w.WriteLine(allLines[i]); + } } } } catch { diff --git a/MCGalaxy/Commands/CPE/CmdCustomColors.cs b/MCGalaxy/Commands/CPE/CmdCustomColors.cs index c34b5822c..a251712e5 100644 --- a/MCGalaxy/Commands/CPE/CmdCustomColors.cs +++ b/MCGalaxy/Commands/CPE/CmdCustomColors.cs @@ -140,7 +140,7 @@ namespace MCGalaxy.Commands.CPE { static bool CheckName(Player p, string arg) { - if (Colors.Parse(arg) != "") { + if (Colors.Parse(arg).Length > 0) { Player.Message(p, "There is already an existing color with the name \"{0}\".", arg); return false; } @@ -150,7 +150,7 @@ namespace MCGalaxy.Commands.CPE { static char ParseColor(Player p, string arg) { if (arg.Length != 1) { string colCode = Colors.Parse(arg); - if (colCode != "") return colCode[1]; + if (colCode.Length > 0) return colCode[1]; Player.Message(p, "There is no color \"" + arg + "\"."); } else { diff --git a/MCGalaxy/Commands/CPE/CmdEnvironment.cs b/MCGalaxy/Commands/CPE/CmdEnvironment.cs index d40de77bc..25b54677b 100644 --- a/MCGalaxy/Commands/CPE/CmdEnvironment.cs +++ b/MCGalaxy/Commands/CPE/CmdEnvironment.cs @@ -203,8 +203,7 @@ namespace MCGalaxy.Commands.CPE { string[] files = Directory.GetFiles("presets", "*.env"); string all = files.Join(f => Path.GetFileNameWithoutExtension(f)); - if (all != "") - Player.Message(p, "Custom preset types: " + all); + if (all.Length > 0) Player.Message(p, "Custom preset types: " + all); } public override void Help(Player p) { diff --git a/MCGalaxy/Commands/Chat/CmdAdminChat.cs b/MCGalaxy/Commands/Chat/CmdAdminChat.cs index cbce181f3..71f030463 100644 --- a/MCGalaxy/Commands/Chat/CmdAdminChat.cs +++ b/MCGalaxy/Commands/Chat/CmdAdminChat.cs @@ -23,7 +23,7 @@ namespace MCGalaxy.Commands.Chatting { } public override void Use(Player p, string message) { - if (message != "") { ChatModes.MessageAdmins(p, message); return; } + if (message.Length > 0) { ChatModes.MessageAdmins(p, message); return; } p.adminchat = !p.adminchat; if (p.adminchat) Player.Message(p, "All messages will now be sent to Admins only"); diff --git a/MCGalaxy/Commands/Chat/CmdIgnore.cs b/MCGalaxy/Commands/Chat/CmdIgnore.cs index ee801d0a8..ec0dbf79b 100644 --- a/MCGalaxy/Commands/Chat/CmdIgnore.cs +++ b/MCGalaxy/Commands/Chat/CmdIgnore.cs @@ -49,7 +49,7 @@ namespace MCGalaxy.Commands.Chatting { Toggle(p, ref p.ignoreDrawOutput, "{0} ignoring draw command output"); return; } else if (action == "list") { string names = p.listignored.Join(); - if (names != "") { + if (names.Length > 0) { Player.Message(p, "&cCurrently ignoring the following players:"); Player.Message(p, names); } diff --git a/MCGalaxy/Commands/Chat/CmdOpChat.cs b/MCGalaxy/Commands/Chat/CmdOpChat.cs index 98f2a32a2..8984c4714 100644 --- a/MCGalaxy/Commands/Chat/CmdOpChat.cs +++ b/MCGalaxy/Commands/Chat/CmdOpChat.cs @@ -26,7 +26,7 @@ namespace MCGalaxy.Commands.Chatting { } public override void Use(Player p, string message) { - if (message != "") { ChatModes.MessageOps(p, message); return; } + if (message.Length > 0) { ChatModes.MessageOps(p, message); return; } p.opchat = !p.opchat; if (p.opchat) Player.Message(p, "All messages will now be sent to OPs only"); diff --git a/MCGalaxy/Commands/Command.Helpers.cs b/MCGalaxy/Commands/Command.Helpers.cs index 99834831d..fce0d9915 100644 --- a/MCGalaxy/Commands/Command.Helpers.cs +++ b/MCGalaxy/Commands/Command.Helpers.cs @@ -40,7 +40,7 @@ namespace MCGalaxy { } protected bool CheckSuper(Player p, string message, string type) { - if (message != "" || !Player.IsSuper(p)) return false; + if (message.Length > 0 || !Player.IsSuper(p)) return false; SuperRequiresArgs(name, p, type); return true; } diff --git a/MCGalaxy/Commands/Economy/CmdAwards.cs b/MCGalaxy/Commands/Economy/CmdAwards.cs index 0bc4e504c..a2c226a4e 100644 --- a/MCGalaxy/Commands/Economy/CmdAwards.cs +++ b/MCGalaxy/Commands/Economy/CmdAwards.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands.Eco { if (args.Length == 2) { plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]); if (plName == null) return; - } else if (message != "" && !message.CaselessEq("all")) { + } else if (message.Length > 0 && !message.CaselessEq("all")) { if (!int.TryParse(args[0], out ignored)) { modifier = ""; plName = PlayerInfo.FindMatchesPreferOnline(p, args[0]); diff --git a/MCGalaxy/Commands/Information/CmdBlocks.cs b/MCGalaxy/Commands/Information/CmdBlocks.cs index 87a709f8e..eed85a82e 100644 --- a/MCGalaxy/Commands/Information/CmdBlocks.cs +++ b/MCGalaxy/Commands/Information/CmdBlocks.cs @@ -103,7 +103,7 @@ namespace MCGalaxy.Commands.Info { msg += Block.Name(i) + ", "; } - if (msg != "") { + if (msg.Length > 0) { Player.Message(p, "Blocks which look like \"{0}\":", block); Player.Message(p, msg.Remove(msg.Length - 2)); } else { diff --git a/MCGalaxy/Commands/Information/CmdCommands.cs b/MCGalaxy/Commands/Information/CmdCommands.cs index a0578a097..34dca9f64 100644 --- a/MCGalaxy/Commands/Information/CmdCommands.cs +++ b/MCGalaxy/Commands/Information/CmdCommands.cs @@ -164,7 +164,7 @@ namespace MCGalaxy.Commands.Info { Player.Message(p, category + " commands you may use:"); type = "Commands " + category; - if (sort != "") type += " " + sort; + if (sort != "") type += " " + sort; MultiPageOutput.Output(p, cmds, (cmd) => CmdHelp.GetColor(cmd) + cmd.name, type, "commands", modifier, false); diff --git a/MCGalaxy/Commands/Information/CmdDevs.cs b/MCGalaxy/Commands/Information/CmdDevs.cs index 13e179f2b..1ea725a0d 100644 --- a/MCGalaxy/Commands/Information/CmdDevs.cs +++ b/MCGalaxy/Commands/Information/CmdDevs.cs @@ -24,7 +24,7 @@ namespace MCGalaxy.Commands.Info { public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } Player.Message(p, "&9{1} devs: %S{0}", Server.Devs.Join(), Server.SoftwareName); Player.Message(p, "&2{1} mods: %S{0}", Server.Mods.Join(), Server.SoftwareName); } diff --git a/MCGalaxy/Commands/Information/CmdHasirc.cs b/MCGalaxy/Commands/Information/CmdHasirc.cs index 190c4f393..3d4c10866 100644 --- a/MCGalaxy/Commands/Information/CmdHasirc.cs +++ b/MCGalaxy/Commands/Information/CmdHasirc.cs @@ -24,7 +24,7 @@ namespace MCGalaxy.Commands.Info { public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } if (ServerConfig.UseIRC) { Player.Message(p, "IRC is &aEnabled%S."); diff --git a/MCGalaxy/Commands/Information/CmdHelp.cs b/MCGalaxy/Commands/Information/CmdHelp.cs index e0f7d2673..2b02ee9be 100644 --- a/MCGalaxy/Commands/Information/CmdHelp.cs +++ b/MCGalaxy/Commands/Information/CmdHelp.cs @@ -86,7 +86,7 @@ namespace MCGalaxy.Commands.Info { bool ParseCommand(Player p, string message) { string[] args = message.SplitSpaces(2); - Alias alias = Alias.Find(args[0].ToLower()); + Alias alias = Alias.Find(args[0]); if (alias != null) args[0] = alias.Target; Command cmd = Command.all.Find(args[0]); diff --git a/MCGalaxy/Commands/Information/CmdMapInfo.cs b/MCGalaxy/Commands/Information/CmdMapInfo.cs index 566266e93..e4ce262a2 100644 --- a/MCGalaxy/Commands/Information/CmdMapInfo.cs +++ b/MCGalaxy/Commands/Information/CmdMapInfo.cs @@ -154,7 +154,7 @@ namespace MCGalaxy.Commands.Info { // Early out when accounts have + and map doesn't. if (plus && lvlName.IndexOf('+') == -1) return null; - while (lvlName != "" && Char.IsNumber(lvlName[lvlName.Length - 1])) { + while (lvlName.Length > 0 && Char.IsNumber(lvlName[lvlName.Length - 1])) { // If the server does not have account with +, we have to account for the // that say Player123's second level is Player1232, and the realm owner is Player123 string pName = plus ? null : PlayerInfo.FindName(lvlName); diff --git a/MCGalaxy/Commands/Information/CmdOpRules.cs b/MCGalaxy/Commands/Information/CmdOpRules.cs index 04ca31d2a..1f3b58a11 100644 --- a/MCGalaxy/Commands/Information/CmdOpRules.cs +++ b/MCGalaxy/Commands/Information/CmdOpRules.cs @@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Info { oprulesFile.EnsureExists(); Player who = p; - if (message != "") { + if (message.Length > 0) { who = PlayerInfo.FindMatches(p, message); if (who == null) return; if (p != null && p.Rank < who.Rank) { diff --git a/MCGalaxy/Commands/Information/CmdOpStats.cs b/MCGalaxy/Commands/Information/CmdOpStats.cs index 39bfabcd0..403baf461 100644 --- a/MCGalaxy/Commands/Information/CmdOpStats.cs +++ b/MCGalaxy/Commands/Information/CmdOpStats.cs @@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Info { if (p == null) { Help(p); return; } name = p.name; - if (message != "") start = message.ToLower(); + if (message.Length > 0) start = message.ToLower(); } else { name = PlayerInfo.FindMatchesPreferOnline(p, args[0]); if (args.Length > 1 && ValidTimespan(args[1].ToLower())) diff --git a/MCGalaxy/Commands/Information/CmdPlayers.cs b/MCGalaxy/Commands/Information/CmdPlayers.cs index c2c2a403a..df4a04abc 100644 --- a/MCGalaxy/Commands/Information/CmdPlayers.cs +++ b/MCGalaxy/Commands/Information/CmdPlayers.cs @@ -28,9 +28,9 @@ namespace MCGalaxy.Commands.Info { public override LevelPermission defaultRank { get { return LevelPermission.Guest; } } public override void Use(Player p, string message) { - if (message != "") { + if (message.Length > 0) { Group grp = Matcher.FindRanks(p, message); - if(grp == null) return; + if (grp == null) return; string title = ":" + grp.Color + GetPlural(grp.Name) + ":"; Section rankSec = MakeSection(grp, title); diff --git a/MCGalaxy/Commands/Information/CmdRules.cs b/MCGalaxy/Commands/Information/CmdRules.cs index 6178ec3b6..60ab54b67 100644 --- a/MCGalaxy/Commands/Information/CmdRules.cs +++ b/MCGalaxy/Commands/Information/CmdRules.cs @@ -39,7 +39,7 @@ namespace MCGalaxy.Commands.Info { if (message.CaselessEq("disagree")) { Disagree(p); return; } Player who = p; - if (message != "") { + if (message.Length > 0) { if (!CheckExtraPerm(p)) { MessageNeedExtra(p, 1); return; } who = PlayerInfo.FindMatches(p, message); if (who == null) return; diff --git a/MCGalaxy/Commands/Information/CmdServerInfo.cs b/MCGalaxy/Commands/Information/CmdServerInfo.cs index 87e8483c9..4eae10973 100644 --- a/MCGalaxy/Commands/Information/CmdServerInfo.cs +++ b/MCGalaxy/Commands/Information/CmdServerInfo.cs @@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.Info { static PerformanceCounter cpuPCounter = null; public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } Player.Message(p, "Server's name: &b{0}%S", ServerConfig.Name); Player.Message(p, "&a{0} %Splayers total. (&a{1} %Sonline, &8{2} banned%S)", diff --git a/MCGalaxy/Commands/Maintenance/CmdRestart.cs b/MCGalaxy/Commands/Maintenance/CmdRestart.cs index be6dd45c8..aefc3da05 100644 --- a/MCGalaxy/Commands/Maintenance/CmdRestart.cs +++ b/MCGalaxy/Commands/Maintenance/CmdRestart.cs @@ -23,7 +23,7 @@ namespace MCGalaxy.Commands.Maintenance { public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } MCGalaxy.Gui.App.ExitProgram(true); } diff --git a/MCGalaxy/Commands/Moderation/CmdModerate.cs b/MCGalaxy/Commands/Moderation/CmdModerate.cs index 224228dea..47e99dbb3 100644 --- a/MCGalaxy/Commands/Moderation/CmdModerate.cs +++ b/MCGalaxy/Commands/Moderation/CmdModerate.cs @@ -23,7 +23,7 @@ namespace MCGalaxy.Commands.Moderation { public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } if (Server.chatmod) { Chat.MessageGlobal("Chat moderation has been disabled. Everyone can now speak."); diff --git a/MCGalaxy/Commands/Moderation/CmdPatrol.cs b/MCGalaxy/Commands/Moderation/CmdPatrol.cs index 0b14c8ae4..778e3255c 100644 --- a/MCGalaxy/Commands/Moderation/CmdPatrol.cs +++ b/MCGalaxy/Commands/Moderation/CmdPatrol.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Moderation { } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } List candidates = GetPatrolCandidates(p); if (candidates.Count == 0) { diff --git a/MCGalaxy/Commands/World/CmdPause.cs b/MCGalaxy/Commands/World/CmdPause.cs index c4e3367dd..6a105e993 100644 --- a/MCGalaxy/Commands/World/CmdPause.cs +++ b/MCGalaxy/Commands/World/CmdPause.cs @@ -28,7 +28,7 @@ namespace MCGalaxy.Commands.World { public override void Use(Player p, string message) { int seconds = 30; Level lvl = p != null ? p.level : Server.mainLevel; - if (message != "") { + if (message.Length > 0) { string[] parts = message.SplitSpaces(); if (parts.Length == 1) { if (!int.TryParse(parts[0], out seconds)) { diff --git a/MCGalaxy/Commands/World/CmdSetspawn.cs b/MCGalaxy/Commands/World/CmdSetspawn.cs index 865db28a5..50059bf97 100644 --- a/MCGalaxy/Commands/World/CmdSetspawn.cs +++ b/MCGalaxy/Commands/World/CmdSetspawn.cs @@ -24,7 +24,7 @@ namespace MCGalaxy.Commands.World { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } Player.Message(p, "Spawn location set to your current position."); p.level.spawnx = (ushort)p.Pos.BlockX; diff --git a/MCGalaxy/Commands/World/CmdSpawn.cs b/MCGalaxy/Commands/World/CmdSpawn.cs index b582742da..5540322ae 100644 --- a/MCGalaxy/Commands/World/CmdSpawn.cs +++ b/MCGalaxy/Commands/World/CmdSpawn.cs @@ -27,7 +27,7 @@ namespace MCGalaxy.Commands.World { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } bool cpSpawn = p.useCheckpointSpawn; Position pos; diff --git a/MCGalaxy/Commands/building/CmdDelete.cs b/MCGalaxy/Commands/building/CmdDelete.cs index 70a53e26b..b0aee52a4 100644 --- a/MCGalaxy/Commands/building/CmdDelete.cs +++ b/MCGalaxy/Commands/building/CmdDelete.cs @@ -25,7 +25,7 @@ namespace MCGalaxy.Commands.Building { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } p.deleteMode = !p.deleteMode; Player.Message(p, "Delete mode: &a" + p.deleteMode); diff --git a/MCGalaxy/Commands/building/CmdDrill.cs b/MCGalaxy/Commands/building/CmdDrill.cs index 146f4b529..67ed1e733 100644 --- a/MCGalaxy/Commands/building/CmdDrill.cs +++ b/MCGalaxy/Commands/building/CmdDrill.cs @@ -28,7 +28,7 @@ namespace MCGalaxy.Commands.Building { public override void Use(Player p, string message) { ushort dist = 20; - if (message != "" && !CommandParser.GetUShort(p, message, "Distance", ref dist)) return; + if (message.Length > 0 && !CommandParser.GetUShort(p, message, "Distance", ref dist)) return; Player.Message(p, "Destroy the block you wish to drill."); p.MakeSelection(1, "Selecting location for %SDrill", dist, DoDrill); diff --git a/MCGalaxy/Commands/building/CmdMark.cs b/MCGalaxy/Commands/building/CmdMark.cs index 361ca398c..d65e6a991 100644 --- a/MCGalaxy/Commands/building/CmdMark.cs +++ b/MCGalaxy/Commands/building/CmdMark.cs @@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.Building { // convert player pos to block coords Vec3U16 P = ClampPos(p.Pos, p.level); - if (message != "" && !ParseCoords(message, p, ref P)) return; + if (message.Length > 0 && !ParseCoords(message, p, ref P)) return; P = Vec3U16.Clamp(P.X, P.Y, P.Z, p.level); if (p.HasBlockchange) { diff --git a/MCGalaxy/Commands/building/CmdMeasure.cs b/MCGalaxy/Commands/building/CmdMeasure.cs index ac30ff6d6..d09071724 100644 --- a/MCGalaxy/Commands/building/CmdMeasure.cs +++ b/MCGalaxy/Commands/building/CmdMeasure.cs @@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.Building { public override void Use(Player p, string message) { if (message.IndexOf(' ') != -1) { Help(p); return; } ExtBlock skip = ExtBlock.Air; - if (message != "" && !CommandParser.GetBlock(p, message, out skip)) return; + if (message.Length > 0 && !CommandParser.GetBlock(p, message, out skip)) return; Player.Message(p, "Place or break two blocks to determine the edges."); p.MakeSelection(2, "Selecting region for %SMeasure", skip, DoMeasure); diff --git a/MCGalaxy/Commands/building/CmdPaint.cs b/MCGalaxy/Commands/building/CmdPaint.cs index 07af329db..0e8694140 100644 --- a/MCGalaxy/Commands/building/CmdPaint.cs +++ b/MCGalaxy/Commands/building/CmdPaint.cs @@ -25,7 +25,7 @@ namespace MCGalaxy.Commands.Building { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } p.painting = !p.painting; string type = p.painting ? "&aON" : "&cOFF"; diff --git a/MCGalaxy/Commands/building/CmdRedo.cs b/MCGalaxy/Commands/building/CmdRedo.cs index 503f3604a..376c5b0ff 100644 --- a/MCGalaxy/Commands/building/CmdRedo.cs +++ b/MCGalaxy/Commands/building/CmdRedo.cs @@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Building { public override bool SuperUseable { get { return false; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } PerformRedo(p); } diff --git a/MCGalaxy/Commands/building/CmdRestartPhysics.cs b/MCGalaxy/Commands/building/CmdRestartPhysics.cs index c473ad8fb..734f717b7 100644 --- a/MCGalaxy/Commands/building/CmdRestartPhysics.cs +++ b/MCGalaxy/Commands/building/CmdRestartPhysics.cs @@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Building { public override void Use(Player p, string message) { PhysicsArgs extraInfo = default(PhysicsArgs); message = message.ToLower(); - if (message != "" && !ParseArgs(p, message, ref extraInfo)) return; + if (message.Length > 0 && !ParseArgs(p, message, ref extraInfo)) return; Player.Message(p, "Place or break two blocks to determine the edges."); p.MakeSelection(2, "Selecting region for %SRestart physics", extraInfo, DoRestart); diff --git a/MCGalaxy/Commands/other/QuitCmds.cs b/MCGalaxy/Commands/other/QuitCmds.cs index 665fae2b2..c1ba89a87 100644 --- a/MCGalaxy/Commands/other/QuitCmds.cs +++ b/MCGalaxy/Commands/other/QuitCmds.cs @@ -63,7 +63,7 @@ namespace MCGalaxy.Commands.Misc { public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override void Use(Player p, string message) { - if (message != "") { Help(p); return; } + if (message.Length > 0) { Help(p); return; } int code = p.random.Next(int.MinValue, int.MaxValue); p.Leave("Server crash! Error code 0x" + Convert.ToString(code, 16).ToUpper()); } @@ -82,7 +82,7 @@ namespace MCGalaxy.Commands.Misc { public override LevelPermission defaultRank { get { return LevelPermission.Banned; } } public override void Use(Player p, string message) { - if (message != "") { + if (message.Length > 0) { Player.Message(p, "&cIncorrect syntax. Abuse detected."); Thread.Sleep(3000); } diff --git a/MCGalaxy/Config/StringAttributes.cs b/MCGalaxy/Config/StringAttributes.cs index 21046e62f..286429c8d 100644 --- a/MCGalaxy/Config/StringAttributes.cs +++ b/MCGalaxy/Config/StringAttributes.cs @@ -30,7 +30,7 @@ namespace MCGalaxy.Config { string color = Colors.Parse(value); if (color.Length == 0) { color = Colors.Name(value); - if (color != "") return value; + if (color.Length > 0) return value; Logger.Log(LogType.Warning, "Config key \"{0}\" is not a valid color, using default of {1}", Name, DefaultValue); return DefaultValue; diff --git a/MCGalaxy/Economy/Awards.cs b/MCGalaxy/Economy/Awards.cs index db95fc4d5..5be442f62 100644 --- a/MCGalaxy/Economy/Awards.cs +++ b/MCGalaxy/Economy/Awards.cs @@ -67,11 +67,13 @@ namespace MCGalaxy.Eco { pl.Name = key.ToLower(); pl.Awards = new List(); - if (value.IndexOf(',') != -1) - foreach (string award in value.Split(',')) + if (value.IndexOf(',') != -1) { + foreach (string award in value.Split(',')) { pl.Awards.Add(award); - else if (value != "") + } + } else { pl.Awards.Add(value); + } PlayerAwards.Add(pl); } diff --git a/MCGalaxy/Games/LavaSurvival/LavaSurvival.Settings.cs b/MCGalaxy/Games/LavaSurvival/LavaSurvival.Settings.cs index cc0e0ad5f..0b8628f2f 100644 --- a/MCGalaxy/Games/LavaSurvival/LavaSurvival.Settings.cs +++ b/MCGalaxy/Games/LavaSurvival/LavaSurvival.Settings.cs @@ -70,7 +70,7 @@ namespace MCGalaxy.Games { case "maps": foreach (string name in value.Split(',')) { string map = name.Trim(); - if (map != "" && !maps.Contains(map)) + if (map.Length > 0 && !maps.CaselessContains(map)) maps.Add(map); } break; diff --git a/MCGalaxy/util/App.cs b/MCGalaxy/util/App.cs index 808f7ccf3..39bec13e9 100644 --- a/MCGalaxy/util/App.cs +++ b/MCGalaxy/util/App.cs @@ -40,17 +40,13 @@ namespace MCGalaxy.Gui { static void ShutdownThread(bool restarting, string msg) { saveAll(restarting, msg); if (restarting) StartProcess(); - ExitProcess(); + Environment.Exit(0); } static void StartProcess() { if (usingConsole) Process.Start(parent); else Process.Start(Application.ExecutablePath); } - - static void ExitProcess() { - Environment.Exit(0); - } public static void saveAll(bool restarting, string msg) { try {