mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 03:55:18 -04:00
Unload old map (without saving) when a /restore is done.
This commit is contained in:
parent
6e05af1be6
commit
d90fac8f7f
@ -47,18 +47,7 @@ namespace MCGalaxy.Commands.World {
|
||||
if (LevelInfo.ExistsOffline(name)) {
|
||||
Player.Message(p, "Level \"" + name + "\" already exists!"); return;
|
||||
}
|
||||
|
||||
if (p != null) {
|
||||
int limit = p.Rank < LevelPermission.Admin ?
|
||||
Server.MapGenLimit : Server.MapGenLimitAdmin;
|
||||
if ((long)x * y * z > limit ) {
|
||||
string text = "You cannot create a map with over ";
|
||||
if (limit > 1000 * 1000) text += (limit / (1000 * 1000)) + " million blocks";
|
||||
else if (limit > 1000) text += (limit / 1000) + " thousand blocks";
|
||||
else text += limit + " blocks";
|
||||
Player.Message(p, text); return;
|
||||
}
|
||||
}
|
||||
if (!CheckMapSize(p, x, y, z)) return;
|
||||
|
||||
try {
|
||||
using (Level lvl = new Level(name, x, y, z, args[4], seed)) {
|
||||
@ -72,10 +61,20 @@ namespace MCGalaxy.Commands.World {
|
||||
}
|
||||
|
||||
string format = seed != "" ? "Level \"{0}\" created with seed \"{1}\"" : "Level \"{0}\" created";
|
||||
if (seed != "")
|
||||
Player.GlobalMessage(String.Format(format, name, seed));
|
||||
else
|
||||
Player.GlobalMessage(String.Format(format, name));
|
||||
Player.GlobalMessage(String.Format(format, name, seed));
|
||||
}
|
||||
|
||||
internal static bool CheckMapSize(Player p, int x, int y, int z) {
|
||||
if (p == null) return true;
|
||||
int limit = p.Rank < LevelPermission.Admin ? Server.MapGenLimit : Server.MapGenLimitAdmin;
|
||||
if ((long)x * y * z <= limit ) return true;
|
||||
|
||||
string text = "You cannot create a map with over ";
|
||||
if (limit > 1000 * 1000) text += (limit / (1000 * 1000)) + " million blocks";
|
||||
else if (limit > 1000) text += (limit / 1000) + " thousand blocks";
|
||||
else text += limit + " blocks";
|
||||
Player.Message(p, text);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -73,6 +73,7 @@ namespace MCGalaxy.Commands {
|
||||
pl.level = restore;
|
||||
CmdReload.ReloadMap(null, pl, false);
|
||||
}
|
||||
lvl.Unload(true, false);
|
||||
} else {
|
||||
Server.s.Log("Restore nulled");
|
||||
File.Copy(LevelInfo.LevelPath(lvl.name) + ".backup", LevelInfo.LevelPath(lvl.name), true);
|
||||
|
@ -38,7 +38,7 @@ namespace MCGalaxy.Commands.World {
|
||||
for (int i = 0; i < loaded.Length; i++) {
|
||||
Level lvl = loaded[i];
|
||||
if (lvl.HasPlayers()) continue;
|
||||
lvl.Unload(true, true);
|
||||
lvl.Unload(true);
|
||||
}
|
||||
} else {
|
||||
Level level = LevelInfo.Find(name);
|
||||
|
@ -19,7 +19,6 @@ using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MCGalaxy.Levels.IO {
|
||||
|
||||
public static class LvlProperties {
|
||||
|
||||
public static void Save(Level level, string path) {
|
||||
|
@ -398,8 +398,8 @@ namespace MCGalaxy
|
||||
}
|
||||
MovePlayersToMain();
|
||||
|
||||
if (changed && ShouldSaveChanges()) Save(false, true);
|
||||
if (ShouldSaveChanges()) saveChanges();
|
||||
if (save && changed && ShouldSaveChanges()) Save(false, true);
|
||||
if (save && ShouldSaveChanges()) saveChanges();
|
||||
|
||||
if (TntWarsGame.Find(this) != null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user