static void AddMap(Player p, string value) { if (p.group.OverseerMaps == 0) { p.Message("Your rank is not allowed to create any /os maps."); return; } string level = NextLevel(p); if (level == null) { return; } if (value.Length == 0) { value = "128 128 128 flat"; } else if (value.IndexOf(' ') == -1) { value = "128 128 128 " + value; } string[] args = value.TrimEnd().SplitSpaces(); if (args.Length == 3) { value += " flat"; } CmdNewLvl newLvl = (CmdNewLvl)Command.Find("NewLvl"); // TODO: this is a nasty hack, find a better way args = (level + " " + value).SplitSpaces(); Level lvl = newLvl.GenerateMap(p, args, p.DefaultCmdData); if (lvl == null) { return; } if (SetPerms(p, lvl)) { Group grp = Group.Find(ServerConfig.OSPerbuildDefault); p.Message("Use %T/os zone add [name] %Sto allow " + "players ranked below " + grp.ColoredName + " %Sto build in the map."); } try { lvl.Save(true); } finally { lvl.Dispose(); Server.DoGC(); } }
public override void Use(Player p, string message) { string[] args = message.Split(' '); if (args.Length < 4) { Help(p); return; } Level lvl = LevelInfo.FindMatches(p, args[0]); if (lvl == null) { return; } 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; } 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; } 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; } Level newLvl = ResizeLevel(lvl, x, y, z); LevelActions.Replace(lvl, newLvl); }
public static bool DoResize(Player p, string[] args) { Level lvl = Matcher.FindLevels(p, args[0]); if (lvl == null) { return(true); } if (!LevelInfo.ValidateAction(p, lvl.name, "resize this level")) { return(false); } ushort x = 0, y = 0, z = 0; if (!CmdNewLvl.CheckMapAxis(p, args[1], "Width", ref x)) { return(false); } if (!CmdNewLvl.CheckMapAxis(p, args[2], "Height", ref y)) { return(false); } if (!CmdNewLvl.CheckMapAxis(p, args[3], "Length", ref z)) { return(false); } if (!CmdNewLvl.CheckMapVolume(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."); return(false); } Level newLvl = ResizeLevel(lvl, x, y, z); LevelActions.Replace(lvl, newLvl); return(true); }
static void AddMap(Player p, string value) { if (p.group.OverseerMaps == 0) { p.Message("Your rank is not allowed to create any /os maps."); return; } string level = NextLevel(p); if (level == null) { return; } if (value.Length == 0) { value = "128 128 128"; } else if (value.IndexOf(' ') == -1) { value = "128 128 128 " + value; } string[] args = (level + " " + value.TrimEnd()).SplitSpaces(); CmdNewLvl newLvl = (CmdNewLvl)Command.Find("NewLvl"); // TODO: this is a nasty hack, find a better way Level lvl = newLvl.GenerateMap(p, args, p.DefaultCmdData); if (lvl == null) { return; } MapGen.SetRealmPerms(p, lvl); p.Message("Use &T/os zone add [name] &Sto allow other players to build in the map."); try { lvl.Save(true); } finally { lvl.Dispose(); Server.DoGC(); } }
public static bool DoResize(Player p, string[] args, CommandData data, out bool needConfirm) { needConfirm = false; Level lvl = Matcher.FindLevels(p, args[0]); if (lvl == null) { return(true); } if (!LevelInfo.Check(p, data.Rank, lvl, "resize this level")) { return(false); } ushort x = 0, y = 0, z = 0; if (!CmdNewLvl.GetDimensions(p, args, 1, ref x, ref y, ref z)) { return(false); } bool confirmed = args.Length > 4 && args[4].CaselessEq("confirm"); if (!confirmed && (x < lvl.Width || y < lvl.Height || z < lvl.Length)) { p.Message("New level dimensions are smaller than the current dimensions, %Wyou will lose blocks%S."); needConfirm = true; return(false); } Level resized = ResizeLevel(lvl, x, y, z); if (resized == null) { p.Message("%WError resizing map."); return(false); } LevelActions.Replace(lvl, resized); return(true); }