mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -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)) {
|
if (LevelInfo.ExistsOffline(name)) {
|
||||||
Player.Message(p, "Level \"" + name + "\" already exists!"); return;
|
Player.Message(p, "Level \"" + name + "\" already exists!"); return;
|
||||||
}
|
}
|
||||||
|
if (!CheckMapSize(p, x, y, z)) 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
using (Level lvl = new Level(name, x, y, z, args[4], seed)) {
|
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";
|
string format = seed != "" ? "Level \"{0}\" created with seed \"{1}\"" : "Level \"{0}\" created";
|
||||||
if (seed != "")
|
Player.GlobalMessage(String.Format(format, name, seed));
|
||||||
Player.GlobalMessage(String.Format(format, name, seed));
|
}
|
||||||
else
|
|
||||||
Player.GlobalMessage(String.Format(format, name));
|
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) {
|
public override void Help(Player p) {
|
||||||
|
@ -73,6 +73,7 @@ namespace MCGalaxy.Commands {
|
|||||||
pl.level = restore;
|
pl.level = restore;
|
||||||
CmdReload.ReloadMap(null, pl, false);
|
CmdReload.ReloadMap(null, pl, false);
|
||||||
}
|
}
|
||||||
|
lvl.Unload(true, false);
|
||||||
} else {
|
} else {
|
||||||
Server.s.Log("Restore nulled");
|
Server.s.Log("Restore nulled");
|
||||||
File.Copy(LevelInfo.LevelPath(lvl.name) + ".backup", LevelInfo.LevelPath(lvl.name), true);
|
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++) {
|
for (int i = 0; i < loaded.Length; i++) {
|
||||||
Level lvl = loaded[i];
|
Level lvl = loaded[i];
|
||||||
if (lvl.HasPlayers()) continue;
|
if (lvl.HasPlayers()) continue;
|
||||||
lvl.Unload(true, true);
|
lvl.Unload(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Level level = LevelInfo.Find(name);
|
Level level = LevelInfo.Find(name);
|
||||||
|
@ -19,7 +19,6 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace MCGalaxy.Levels.IO {
|
namespace MCGalaxy.Levels.IO {
|
||||||
|
|
||||||
public static class LvlProperties {
|
public static class LvlProperties {
|
||||||
|
|
||||||
public static void Save(Level level, string path) {
|
public static void Save(Level level, string path) {
|
||||||
|
@ -398,8 +398,8 @@ namespace MCGalaxy
|
|||||||
}
|
}
|
||||||
MovePlayersToMain();
|
MovePlayersToMain();
|
||||||
|
|
||||||
if (changed && ShouldSaveChanges()) Save(false, true);
|
if (save && changed && ShouldSaveChanges()) Save(false, true);
|
||||||
if (ShouldSaveChanges()) saveChanges();
|
if (save && ShouldSaveChanges()) saveChanges();
|
||||||
|
|
||||||
if (TntWarsGame.Find(this) != null)
|
if (TntWarsGame.Find(this) != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user