mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Add /os map resize
This commit is contained in:
parent
80c3628ee2
commit
c527478310
@ -73,7 +73,7 @@ namespace MCGalaxy.Commands {
|
||||
string lbArgs = (arg1 + " " + arg2).Trim();
|
||||
CustomBlockCommand.Execute(p, lbArgs, false, "/os lb");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void HandleMap(Player p, string opt, string value) {
|
||||
bool mapOnly = !(opt == "ADD" || opt == "DELETE" || opt == "SAVE");
|
||||
@ -106,6 +106,14 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
} else if (opt == "RESTORE") {
|
||||
Command.all.Find("restore").Use(p, value);
|
||||
} else if (opt == "RESIZE") {
|
||||
value = p.level.name + " " + value;
|
||||
string[] args = value.Split(' ');
|
||||
if (args.Length < 4) { Command.all.Find("resizelvl").Help(p); return; }
|
||||
|
||||
if (CmdResizeLvl.DoResize(p, args)) return;
|
||||
Player.Message(p, "Type %T/os map resize {0} {1} {2} confirm %Sif you're sure.",
|
||||
args[1], args[2], args[3]);
|
||||
} else if (opt == "PERVISIT") {
|
||||
string rank = value == "" ? Server.defaultRank : value;
|
||||
Command.all.Find("pervisit").Use(p, rank);
|
||||
@ -206,7 +214,7 @@ namespace MCGalaxy.Commands {
|
||||
static void HandleSpawn(Player p, string ignored1, string ignored2) {
|
||||
Command.all.Find("setspawn").Use(p, "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void HandleZone(Player p, string cmd, string name) {
|
||||
if (cmd == "LIST") {
|
||||
|
@ -171,6 +171,7 @@ namespace MCGalaxy.Commands {
|
||||
"%T/os map physics [level] %H- Sets the physics on your map.",
|
||||
"%T/os map delete [num] %H- Deletes your nth map",
|
||||
"%T/os map restore [num] %H- Restores backup [num] of your map",
|
||||
"%T/os map resize [width] [length] [height] %H- Resizes your map",
|
||||
"%T/os map save %H- Saves your map",
|
||||
"%T/os map pervisit [rank] %H- Sets the pervisit of you map",
|
||||
"%T/os map perbuild [rank] %H- Sets the perbuild of you map",
|
||||
|
@ -31,28 +31,35 @@ namespace MCGalaxy.Commands.World {
|
||||
public override void Use(Player p, string message) {
|
||||
string[] args = message.Split(' ');
|
||||
if (args.Length < 4) { Help(p); return; }
|
||||
|
||||
if (DoResize(p, args)) return;
|
||||
Player.Message(p, "Type %T/resizelvl {0} {1} {2} {3} confirm %Sif you're sure.",
|
||||
args[0], args[1], args[2], args[3]);
|
||||
}
|
||||
|
||||
public static bool DoResize(Player p, string[] args) {
|
||||
Level lvl = LevelInfo.FindMatches(p, args[0]);
|
||||
if (lvl == null) return;
|
||||
if (lvl == null) return true;
|
||||
|
||||
ushort x, y, z;
|
||||
if (!UInt16.TryParse(args[1], out x) || !UInt16.TryParse(args[2], out y) || !UInt16.TryParse(args[3], out z)) {
|
||||
Player.Message(p, "Invalid dimensions."); return;
|
||||
Player.Message(p, "Invalid dimensions."); return true;
|
||||
}
|
||||
|
||||
if (!MapGen.OkayAxis(x)) { Player.Message(p, "width must be divisible by 16, and >= 16"); return; }
|
||||
if (!MapGen.OkayAxis(y)) { Player.Message(p, "height must be divisible by 16, and >= 16"); return; }
|
||||
if (!MapGen.OkayAxis(z)) { Player.Message(p, "length must be divisible by 16, and >= 16."); return; }
|
||||
if (!CmdNewLvl.CheckMapSize(p, x, y, z)) return;
|
||||
if (!MapGen.OkayAxis(x)) { Player.Message(p, "width must be divisible by 16, and >= 16"); return true; }
|
||||
if (!MapGen.OkayAxis(y)) { Player.Message(p, "height must be divisible by 16, and >= 16"); return true; }
|
||||
if (!MapGen.OkayAxis(z)) { Player.Message(p, "length must be divisible by 16, and >= 16."); return true; }
|
||||
if (!CmdNewLvl.CheckMapSize(p, x, y, z)) return true;
|
||||
|
||||
bool confirmed = args.Length > 4 && args[4].CaselessEq("confirm");
|
||||
if (!confirmed && (x < lvl.Width || y < lvl.Height || z < lvl.Length)) {
|
||||
Player.Message(p, "New level dimensions are smaller than the current dimensions, &cyou will lose blocks%S.");
|
||||
Player.Message(p, "Type %T/resizelvl {0} {1} {2} {3} confirm %Sif you're sure.", args[0], x, y, z);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Level newLvl = ResizeLevel(lvl, x, y, z);
|
||||
LevelActions.Replace(lvl, newLvl);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Level ResizeLevel(Level lvl, ushort width, ushort height, ushort length) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user