mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Fix /museum not loading custom blocks and env
This commit is contained in:
parent
fb652663c6
commit
bd09b32b52
@ -70,7 +70,7 @@ namespace MCGalaxy {
|
||||
|
||||
internal static BlockDefinition[] Load(bool global, Level lvl) {
|
||||
BlockDefinition[] defs = new BlockDefinition[256];
|
||||
string path = global ? GlobalPath : "blockdefs/lvl_" + lvl.name + ".json";
|
||||
string path = global ? GlobalPath : "blockdefs/lvl_" + lvl.MapName + ".json";
|
||||
try {
|
||||
if (File.Exists(path)) {
|
||||
string json = File.ReadAllText(path);
|
||||
@ -109,7 +109,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
string json = JsonConvert.SerializeObject(defs, Formatting.Indented);
|
||||
string path = global ? GlobalPath : "blockdefs/lvl_" + lvl.name + ".json";
|
||||
string path = global ? GlobalPath : "blockdefs/lvl_" + lvl.MapName + ".json";
|
||||
File.WriteAllText(path, json);
|
||||
}
|
||||
|
||||
|
@ -37,8 +37,8 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.Message(p, "%T/trust <name>");
|
||||
Player.Message(p, "%HTurns off the anti-grief for <name>");
|
||||
Player.Message(p, "%T/trust [name]");
|
||||
Player.Message(p, "%HTurns off the anti-grief for [name]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,15 +53,17 @@ namespace MCGalaxy.Commands.World {
|
||||
}
|
||||
|
||||
try {
|
||||
JoinMuseum(p, name, path);
|
||||
JoinMuseum(p, name, args[0].ToLower(), path);
|
||||
} finally {
|
||||
Interlocked.Exchange(ref p.LoadingMuseum, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void JoinMuseum(Player p, string name, string path) {
|
||||
static void JoinMuseum(Player p, string name, string mapName, string path) {
|
||||
Level lvl = IMapImporter.Formats[0].Read(path, name, false);
|
||||
lvl.MapName = mapName;
|
||||
SetLevelProps(lvl);
|
||||
Level.LoadMetadata(lvl);
|
||||
|
||||
p.Loading = true;
|
||||
Entities.DespawnEntities(p);
|
||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Levels.IO {
|
||||
}
|
||||
|
||||
public static void LoadEnv(Level level) {
|
||||
string path = "levels/level properties/" + level.name + ".env";
|
||||
string path = "levels/level properties/" + level.MapName.ToLower() + ".env";
|
||||
PropertiesFile.Read(path, ref level, EnvLineProcessor);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ using MCGalaxy.Util;
|
||||
namespace MCGalaxy {
|
||||
public sealed partial class Level : IDisposable {
|
||||
|
||||
public string name;
|
||||
public string name, MapName;
|
||||
[ConfigString("MOTD", "General", null, "ignore", true, null, 128)]
|
||||
public string motd = "ignore";
|
||||
|
||||
|
@ -56,9 +56,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void Init(string n, ushort x, ushort y, ushort z) {
|
||||
Width = x;
|
||||
Height = y;
|
||||
Length = z;
|
||||
Width = x; Height = y; Length = z;
|
||||
if (Width < 16) Width = 16;
|
||||
if (Height < 16) Height = 16;
|
||||
if (Length < 16) Length = 16;
|
||||
@ -76,7 +74,7 @@ namespace MCGalaxy {
|
||||
for (int i = 0; i < CustomBlockProps.Length; i++)
|
||||
CustomBlockProps[i] = BlockDefinition.GlobalProps[i];
|
||||
|
||||
name = n;
|
||||
name = n; MapName = n;
|
||||
BlockDB = new BlockDB(this);
|
||||
EdgeLevel = (short)(y / 2);
|
||||
CloudsHeight = (short)(y + 2);
|
||||
@ -350,57 +348,63 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
try {
|
||||
Level level = IMapImporter.Formats[0].Read(path, name, true);
|
||||
level.setPhysics(phys);
|
||||
level.backedup = true;
|
||||
Level lvl = IMapImporter.Formats[0].Read(path, name, true);
|
||||
lvl.setPhysics(phys);
|
||||
lvl.backedup = true;
|
||||
|
||||
level.jailx = (ushort)(level.spawnx * 32);
|
||||
level.jaily = (ushort)(level.spawny * 32);
|
||||
level.jailz = (ushort)(level.spawnz * 32);
|
||||
level.jailrotx = level.rotx;
|
||||
level.jailroty = level.roty;
|
||||
level.StartPhysics();
|
||||
lvl.jailx = (ushort)(lvl.spawnx * 32);
|
||||
lvl.jaily = (ushort)(lvl.spawny * 32);
|
||||
lvl.jailz = (ushort)(lvl.spawnz * 32);
|
||||
lvl.jailrotx = lvl.rotx;
|
||||
lvl.jailroty = lvl.roty;
|
||||
lvl.StartPhysics();
|
||||
|
||||
try {
|
||||
string propsPath = LevelInfo.FindPropertiesFile(level.name);
|
||||
if (propsPath != null)
|
||||
LvlProperties.Load(level, propsPath);
|
||||
else
|
||||
Server.s.Log(".properties file for level " + level.name + " was not found.");
|
||||
// Backwards compatibility for older levels which had .env files.
|
||||
LvlProperties.LoadEnv(level);
|
||||
} catch (Exception e) {
|
||||
Server.ErrorLog(e);
|
||||
}
|
||||
level.BlockDB.Cache.Enabled = level.UseBlockDB;
|
||||
|
||||
BlockDefinition[] defs = BlockDefinition.Load(false, level);
|
||||
for (int i = 0; i < defs.Length; i++) {
|
||||
if (defs[i] == null) continue;
|
||||
level.CustomBlockDefs[i] = defs[i];
|
||||
level.CustomBlockProps[i] = new BlockProps((byte)i);
|
||||
}
|
||||
BlockProps.Load("lvl_" + level.name, level.CustomBlockProps);
|
||||
Bots.BotsFile.LoadBots(level);
|
||||
LoadMetadata(lvl);
|
||||
Bots.BotsFile.LoadBots(lvl);
|
||||
|
||||
object locker = ThreadSafeCache.DBCache.Get(name);
|
||||
lock (locker) {
|
||||
LevelDB.LoadZones(level, name);
|
||||
LevelDB.LoadPortals(level, name);
|
||||
LevelDB.LoadMessages(level, name);
|
||||
LevelDB.LoadZones(lvl, name);
|
||||
LevelDB.LoadPortals(lvl, name);
|
||||
LevelDB.LoadMessages(lvl, name);
|
||||
}
|
||||
|
||||
Server.s.Log(string.Format("Level \"{0}\" loaded.", level.name));
|
||||
Server.s.Log(string.Format("Level \"{0}\" loaded.", lvl.name));
|
||||
if (LevelLoaded != null)
|
||||
LevelLoaded(level);
|
||||
OnLevelLoadedEvent.Call(level);
|
||||
return level;
|
||||
LevelLoaded(lvl);
|
||||
OnLevelLoadedEvent.Call(lvl);
|
||||
return lvl;
|
||||
} catch (Exception ex) {
|
||||
Server.ErrorLog(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadMetadata(Level lvl) {
|
||||
try {
|
||||
string propsPath = LevelInfo.FindPropertiesFile(lvl.MapName);
|
||||
if (propsPath != null) {
|
||||
LvlProperties.Load(lvl, propsPath);
|
||||
} else {
|
||||
Server.s.Log(".properties file for level " + lvl.MapName + " was not found.");
|
||||
}
|
||||
|
||||
// Backwards compatibility for older levels which had .env files.
|
||||
LvlProperties.LoadEnv(lvl);
|
||||
} catch (Exception e) {
|
||||
Server.ErrorLog(e);
|
||||
}
|
||||
lvl.BlockDB.Cache.Enabled = lvl.UseBlockDB;
|
||||
|
||||
BlockDefinition[] defs = BlockDefinition.Load(false, lvl);
|
||||
for (int i = 0; i < defs.Length; i++) {
|
||||
if (defs[i] == null) continue;
|
||||
lvl.CustomBlockDefs[i] = defs[i];
|
||||
lvl.CustomBlockProps[i] = new BlockProps((byte)i);
|
||||
}
|
||||
BlockProps.Load("lvl_" + lvl.MapName, lvl.CustomBlockProps);
|
||||
}
|
||||
|
||||
public static bool CheckLoadOnGoto(string givenName) {
|
||||
string value = LevelInfo.FindOfflineProperty(givenName, "loadongoto");
|
||||
if (value == null) return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user