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