diff --git a/Color.cs b/Color.cs index b030b9c67..20fbbb6a2 100644 --- a/Color.cs +++ b/Color.cs @@ -110,7 +110,7 @@ namespace MCGalaxy default: return 0; } } - static readonly Dictionary MinecraftToIRCColors = new Dictionary { + public static readonly Dictionary MinecraftToIRCColors = new Dictionary { { white, "\u000300" }, { black, "\u000301" }, { navy, "\u000302" }, @@ -188,5 +188,31 @@ namespace MCGalaxy default: return ""; } } + /// Replaces Minecraft color codes with equivalent IRC color codes, in the given StringBuilder. + /// Opposite of IrcToMinecraftColors method. + /// StringBuilder objects, the contents of which will be processed. + /// sb is null. + public static void MinecraftToIrcColors(StringBuilder sb) + { + if (sb == null) throw new ArgumentNullException("sb"); + foreach (var codePair in MinecraftToIRCColors) + { + sb.Replace(codePair.Key, codePair.Value); + } + } + + + /// Replaces Minecraft color codes with equivalent IRC color codes, in the given string. + /// Opposite of IrcToMinecraftColors method. + /// String to process. + /// A processed string. + /// input is null. + public static string MinecraftToIrcColors(string input) + { + if (input == null) throw new ArgumentNullException("input"); + StringBuilder sb = new StringBuilder(input); + MinecraftToIrcColors(sb); + return sb.ToString(); + } } } \ No newline at end of file diff --git a/Commands/CmdCuboid.cs b/Commands/CmdCuboid.cs index 8e2779447..cd56863c8 100644 --- a/Commands/CmdCuboid.cs +++ b/Commands/CmdCuboid.cs @@ -456,7 +456,7 @@ namespace MCGalaxy.Commands p.SendMessage("You tried to cuboid over 10000 blocks, reloading map for faster cuboid."); buffer.ForEach(delegate(Pos pos) { - p.level.SetTile(pos.x, pos.y, pos.z, type); + p.level.SetTile(pos.x, pos.y, pos.z, type, p); }); foreach(Player pl in Player.players) { diff --git a/Commands/CmdFill.cs b/Commands/CmdFill.cs index b7675c659..60bf40b3a 100644 --- a/Commands/CmdFill.cs +++ b/Commands/CmdFill.cs @@ -145,7 +145,7 @@ namespace MCGalaxy.Commands p.SendMessage("You tried to cuboid over 10000 blocks, reloading map for faster fill."); foreach (Pos pos in buffer) { - p.level.SetTile(pos.x, pos.y, pos.z, cpos.type); + p.level.SetTile(pos.x, pos.y, pos.z, cpos.type, p); } foreach (Player pl in Player.players) { diff --git a/Commands/CmdReplace.cs b/Commands/CmdReplace.cs index a622122b6..7e5de9bbe 100644 --- a/Commands/CmdReplace.cs +++ b/Commands/CmdReplace.cs @@ -142,7 +142,7 @@ namespace MCGalaxy.Commands p.SendMessage("You tried to replace over 10000 blocks, reloading map for faster replace."); foreach (Pos pos in buffer) { - p.level.SetTile(pos.x, pos.y, pos.z, cpos.newType); + p.level.SetTile(pos.x, pos.y, pos.z, cpos.newType, p); } foreach (Player pl in Player.players) { diff --git a/Commands/CmdReplaceAll.cs b/Commands/CmdReplaceAll.cs index 9267b5a4c..596ac10bb 100644 --- a/Commands/CmdReplaceAll.cs +++ b/Commands/CmdReplaceAll.cs @@ -113,7 +113,7 @@ namespace MCGalaxy.Commands p.SendMessage("You tried to replace over 10000 blocks, reloading map for faster replace."); foreach (Pos Pos in stored) { - p.level.SetTile(Pos.x, Pos.y, Pos.z, newType); + p.level.SetTile(Pos.x, Pos.y, Pos.z, newType, p); } foreach (Player pl in Player.players) { diff --git a/Commands/CmdReplaceNot.cs b/Commands/CmdReplaceNot.cs index f0635b74e..585f62d2a 100644 --- a/Commands/CmdReplaceNot.cs +++ b/Commands/CmdReplaceNot.cs @@ -135,7 +135,7 @@ namespace MCGalaxy.Commands p.SendMessage("You tried to replace over 10000 blocks, reloading map for faster replace."); foreach (Pos pos in buffer) { - p.level.SetTile(pos.x, pos.y, pos.z, cpos.newType); + p.level.SetTile(pos.x, pos.y, pos.z, cpos.newType, p); } foreach (Player pl in Player.players) { diff --git a/ForgeBot.cs b/ForgeBot.cs index 297217e34..7114a0578 100644 --- a/ForgeBot.cs +++ b/ForgeBot.cs @@ -91,14 +91,20 @@ namespace MCGalaxy { message = "."; if (color) { - for (int i = 0; i < 10; i++) { - sb.Replace("%" + i, ColorSignal + c.MCtoIRC("&" + i)); - sb.Replace("&" + i, ColorSignal + c.MCtoIRC("&" + i)); - } - for (char ch = 'a'; ch <= 'f'; ch++) { - sb.Replace("%" + ch, ColorSignal + c.MCtoIRC("&" + ch)); - sb.Replace("&" + ch, ColorSignal + c.MCtoIRC("&" + ch)); - } + for (int i = 0; i < 10; i++) + { + sb.Replace("%" + i, ColorSignal + c.MCtoIRC("&" + i)); + //sb.Replace("&" + i, ColorSignal + c.MCtoIRC("&" + i)); + } + for (char ch = 'a'; ch <= 'f'; ch++) + { + sb.Replace("%" + ch, ColorSignal2 + c.MCtoIRC("&" + ch)); + //sb.Replace("&" + ch, ColorSignal2 + c.MCtoIRC("&" + ch)); + } + foreach (var codePair in c.MinecraftToIRCColors) + { + message.Replace(codePair.Key, codePair.Value); + } } sb.Replace("%r", ResetSignal); @@ -207,6 +213,10 @@ namespace MCGalaxy { Server.IRC.Say("Unknown command!"); } } + for (byte i = 10; i < 16; i++) + message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%')); + for (byte i = 0; i < 10; i++) + message = message.Replace(ColorSignal + i, c.IRCtoMC(i).Replace('&', '%')); message = c.IrcToMinecraftColors(message); if(String.IsNullOrEmpty(message.Trim())) diff --git a/Levels/Level.cs b/Levels/Level.cs index 90d0a195b..dc05f978f 100644 --- a/Levels/Level.cs +++ b/Levels/Level.cs @@ -457,12 +457,24 @@ namespace MCGalaxy blocks[b] = type; //blockchanges[x + width * z + width * height * y] = pName; } - public void SetTile(ushort x, ushort y, ushort z, byte type) + public void SetTile(ushort x, ushort y, ushort z, byte type, Player p = null) { if (blocks == null) return; if (!InBound(x, y, z)) return; blocks[PosToInt(x, y, z)] = type; - //blockchanges[x + width * z + width * height * y] = pName; + if (p != null) + { + Level.BlockPos bP; + bP.name = p.name; + bP.TimePerformed = DateTime.Now; + bP.x = x; bP.y = y; bP.z = z; + bP.type = type; + if (bP.type == 0) + bP.deleted = true; + else + bP.deleted = false; + blockCache.Add(bP); + } } public bool InBound(ushort x, ushort y, ushort z) diff --git a/Player/Player.cs b/Player/Player.cs index 7ace31fbc..105330009 100644 --- a/Player/Player.cs +++ b/Player/Player.cs @@ -2749,12 +2749,13 @@ return; sb.Replace("%r", "&f"); for ( int i = 0; i < 10; i++ ) { sb.Replace("%" + i, "&" + i); - sb.Replace("&" + i + " &", " &"); + //sb.Replace("&" + i + " &", " &"); } for ( char ch = 'a'; ch <= 'f'; ch++ ) { sb.Replace("%" + ch, "&" + ch); - sb.Replace("&" + ch + " &", " &"); + //sb.Replace("&" + ch + " &", " &"); } + message = c.MinecraftToIrcColors(message); // Begin fix to replace all invalid color codes typed in console or chat with "." for ( char ch = (char)0; ch <= (char)47; ch++ ) // Characters that cause clients to disconnect sb.Replace("&" + ch, String.Empty); diff --git a/Uploads/MCGalaxy.exe b/Uploads/MCGalaxy.exe index 309da2f5c..9a5f95325 100644 Binary files a/Uploads/MCGalaxy.exe and b/Uploads/MCGalaxy.exe differ diff --git a/Uploads/MCGalaxy_.dll b/Uploads/MCGalaxy_.dll index b971ccbc2..53d161039 100644 Binary files a/Uploads/MCGalaxy_.dll and b/Uploads/MCGalaxy_.dll differ diff --git a/Uploads/current_version.txt b/Uploads/current_version.txt index b6c8757ca..4e1a34234 100644 --- a/Uploads/current_version.txt +++ b/Uploads/current_version.txt @@ -1 +1 @@ -1.5.0.8 \ No newline at end of file +1.5.1.0 \ No newline at end of file diff --git a/properties/AssemblyInfo.cs b/properties/AssemblyInfo.cs index 6317ba3f2..d5a95d36b 100644 --- a/properties/AssemblyInfo.cs +++ b/properties/AssemblyInfo.cs @@ -37,7 +37,7 @@ using System.Runtime.InteropServices; // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("24d9085c-78ba-4f53-b69c-f2b52153683f")] -[assembly: AssemblyVersion("1.5.0.8")] +[assembly: AssemblyVersion("1.5.1.0")] // Version information for an assembly consists of the following four values: //