From d60092502b9a37e9bf5432ec3209d961703ca936 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 9 Jan 2017 19:45:44 +1100 Subject: [PATCH] Style: less var --- MCGalaxy/Bots/BotsFile.cs | 2 +- MCGalaxy/Bots/ScriptFile.cs | 2 +- MCGalaxy/Chat/ChatTokens.cs | 4 ++-- MCGalaxy/Chat/Colors.cs | 10 +++++++--- MCGalaxy/Commands/CommandList.cs | 2 +- MCGalaxy/Levels/IO/fNbt.cs | 6 +++--- MCGalaxy/Network/Heart.cs | 6 +++--- MCGalaxy/Network/Player.Networking.cs | 6 +++--- MCGalaxy/Player/Player.cs | 2 +- MCGalaxy/Scripting/Scripting.cs | 2 +- MCGalaxy/Server/Extra/UPnP.cs | 2 +- MCGalaxy/Server/Server.cs | 2 +- MCGalaxy/util/Formatter.cs | 2 +- 13 files changed, 26 insertions(+), 22 deletions(-) diff --git a/MCGalaxy/Bots/BotsFile.cs b/MCGalaxy/Bots/BotsFile.cs index 8c6da96e6..c6c677e05 100644 --- a/MCGalaxy/Bots/BotsFile.cs +++ b/MCGalaxy/Bots/BotsFile.cs @@ -33,7 +33,7 @@ namespace MCGalaxy.Bots { if (!File.Exists("extra/bots.json")) return; lock (locker) { string json = File.ReadAllText("extra/bots.json"); - var bots = JsonConvert.DeserializeObject(json); + BotProperties[] bots = JsonConvert.DeserializeObject(json); SavedBots = new List(bots); foreach (BotProperties bot in SavedBots) { diff --git a/MCGalaxy/Bots/ScriptFile.cs b/MCGalaxy/Bots/ScriptFile.cs index ff3f073fc..fff9aebc8 100644 --- a/MCGalaxy/Bots/ScriptFile.cs +++ b/MCGalaxy/Bots/ScriptFile.cs @@ -58,7 +58,7 @@ namespace MCGalaxy.Bots { Player.Message(p, "Could not find instruction \"" + action + "\""); return; } - var perms = CommandOtherPerms.Find("botset"); + CommandOtherPerms.OtherPerms perms = CommandOtherPerms.Find("botset"); LevelPermission killPerm = (LevelPermission)perms.Permission; if (ins.Name.CaselessEq("kill") && p.Rank < killPerm) { Formatter.MessageNeedMinPerm(p, "toggle a bot's killer instinct.", killPerm); diff --git a/MCGalaxy/Chat/ChatTokens.cs b/MCGalaxy/Chat/ChatTokens.cs index 768c1ae83..cd1ef72f9 100644 --- a/MCGalaxy/Chat/ChatTokens.cs +++ b/MCGalaxy/Chat/ChatTokens.cs @@ -16,7 +16,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; -using TokenParser = System.Func; namespace MCGalaxy { public static class ChatTokens { @@ -54,7 +53,8 @@ namespace MCGalaxy { } - internal static Dictionary standardTokens = new Dictionary { + internal static Dictionary> standardTokens + = new Dictionary> { { "$name", p => p.DisplayName == null ? null : (Server.dollarNames ? "$" : "") + Colors.StripColors(p.DisplayName) }, { "$truename", p => p.truename == null ? null : diff --git a/MCGalaxy/Chat/Colors.cs b/MCGalaxy/Chat/Colors.cs index 7703dd46a..dca46ce2c 100644 --- a/MCGalaxy/Chat/Colors.cs +++ b/MCGalaxy/Chat/Colors.cs @@ -112,10 +112,13 @@ namespace MCGalaxy { input = IrcTwoColorCode.Replace(input, "$1"); StringBuilder sb = new StringBuilder(input); - foreach (var kvp in ircColors) + foreach (KeyValuePair kvp in ircColors) { sb.Replace(kvp.Value, kvp.Key); - foreach (var kvp in ircSingleColors) + } + foreach (KeyValuePair kvp in ircSingleColors) { sb.Replace(kvp.Value, kvp.Key); + } + sb.Replace("\u0003", white); // color reset sb.Replace("\u000f", white); // reset return sb.ToString(); @@ -132,8 +135,9 @@ namespace MCGalaxy { sb.Replace("&" + col.Code, "&" + col.Fallback); } - foreach (var kvp in ircColors) + foreach (KeyValuePair kvp in ircColors) { sb.Replace(kvp.Key, kvp.Value); + } return sb.ToString(); } diff --git a/MCGalaxy/Commands/CommandList.cs b/MCGalaxy/Commands/CommandList.cs index 390578ad0..9973eb704 100644 --- a/MCGalaxy/Commands/CommandList.cs +++ b/MCGalaxy/Commands/CommandList.cs @@ -36,7 +36,7 @@ namespace MCGalaxy { } public List commandNames() { - var tempList = new List(commands.Count); + List tempList = new List(commands.Count); commands.ForEach(cmd => tempList.Add(cmd.name)); return tempList; } diff --git a/MCGalaxy/Levels/IO/fNbt.cs b/MCGalaxy/Levels/IO/fNbt.cs index a4796481d..4531dc3db 100644 --- a/MCGalaxy/Levels/IO/fNbt.cs +++ b/MCGalaxy/Levels/IO/fNbt.cs @@ -412,7 +412,7 @@ namespace fNbt { static int Swap(int v) { unchecked { - var v2 = (uint)v; + uint v2 = (uint)v; return (int) ((v2 >> 24) & 0x000000FF | (v2 >> 8) & 0x0000FF00 | (v2 << 8) & 0x00FF0000 | @@ -446,8 +446,8 @@ namespace fNbt { if (header != (int)NbtTagType.Compound) throw new NbtFormatException("Given NBT stream does not start with a TAG_Compound"); - var reader = new NbtBinaryReader(buffered, true); - var rootCompound = new NbtCompound(reader.ReadString()); + NbtBinaryReader reader = new NbtBinaryReader(buffered, true); + NbtCompound rootCompound = new NbtCompound(reader.ReadString()); rootCompound.ReadTag(reader); RootTag = rootCompound; } diff --git a/MCGalaxy/Network/Heart.cs b/MCGalaxy/Network/Heart.cs index 3248ccd75..024170156 100644 --- a/MCGalaxy/Network/Heart.cs +++ b/MCGalaxy/Network/Heart.cs @@ -76,7 +76,7 @@ namespace MCGalaxy { for (int i = 0; i < MAX_RETRIES; i++) { try { - var req = WebRequest.Create(beat.URL) as HttpWebRequest; + HttpWebRequest req = WebRequest.Create(beat.URL) as HttpWebRequest; req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); @@ -84,12 +84,12 @@ namespace MCGalaxy { req.ContentLength = data.Length; beat.OnRequest(req); - using (var w = req.GetRequestStream()) { + using (Stream w = req.GetRequestStream()) { w.Write(data, 0, data.Length); if (Server.logbeat) Server.s.Log("Beat " + beat + " was sent"); } - using (var r = new StreamReader(req.GetResponse().GetResponseStream())) { + using (StreamReader r = new StreamReader(req.GetResponse().GetResponseStream())) { string read = r.ReadToEnd().Trim(); beat.OnResponse(read); diff --git a/MCGalaxy/Network/Player.Networking.cs b/MCGalaxy/Network/Player.Networking.cs index 4c91c2d03..2278e0cd4 100644 --- a/MCGalaxy/Network/Player.Networking.cs +++ b/MCGalaxy/Network/Player.Networking.cs @@ -81,8 +81,8 @@ namespace MCGalaxy { void HandlePlayerClicked(byte[] packet) { if (OnPlayerClick == null) return; - var Button = (MouseButton)packet[1]; - var Action = (MouseAction)packet[2]; + MouseButton Button = (MouseButton)packet[1]; + MouseAction Action = (MouseAction)packet[2]; ushort Yaw = NetUtils.ReadU16(packet, 3); ushort Pitch = NetUtils.ReadU16(packet, 5); byte EntityID = packet[7]; @@ -91,7 +91,7 @@ namespace MCGalaxy { ushort Z = NetUtils.ReadU16(packet, 12); byte Face = packet[14]; - var face = TargetBlockFace.None; + TargetBlockFace face = TargetBlockFace.None; if (Face < (byte)face) face = (TargetBlockFace)Face; OnPlayerClick(this, Button, Action, Yaw, Pitch, EntityID, X, Y, Z, face); diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index e59a0178a..49e1c87a9 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -150,7 +150,7 @@ namespace MCGalaxy { public static void SendChatFrom(Player from, string message, bool showname) { if (from == null) return; if (Last50Chat.Count == 50) Last50Chat.RemoveAt(0); - var chatmessage = new ChatMessage(); + ChatMessage chatmessage = new ChatMessage(); chatmessage.text = message; chatmessage.username = from.color + from.name; chatmessage.time = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss"); diff --git a/MCGalaxy/Scripting/Scripting.cs b/MCGalaxy/Scripting/Scripting.cs index 4428a6c38..10f6f56e4 100644 --- a/MCGalaxy/Scripting/Scripting.cs +++ b/MCGalaxy/Scripting/Scripting.cs @@ -68,7 +68,7 @@ namespace MCGalaxy { syntax = String.Format(syntax, cmdName.Capitalize(), cmdName); string path = SourceDir + "Cmd" + cmdName + Ext; - using (var sw = new StreamWriter(path)) + using (StreamWriter sw = new StreamWriter(path)) sw.WriteLine(syntax); } diff --git a/MCGalaxy/Server/Extra/UPnP.cs b/MCGalaxy/Server/Extra/UPnP.cs index 0415ef6ed..4844b46e9 100644 --- a/MCGalaxy/Server/Extra/UPnP.cs +++ b/MCGalaxy/Server/Extra/UPnP.cs @@ -91,7 +91,7 @@ namespace MCGalaxy.Core { try { #endif XmlDocument desc = new XmlDocument(); - var request = WebRequest.CreateDefault(new Uri(resp)); + WebRequest request = WebRequest.CreateDefault(new Uri(resp)); desc.Load(request.GetResponse().GetResponseStream()); XmlNamespaceManager nsMgr = new XmlNamespaceManager(desc.NameTable); nsMgr.AddNamespace("tns", "urn:schemas-upnp-org:device-1-0"); diff --git a/MCGalaxy/Server/Server.cs b/MCGalaxy/Server/Server.cs index 44798b7ed..caac15528 100644 --- a/MCGalaxy/Server/Server.cs +++ b/MCGalaxy/Server/Server.cs @@ -189,7 +189,7 @@ namespace MCGalaxy { } static void FixupOldPerms() { - var perms = SrvProperties.oldPerms; + SrvProperties.OldPerms perms = SrvProperties.oldPerms; Server.opchatperm = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator); Server.adminchatperm = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); if (perms.clearPerm == -1 && perms.nextPerm == -1 && perms.viewPerm == -1 diff --git a/MCGalaxy/util/Formatter.cs b/MCGalaxy/util/Formatter.cs index 3a63409e8..670b9465d 100644 --- a/MCGalaxy/util/Formatter.cs +++ b/MCGalaxy/util/Formatter.cs @@ -57,7 +57,7 @@ namespace MCGalaxy { Player.Message(p, "%TExtra permissions:"); for (int i = 0; i < addPerms.Length; i++) { - var extra = CommandOtherPerms.Find(cmd, i + 1); + CommandOtherPerms.OtherPerms extra = CommandOtherPerms.Find(cmd, i + 1); LevelPermission perm = (LevelPermission)extra.Permission; Player.Message(p, "{0}) {1}%S{2}", i + 1, Group.GetColoredName(perm), extra.Description); }