void Delete(Client player, string[] cmd, int iarg) { if (player.Admin() == false) { throw new ErrorException("Disabled"); } WorldRegion region = player.Session.CurrentRegion; if (region == null) { throw new ErrorException("No region here"); } if (cmd.Length <= iarg) { throw new ShowHelpException(); //Need more arguments } RegionList regions = player.Session.World.Regions; string subdel = cmd [iarg].ToLowerInvariant(); switch (subdel) { case "single": DeleteSingle(region, regions); player.TellSystem(Chat.Purple, region.Name + " removed"); player.Session.CurrentRegion = null; break; case "recursive": DeleteRecursive(region); player.TellSystem(Chat.Purple, region.Name + " and subregions removed"); region.Deleted = true; player.Session.CurrentRegion = null; break; case "subonly": DeleteSubregions(region); player.TellSystem(Chat.Purple, "Subregions of " + region.Name + " removed"); break; default: throw new ShowHelpException(); } RegionLoader.Save(regions); //Update all players regions foreach (var p in PlayerList.List) { RegionCrossing.SetRegion(p.Session); } ScoreboardRegionManager.UpdateAllPlayersRegion(); }
void AddResident(Client player, string[] cmd, int iarg) { WorldRegion region = player.Session.CurrentRegion; if (region == null) { throw new ErrorException("No region here"); } if (cmd.Length != 3) { throw new ErrorException("Too few arguments"); } region.AddPlayer(player, cmd [2]); ScoreboardRegionManager.UpdateAllPlayersRegion(); return; }
void Rename(Client player, string[] cmd, int iarg) { WorldRegion region = player.Session.CurrentRegion; if (region == null) { throw new ErrorException("No region here"); } if (cmd.Length < 3) { throw new ErrorException("Too few arguments"); } region.Rename(player, cmd.JoinFrom(2)); ScoreboardRegionManager.UpdateAllPlayersRegion(); }
void Type(Client player, string[] cmd, int iarg) { WorldRegion region = player.Session.CurrentRegion; if (region == null) { throw new ErrorException("No region here"); } if (cmd.Length == 2) { player.TellSystem(Chat.Purple, "Region is of type " + region.Type); return; } region.SetType(player, cmd.JoinFrom(2)); ScoreboardRegionManager.UpdateAllPlayersRegion(); return; }
void Resize(Client player, string[] cmd, int iarg) { WorldRegion region = player.Session.CurrentRegion; if (region == null) { throw new ErrorException("No region here"); } player.TellSystem(Chat.Gray, "Resizing: " + region); if (cmd.Length != 8) { throw new ShowHelpException(); } region.Resize(int.Parse(cmd [2]), int.Parse(cmd [3]), int.Parse(cmd [4]), int.Parse(cmd [5]), int.Parse(cmd [6]), int.Parse(cmd [7]), player); ScoreboardRegionManager.UpdateAllPlayersRegion(); }
void ShowSidebar(Client player, string[] cmd, int iarg) { if (cmd.Length <= iarg) { throw new ShowHelpException(); } string setting = cmd [iarg].ToLowerInvariant(); if (setting == "off") { player.Settings.ShowRegionScoreboard = false; player.Score = null; player.TellSystem(Chat.Purple, "Region reporting off"); return; } if (setting == "on") { player.Settings.ShowRegionScoreboard = true; ScoreboardRegionManager.UpdateRegion(player); player.TellSystem(Chat.Purple, "Region reporting on"); return; } }
/// <summary> /// Find region and send message /// </summary> internal static void SetRegion(WorldSession session) { RegionList regions = session.World.Regions; if (regions == null) { return; } try { //This is called every single player movement, 20 times a second, some optimization might be needed. WorldRegion w = null; //First test if we are in the same as before WorldRegion current = session.CurrentRegion; if (current != null) { if (current.Deleted == false && current.Contains(session.Position)) { w = GetRegion(current.SubRegions, session.Position, session.Dimension); if (w == null) { w = current; } } } if (w == null) { w = GetRegion(regions.List, session.Position, session.Dimension); } //Debug.Write("Setregion: " + w); //If different if (session.CurrentRegion != w) { //Leaving if (session.CurrentRegion != null && (session.CurrentRegion.HasChild(w) == false)) { session.CurrentRegion.Leaving(session.Player, w); } //Entering if (w != null && w.HasChild(session.CurrentRegion) == false) { w.Entering(session.Player); } //Stats SetStats(session.CurrentRegion, session.Player); SetStats(w, session.Player); } //Adjust Survival/Adventure mode if (session.Mode != GameMode.Creative && session.Mode != GameMode.Spectator) { bool protect = Protected.IsBlockProtected(session, w); if (protect && w.IsResident(session.Player)) { protect = false; } if (protect) { session.SetMode(GameMode.Adventure); } else { session.SetMode(GameMode.Survival); } } if (w != null && w.Type == WarpZone.Type) { if (session.Mode != GameMode.Creative) { WarpZone wz = new WarpZone(w.Name); session.Player.Warp(wz.Destination, (Dimensions)wz.DestinationDimension, wz.DesinationWorld); } } bool update = (w != session.CurrentRegion); session.CurrentRegion = w; if (update) { ScoreboardRegionManager.UpdateRegion(session.Player); } #if !DEBUG } catch (Exception e) { Log.WriteServer(e); return; #endif } finally { } }