static void MapsHandler(NetworkClient client, string[] args, string text1, string text2) { var mapString = "§SMaps:<br>"; foreach (var m in ServerCore.Maps.Values) { if (client.HasAllPermissions(m.Showperms.Values.ToList())) mapString += "§S" + m.CWMap.MapName + " §D "; } Chat.SendClientChat(client, mapString); }
/// <summary> /// Sends additional packets to clients after sending the map to the client. /// </summary> /// <param name="client"></param> public static void PostMapActions(NetworkClient client) { int mapAppearance, blockPerms, weatherVer, colorVer; // -- EnvMapAppearance if (client.CS.CPEExtensions.TryGetValue("EnvMapAppearance", out mapAppearance) && mapAppearance == EnvMapAppearanceVersion) { var cpeData = client.CS.CurrentMap.CPESettings; var mapApprPacket = new EnvSetMapAppearance { EdgeBlock = cpeData.EdgeBlock, SideBlock = cpeData.SideBlock, SideLevel = cpeData.SideLevel, TextureUrl = cpeData.TextureUrl }; // -- Customblocks compatibility check if (mapApprPacket.EdgeBlock > 49) { var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.EdgeBlock); if (mBlock.CPELevel > client.CS.CustomBlocksLevel) mapApprPacket.EdgeBlock = (byte)mBlock.CPEReplace; } if (mapApprPacket.SideBlock > 49) { var mBlock = ServerCore.Blockholder.GetBlock(mapApprPacket.SideBlock); if (mBlock.CPELevel > client.CS.CustomBlocksLevel) mapApprPacket.SideBlock = (byte)mBlock.CPEReplace; } client.SendQueue.Enqueue(mapApprPacket); } // -- BlockPermissions if (client.CS.CPEExtensions.TryGetValue("BlockPermissions", out blockPerms) && blockPerms == BlockPermissionsVersion) { foreach (var block in ServerCore.Blockholder.NumberList) { // -- For every block if (block.CPELevel > client.CS.CustomBlocksLevel) // -- If its within this player's CustomBlock support continue; if (block.Name == "Unknown") // -- If its not an unknown block continue; if (block.Special) // -- If it's not a custom block. continue; var disallowPlace = new SetBlockPermissions { // -- THen set the permissions for the block AllowDeletion = 1, AllowPlacement = 1, BlockType = block.OnClient, }; if (!client.HasAllPermissions(block.PlacePermissions)) { disallowPlace.AllowPlacement = 0; } if (!client.HasAllPermissions(block.DeletePermissions)) disallowPlace.AllowDeletion = 0; if (disallowPlace.AllowDeletion != 1 || disallowPlace.AllowPlacement != 1) // -- Only send if we're changing permissions though client.SendQueue.Enqueue(disallowPlace); } } // -- EnvWeatherType if (client.CS.CPEExtensions.TryGetValue("EnvWeatherType", out weatherVer) && weatherVer == EnvWeatherTypeVersion) { var weather = new EnvSetWeatherType { WeatherType = client.CS.CurrentMap.CPESettings.Weather, }; client.SendQueue.Enqueue(weather); } // -- EnvColors if (client.CS.CPEExtensions.TryGetValue("EnvColors", out colorVer) && colorVer == EnvColorsVersion) { // -- if envcolors is enabled on the map if (client.CS.CurrentMap.CPESettings.EnvColorsVersion > 0) { var skyColor = new EnvSetColor { ColorType = (byte) EnvSetColor.ColorTypes.SkyColor, Red = client.CS.CurrentMap.CPESettings.SkyColor[0], Green = client.CS.CurrentMap.CPESettings.SkyColor[1], Blue = client.CS.CurrentMap.CPESettings.SkyColor[2], }; var cloudColor = new EnvSetColor { ColorType = (byte)EnvSetColor.ColorTypes.CloudColor, Red = client.CS.CurrentMap.CPESettings.CloudColor[0], Green = client.CS.CurrentMap.CPESettings.CloudColor[1], Blue = client.CS.CurrentMap.CPESettings.CloudColor[2], }; var fogColor = new EnvSetColor { ColorType = (byte)EnvSetColor.ColorTypes.FogColor, Red = client.CS.CurrentMap.CPESettings.FogColor[0], Green = client.CS.CurrentMap.CPESettings.FogColor[1], Blue = client.CS.CurrentMap.CPESettings.FogColor[2], }; var ambeintColor = new EnvSetColor { ColorType = (byte)EnvSetColor.ColorTypes.AmbientColor, Red = client.CS.CurrentMap.CPESettings.AmbientColor[0], Green = client.CS.CurrentMap.CPESettings.AmbientColor[1], Blue = client.CS.CurrentMap.CPESettings.AmbientColor[2], }; var sunlightColor = new EnvSetColor { ColorType = (byte)EnvSetColor.ColorTypes.SunlightColor, Red = client.CS.CurrentMap.CPESettings.SunlightColor[0], Green = client.CS.CurrentMap.CPESettings.SunlightColor[1], Blue = client.CS.CurrentMap.CPESettings.SunlightColor[2], }; client.SendQueue.Enqueue(skyColor); client.SendQueue.Enqueue(cloudColor); client.SendQueue.Enqueue(fogColor); client.SendQueue.Enqueue(ambeintColor); client.SendQueue.Enqueue(sunlightColor); } } }
public bool CanBeSeen(NetworkClient client) { return client.HasAllPermissions(ShowPermissions); }
public void ClientChangeBlock(NetworkClient client, short x, short y, short z, byte mode, Block newBlock) { if (!HCSettings.Building) { Chat.SendClientChat(client, "Building is disabled on this map at this time."); SendBlock(client, x, y, z, GetBlock(x, y, z)); return; } if (!BlockInBounds(x, y, z)) return; var mapBlock = GetBlock(x, y, z); if (mode == 0) newBlock = ServerCore.Blockholder.GetBlock(0); if (newBlock == mapBlock && newBlock != ServerCore.Blockholder.GetBlock(0)) return; if (!client.HasAllPermissions(Buildperms.Values.ToList())) { Chat.SendClientChat(client, "§EYou are not allowed to build here."); SendBlock(client, x, y, z, mapBlock); return; } if (!client.HasAllPermissions(mapBlock.DeletePermissions.Values.ToList()) && mode == 0) { Chat.SendClientChat(client, "§EYou are not allowed to delete this block type."); SendBlock(client, x, y, z, mapBlock); return; } if (!client.HasAllPermissions(newBlock.PlacePermissions.Values.ToList()) && mode > 0) { Chat.SendClientChat(client, "§EYou are not allowed to place this block type."); SendBlock(client, x, y, z, mapBlock); return; } ServerCore.Luahandler.RunFunction("E_BlockChange", client, x, y, z, newBlock); BlockChange(client.CS.Id, x, y, z, newBlock, mapBlock, true, true, true, 250); }
public bool CanBeCalled(NetworkClient client) { return client.HasAllPermissions(UsePermissions); }