From 6a03bffebeed4cdfa43004e42a6294a6db0ad624 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 13 Apr 2020 00:30:43 +1000 Subject: [PATCH] Don't check volume for /buy level --- .../Commands/World/CmdOverseer.SubCommands.cs | 15 ++----------- MCGalaxy/Economy/LevelItem.cs | 6 ++---- MCGalaxy/Generator/MapGen.cs | 21 +++++++++++++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs b/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs index 0d4188672..6f6873af6 100644 --- a/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs +++ b/MCGalaxy/Commands/World/CmdOverseer.SubCommands.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.IO; using MCGalaxy.Commands.CPE; using MCGalaxy.Commands.Moderation; +using MCGalaxy.Generator; namespace MCGalaxy.Commands.World { public sealed partial class CmdOverseer : Command2 { @@ -159,7 +160,7 @@ namespace MCGalaxy.Commands.World { Level lvl = newLvl.GenerateMap(p, args, p.DefaultCmdData); if (lvl == null) return; - SetPerms(p, lvl); + MapGen.SetRealmPerms(p, lvl); p.Message("Use %T/os zone add [name] %Sto allow other players to build in the map."); try { @@ -170,18 +171,6 @@ namespace MCGalaxy.Commands.World { } } - internal static void SetPerms(Player p, Level lvl) { - lvl.Config.RealmOwner = p.name; - const LevelPermission rank = LevelPermission.Nobody; - lvl.BuildAccess.Whitelist(Player.Console, rank, lvl, p.name); - lvl.VisitAccess.Whitelist(Player.Console, rank, lvl, p.name); - - Group grp = Group.Find(Server.Config.OSPerbuildDefault); - if (grp == null) return; - - lvl.BuildAccess.SetMin(Player.Console, rank, lvl, grp); - } - static void DeleteMap(Player p, string value) { if (value.Length > 0) { p.Message("To delete your current map, type %T/os map delete"); diff --git a/MCGalaxy/Economy/LevelItem.cs b/MCGalaxy/Economy/LevelItem.cs index c7d24ba8d..b5816196b 100644 --- a/MCGalaxy/Economy/LevelItem.cs +++ b/MCGalaxy/Economy/LevelItem.cs @@ -96,15 +96,13 @@ namespace MCGalaxy.Eco { ushort x = 0, y = 0, z = 0; string[] xyz = { preset.x, preset.y, preset.z }; - if (!MapGen.GetDimensions(p, xyz, 0, ref x, ref y, ref z)) return; + if (!MapGen.GetDimensions(p, xyz, 0, ref x, ref y, ref z, false)) return; MapGen gen = MapGen.Find(preset.type); Level lvl = MapGen.Generate(p, gen, name, x, y, z, ""); if (lvl == null) return; - CmdOverseer.SetPerms(p, lvl); - lvl.SaveSettings(); - + MapGen.SetRealmPerms(p, lvl); try { lvl.Save(true); } finally { diff --git a/MCGalaxy/Generator/MapGen.cs b/MCGalaxy/Generator/MapGen.cs index eef9c81e7..722f7a57e 100644 --- a/MCGalaxy/Generator/MapGen.cs +++ b/MCGalaxy/Generator/MapGen.cs @@ -118,21 +118,21 @@ namespace MCGalaxy.Generator { } return lvl; } - + public static bool GetDimensions(Player p, string[] args, int i, - ref ushort x, ref ushort y, ref ushort z) { + ref ushort x, ref ushort y, ref ushort z, bool checkVolume = true) { return CheckMapAxis(p, args[i ], "Width", ref x) && CheckMapAxis(p, args[i + 1], "Height", ref y) && CheckMapAxis(p, args[i + 2], "Length", ref z) && - CheckMapVolume(p, x, y, z); + (!checkVolume || CheckMapVolume(p, x, y, z)); } static bool CheckMapAxis(Player p, string input, string type, ref ushort len) { return CommandParser.GetUShort(p, input, type, ref len, 1, 16384); } - static bool CheckMapVolume(Player p, int x, int y, int z) { + static bool CheckMapVolume(Player p, int x, int y, int z) { if (p.IsConsole) return true; int limit = p.group.GenVolume; if ((long)x * y * z <= limit) return true; @@ -143,6 +143,19 @@ namespace MCGalaxy.Generator { else text += limit + " blocks"; p.Message(text); return false; + } + + /// Sets default permissions for a newly generated realm map. + internal static void SetRealmPerms(Player p, Level lvl) { + lvl.Config.RealmOwner = p.name; + const LevelPermission rank = LevelPermission.Nobody; + lvl.BuildAccess.Whitelist(Player.Console, rank, lvl, p.name); + lvl.VisitAccess.Whitelist(Player.Console, rank, lvl, p.name); + + Group grp = Group.Find(Server.Config.OSPerbuildDefault); + if (grp == null) return; + + lvl.BuildAccess.SetMin(Player.Console, rank, lvl, grp); } } }