public static void Removal(ConcurrentDictionary <string, Vector3I> bullets, Map map) { foreach (Vector3I bp in bullets.Values) { map.QueueUpdate(new BlockUpdate(null, (short)bp.X, (short)bp.Y, (short)bp.Z, Block.Air)); bullets.TryRemove(bp.ToString(), out _); } }
public static void PlayerDisconnected(object sender, PlayerDisconnectedEventArgs e) { try { if (e.Player.World == null) { return; } if (e.Player.World.IsLoaded) { Map map = e.Player.World.Map; if (e.Player.orangePortal.Count > 0) { int i = 0; foreach (Vector3I block in e.Player.orangePortal) { map?.QueueUpdate(new BlockUpdate(null, block, e.Player.orangeOld[i])); i++; } e.Player.orangeOld.Clear(); e.Player.orangePortal.Clear(); } if (e.Player.bluePortal.Count <= 0) { return; } { int i = 0; foreach (Vector3I block in e.Player.bluePortal) { map?.QueueUpdate(new BlockUpdate(null, block, e.Player.blueOld[i])); i++; } e.Player.blueOld.Clear(); e.Player.bluePortal.Clear(); } } else { if (e.Player.bluePortal.Count > 0) { if (e.Player.World.Map != null) { e.Player.World.Map.Blocks[e.Player.World.Map.Index(e.Player.bluePortal[0])] = (byte)e.Player.blueOld[0]; e.Player.World.Map.Blocks[e.Player.World.Map.Index(e.Player.bluePortal[1])] = (byte)e.Player.blueOld[1]; } } if (e.Player.orangePortal.Count <= 0) { return; } e.Player.WorldMap.Blocks[e.Player.WorldMap.Index(e.Player.orangePortal[0])] = (byte)e.Player.orangeOld[0]; e.Player.WorldMap.Blocks[e.Player.WorldMap.Index(e.Player.orangePortal[1])] = (byte)e.Player.orangeOld[1]; } } catch (Exception ex) { Logger.Log(LogType.SeriousError, "GunPortalDisconnected: " + ex); } }