public static void LoadMetadata(Level lvl) { try { string propsPath = LevelInfo.PropsPath(lvl.MapName); if (lvl.Config.Load(propsPath)) { lvl.SetPhysics(lvl.Config.Physics); } else { Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName); } } catch (Exception e) { Logger.LogError(e); } lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB; string blockDefsPath = Paths.MapBlockDefs(lvl.MapName); BlockDefinition[] defs = BlockDefinition.Load(blockDefsPath); for (int b = 0; b < defs.Length; b++) { if (defs[b] == null) { continue; } lvl.UpdateCustomBlock((BlockID)b, defs[b]); } lvl.UpdateBlockProps(); lvl.UpdateAllBlockHandlers(); }
public static void Remove(BlockDefinition def, BlockDefinition[] defs, Level level) { BlockID block = def.GetBlock(); bool global = defs == GlobalDefs; if (global) { UpdateGlobalCustom(block, null); } defs[block] = null; if (global) { Block.SetDefaultNames(); } if (!global) { level.UpdateCustomBlock(block, null); } Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!global && pl.level != level) { continue; } if (global && pl.level.CustomBlockDefs[block] != null) { continue; } pl.Session.SendUndefineBlock(def); } }
public static void Add(BlockDefinition def, BlockDefinition[] defs, Level level) { byte raw = def.BlockID; bool global = defs == GlobalDefs; if (global) { UpdateGlobalCustom(raw, def); } defs[raw] = def; if (global) { Block.SetDefaultNames(); } if (!global) { level.UpdateCustomBlock(raw, def); } Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!global && pl.level != level) { continue; } if (!pl.hasBlockDefs) { continue; } if (global && pl.level.CustomBlockDefs[raw] != GlobalDefs[raw]) { continue; } pl.Send(def.MakeDefinePacket(pl)); if (pl.Supports(CpeExt.BlockPermissions)) { pl.Send(Packet.BlockPermission(def.BlockID, pl.level.CanPlace, pl.level.CanDelete)); } } Save(global, level); }
public static void LoadMetadata(Level lvl) { lvl.Config.JailX = (ushort)(lvl.spawnx * 32); lvl.Config.JailY = (ushort)(lvl.spawny * 32); lvl.Config.JailZ = (ushort)(lvl.spawnz * 32); lvl.Config.jailrotx = lvl.rotx; lvl.Config.jailroty = lvl.roty; try { string propsPath = LevelInfo.PropsPath(lvl.MapName); bool propsExisted = lvl.Config.Load(propsPath); if (propsExisted) { lvl.SetPhysics(lvl.Config.Physics); } else { Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName); } // Backwards compatibility for older levels which had .env files. string envPath = "levels/level properties/" + lvl.MapName + ".env"; lvl.Config.Load(envPath); } catch (Exception e) { Logger.LogError(e); } lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB; BlockDefinition[] defs = BlockDefinition.Load(false, lvl.MapName); for (int b = 0; b < defs.Length; b++) { if (defs[b] == null) { continue; } lvl.UpdateCustomBlock((BlockID)b, defs[b]); } lvl.UpdateBlockProps(); lvl.UpdateBlockHandlers(); }
public static void Add(BlockDefinition def, BlockDefinition[] defs, Level level) { BlockID block = def.GetBlock(); bool global = defs == GlobalDefs; if (global) { UpdateGlobalCustom(block, def); } defs[block] = def; if (global) { Block.SetDefaultNames(); } if (!global) { level.UpdateCustomBlock(block, def); } Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!global && pl.level != level) { continue; } if (!pl.hasBlockDefs || def.RawID > pl.MaxRawBlock) { continue; } if (global && pl.level.CustomBlockDefs[block] != GlobalDefs[block]) { continue; } pl.Send(def.MakeDefinePacket(pl)); pl.SendCurrentBlockPermissions(); } Save(global, level); }
public static void Remove(BlockDefinition def, BlockDefinition[] defs, Level level) { BlockID block = def.GetBlock(); bool global = defs == GlobalDefs; if (global) { UpdateGlobalCustom(block, null); } defs[block] = null; if (global) { Block.SetDefaultNames(); } if (!global) { level.UpdateCustomBlock(block, null); } Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!global && pl.level != level) { continue; } if (!pl.hasBlockDefs || def.RawID > pl.MaxRawBlock) { continue; } if (global && pl.level.CustomBlockDefs[block] != null) { continue; } pl.Send(Packet.UndefineBlock(def, pl.hasExtBlocks)); } Save(global, level); }
public static void Remove(BlockDefinition def, BlockDefinition[] defs, Level level) { byte raw = def.BlockID; bool global = defs == GlobalDefs; if (global) { UpdateGlobalCustom(raw, null); } defs[raw] = null; if (global) { Block.SetDefaultNames(); } if (!global) { level.UpdateCustomBlock(raw, null); } Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (!global && pl.level != level) { continue; } if (global && pl.level.CustomBlockDefs[raw] != null) { continue; } if (pl.hasBlockDefs) { pl.Send(Packet.UndefineBlock(raw)); } } Save(global, level); }
public static void LoadMetadata(Level lvl) { try { string propsPath = LevelInfo.PropertiesPath(lvl.MapName); bool propsExisted = LevelConfig.Load(propsPath, lvl.Config); if (propsExisted) { lvl.setPhysics(lvl.Config.Physics); } else { Logger.Log(LogType.ConsoleMessage, ".properties file for level {0} was not found.", lvl.MapName); } // Backwards compatibility for older levels which had .env files. string envPath = "levels/level properties/" + lvl.MapName + ".env"; LevelConfig.Load(envPath, lvl.Config); } catch (Exception e) { Logger.LogError(e); } lvl.BlockDB.Cache.Enabled = lvl.Config.UseBlockDB; BlockDefinition[] defs = BlockDefinition.Load(false, lvl); for (int i = 0; i < defs.Length; i++) { if (defs[i] == null) { continue; } lvl.UpdateCustomBlock((byte)i, defs[i]); } lvl.UpdateBlockProps(); lvl.UpdateBlockHandlers(); }