diff --git a/Commands/building/CmdMark.cs b/Commands/building/CmdMark.cs index 20b5c20af..ed9507336 100644 --- a/Commands/building/CmdMark.cs +++ b/Commands/building/CmdMark.cs @@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.Building { if (!p.HasBlockchange) { Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return; } - p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock); + p.ManualChange(P.X, P.Y, P.Z, 0, Block.rock, 0, false); Player.Message(p, "Mark placed at &b({0}, {1}, {2})", P.X, P.Y, P.Z); } diff --git a/Commands/other/CmdC4.cs b/Commands/other/CmdC4.cs index 86e4d442f..90d09b6a4 100644 --- a/Commands/other/CmdC4.cs +++ b/Commands/other/CmdC4.cs @@ -46,11 +46,11 @@ namespace MCGalaxy.Commands void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { p.ClearBlockchange(); if (type == Block.red) { - p.ManualChange(x, y, z, 1, Block.c4det, 0); + p.ManualChange(x, y, z, 1, Block.c4det); Player.Message(p, "Placed detonator block!"); return; } else if (type != Block.air) { - p.ManualChange(x, y, z, 1, Block.c4, 0); + p.ManualChange(x, y, z, 1, Block.c4); } p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); } diff --git a/Player/Group/Group.cs b/Player/Group/Group.cs index e18735597..716f27bf3 100644 --- a/Player/Group/Group.cs +++ b/Player/Group/Group.cs @@ -114,6 +114,7 @@ namespace MCGalaxy public static List GroupList = new List(); public static Group standard; + static readonly object saveLock = new object(); /// Load up all server groups public static void InitAll() { @@ -146,9 +147,10 @@ namespace MCGalaxy /// Save givenList group /// The list of groups to save public static void saveGroups(List givenList) { - GroupProperties.SaveGroups(givenList); - if (OnGroupSave != null) - OnGroupSave(); + lock (saveLock) + GroupProperties.SaveGroups(givenList); + + if (OnGroupSave != null) OnGroupSave(); OnGroupSaveEvent.Call(); } diff --git a/Player/Group/GroupCommands.cs b/Player/Group/GroupCommands.cs index 11138dbe4..1649c843f 100644 --- a/Player/Group/GroupCommands.cs +++ b/Player/Group/GroupCommands.cs @@ -129,7 +129,13 @@ namespace MCGalaxy { } } + static readonly object saveLock = new object(); public static void Save(List givenList) { + lock (saveLock) + SaveCore(givenList); + } + + static void SaveCore(List givenList) { try { using (StreamWriter w = new StreamWriter("properties/command.properties")) { w.WriteLine("#Version 2"); diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index 52d8963e9..64a22ba0a 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -45,6 +45,11 @@ namespace MCGalaxy { } public void ManualChange(ushort x, ushort y, ushort z, byte action, byte type, byte extType = 0) { + ManualChange(x, y, z, action, type, extType, true); + } + + public void ManualChange(ushort x, ushort y, ushort z, byte action, + byte type, byte extType, bool checkPlaceDist) { byte b = level.GetTile(x, y, z); if ( b == Block.Zero ) { return; } if ( jailed || !agreed ) { RevertBlock(x, y, z); return; } @@ -91,12 +96,12 @@ namespace MCGalaxy { OnBlockChangeEvent.Call(this, x, y, z, type, extType); if ( cancelBlock ) { cancelBlock = false; return; } - if ( group.Permission == LevelPermission.Banned ) return; - if ( group.Permission == LevelPermission.Guest ) { - int Diff = Math.Abs((pos[0] / 32) - x) + Math.Abs((pos[1] / 32) - y) - + Math.Abs((pos[2] / 32) - z); + if (group.Permission == LevelPermission.Banned) return; + if (checkPlaceDist && group.Permission == LevelPermission.Guest) { + int Diff = Math.Abs(((short)pos[0] / 32) - x) + Math.Abs(((short)pos[1] / 32) - y) + + Math.Abs(((short)pos[2] / 32) - z); - if ((Diff > ReachDistance + 4) && !(lastCMD == "click" || lastCMD == "mark")) { + if (Diff > ReachDistance + 4) { Server.s.Log(name + " attempted to build with a " + Diff + " distance offset"); SendMessage("You can't build that far away."); RevertBlock(x, y, z); return;