diff --git a/Commands/Chat/CmdNick.cs b/Commands/Chat/CmdNick.cs index 72f040582..2b8247278 100644 --- a/Commands/Chat/CmdNick.cs +++ b/Commands/Chat/CmdNick.cs @@ -62,9 +62,9 @@ namespace MCGalaxy.Commands { pBot.DisplayName = pBot.name; Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sreverted to their original name."); } else { - if (newName.CaselessEq("empty")) newName = ""; - if (newName.Length >= 30) { Player.Message(p, "Name must be under 30 letters."); return; } - Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sname was set to " + newName + "%S."); + string nameTag = newName.CaselessEq("empty") ? "" : newName; + if (newName.Length >= 30) { Player.Message(p, "Name must be under 30 letters."); return; } + Player.GlobalMessage("Bot " + pBot.ColoredName + "'s %Sname was set to " + nameTag + "%S."); pBot.DisplayName = newName; } diff --git a/Commands/building/CmdMessageBlock.cs b/Commands/building/CmdMessageBlock.cs index 328d43d69..1c994531c 100644 --- a/Commands/building/CmdMessageBlock.cs +++ b/Commands/building/CmdMessageBlock.cs @@ -87,8 +87,8 @@ namespace MCGalaxy.Commands.Building { p.ClearBlockchange(); CatchPos cpos = (CatchPos)p.blockchangeObject; - byte b = p.level.GetTile(x, y, z); - if (p.level.CheckAffectPermissions(p, x, y, z, b, cpos.type, 0)) { + byte old = p.level.GetTile(x, y, z); + if (p.level.CheckAffectPermissions(p, x, y, z, old, cpos.type, 0)) { p.level.Blockchange(p, x, y, z, cpos.type, 0); p.SendBlockchange(x, y, z, cpos.type, 0); // for when same block type but different message UpdateDatabase(p, cpos, x, y, z); diff --git a/Commands/building/CmdPortal.cs b/Commands/building/CmdPortal.cs index e05f60a11..ede64f760 100644 --- a/Commands/building/CmdPortal.cs +++ b/Commands/building/CmdPortal.cs @@ -60,7 +60,8 @@ namespace MCGalaxy.Commands.Building { void EntryChange(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { PortalData bp = (PortalData)p.blockchangeObject; - if (!p.level.CheckAffectPermissions(p, x, y, z, type, extType)) { + byte old = p.level.GetTile(x, y, z); + if (!p.level.CheckAffectPermissions(p, x, y, z, old, type, extType)) { p.RevertBlock(x, y, z); return; } p.ClearBlockchange(); diff --git a/Drawing/DrawOps/DrawOp.Performer.cs b/Drawing/DrawOps/DrawOp.Performer.cs index 82b2a9ad8..91bed6ee2 100644 --- a/Drawing/DrawOps/DrawOp.Performer.cs +++ b/Drawing/DrawOps/DrawOp.Performer.cs @@ -133,7 +133,7 @@ namespace MCGalaxy.Drawing.Ops { foreach (var b in item.Op.Perform(item.Marks, p, lvl, item.Brush)) { if (b.Block == Block.Zero) continue; byte old = lvl.GetTile(b.X, b.Y, b.Z); - if (old == Block.Zero || !lvl.CheckAffectPermissions(p, b.X, b.Y, b.Z, old, b.Block)) + if (old == Block.Zero || !lvl.CheckAffectPermissions(p, b.X, b.Y, b.Z, old, b.Block, b.ExtBlock)) continue; lvl.SetTile(b.X, b.Y, b.Z, b.Block, p, b.ExtBlock); diff --git a/Levels/Level.Blocks.cs b/Levels/Level.Blocks.cs index ccfa9dd26..f79ba9fe0 100644 --- a/Levels/Level.Blocks.cs +++ b/Levels/Level.Blocks.cs @@ -239,7 +239,8 @@ namespace MCGalaxy { return true; } - public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, byte b, byte type, byte extType = 0) { + public bool CheckAffectPermissions(Player p, ushort x, ushort y, ushort z, + byte b, byte type, byte extType = 0) { if (!Block.AllowBreak(b) && !Block.canPlace(p, b) && !Block.BuildIn(b)) return false; if (p.PlayingTntWars && !CheckTNTWarsChange(p, x, y, z, ref type)) return false; @@ -266,24 +267,24 @@ namespace MCGalaxy { { //if (x < 0 || y < 0 || z < 0) return; if (x >= Width || y >= Height || z >= Length) return false; - byte b = GetTile(x, y, z), extB = 0; - if (b == Block.custom_block) extB = GetExtTile(x, y, z); + byte old = GetTile(x, y, z), extOld = 0; + if (old == Block.custom_block) extOld = GetExtTile(x, y, z); errorLocation = "Permission checking"; - if (!CheckAffectPermissions(p, x, y, z, b, block, extBlock)) { + if (!CheckAffectPermissions(p, x, y, z, old, block, extBlock)) { p.RevertBlock(x, y, z); return false; } - if (b == Block.sponge && physics > 0 && block != Block.sponge) + if (old == Block.sponge && physics > 0 && block != Block.sponge) OtherPhysics.DoSpongeRemoved(this, PosToInt(x, y, z)); - if (b == Block.lava_sponge && physics > 0 && block != Block.lava_sponge) + if (old == Block.lava_sponge && physics > 0 && block != Block.lava_sponge) OtherPhysics.DoSpongeRemoved(this, PosToInt(x, y, z), true); errorLocation = "Undo buffer filling"; Player.UndoPos Pos; Pos.x = x; Pos.y = y; Pos.z = z; Pos.mapName = name; - Pos.type = b; Pos.extType = extB; + Pos.type = old; Pos.extType = extOld; Pos.newtype = block; Pos.newExtType = extBlock; Pos.timeDelta = (int)DateTime.UtcNow.Subtract(Server.StartTime).TotalSeconds; p.UndoBuffer.Add(this, Pos); @@ -292,7 +293,7 @@ namespace MCGalaxy { p.IncrementBlockStats(block, drawn); SetTile(x, y, z, block); - if (b == Block.custom_block && block != Block.custom_block) + if (old == Block.custom_block && block != Block.custom_block) RevertExtTileNoCheck(x, y, z); if (block == Block.custom_block) SetExtTileNoCheck(x, y, z, extBlock); @@ -303,8 +304,8 @@ namespace MCGalaxy { changed = true; backedup = false; - bool diffBlock = b == Block.custom_block ? extB != extBlock : - Block.Convert(b) != Block.Convert(block); + bool diffBlock = old == Block.custom_block ? extOld != extBlock : + Block.Convert(old) != Block.Convert(block); return diffBlock; } catch (OutOfMemoryException) { Player.Message(p, "Undo buffer too big! Cleared!"); diff --git a/Player/Entities.cs b/Player/Entities.cs index 180465ef0..60d157c81 100644 --- a/Player/Entities.cs +++ b/Player/Entities.cs @@ -136,13 +136,15 @@ namespace MCGalaxy { } internal static void Spawn(Player dst, PlayerBot b) { - string name = Chat.ApplyTokens(b.DisplayName, dst); + string name = Chat.ApplyTokens(b.DisplayName, dst); + if (name.CaselessEq("empty")) name = ""; + else name = b.color + name; string skin = Chat.ApplyTokens(b.SkinName, dst); if (dst.hasExtList) { - dst.SendExtAddEntity2(b.id, skin, b.color + name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); + dst.SendExtAddEntity2(b.id, skin, name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } else { - dst.SendSpawn(b.id, b.color + name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); + dst.SendSpawn(b.id, name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } if (Server.TablistBots) TabList.Add(dst, b);