public static TestDirectory ( [ pathLabel, [ path, bool checkForWriteAccess ) : bool | ||
pathLabel | [ | Name of the path that's being tested (e.g. "map path"). Used for logging. |
path | [ | Full or partial path. |
checkForWriteAccess | bool | If set, tries to write to the given directory. |
return | bool |
internal static void Init() { Paths.TestDirectory("BlockDB", Paths.BlockDBPath, true); Player.PlacedBlock += OnPlayerPlacedBlock; Scheduler.NewBackgroundTask(FlushAll).RunForever(FlushInterval, FlushInterval); IsEnabledGlobally = true; }
static void ApplyKeyChange(ConfigKey key) { switch (key) { case ConfigKey.AnnouncementColor: Color.Announcement = Color.Parse(key.GetString()); break; case ConfigKey.AntispamInterval: Player.AntispamInterval = key.GetInt(); break; case ConfigKey.AntispamMessageCount: Player.AntispamMessageCount = key.GetInt(); break; case ConfigKey.DefaultBuildRank: RankManager.DefaultBuildRank = Rank.Parse(key.GetString()); break; case ConfigKey.DefaultRank: RankManager.DefaultRank = Rank.Parse(key.GetString()); break; case ConfigKey.BandwidthUseMode: Player[] playerListCache = Server.Players; if (playerListCache != null) { foreach (Player p in playerListCache) { if (p.BandwidthUseMode == BandwidthUseMode.Default) { // resets the use tweaks p.BandwidthUseMode = BandwidthUseMode.Default; } } } break; case ConfigKey.BlockDBAutoEnableRank: RankManager.BlockDBAutoEnableRank = Rank.Parse(key.GetString()); if (BlockDB.IsEnabledGlobally) { World[] worldListCache = WorldManager.Worlds; foreach (World world in worldListCache) { if (world.BlockDB.AutoToggleIfNeeded()) { if (world.BlockDB.IsEnabled) { Logger.Log(LogType.SystemActivity, "BlockDB is now auto-enabled on world {0}", world.Name); } else { Logger.Log(LogType.SystemActivity, "BlockDB is now auto-disabled on world {0}", world.Name); } } } } break; case ConfigKey.BlockUpdateThrottling: Server.BlockUpdateThrottling = key.GetInt(); break; case ConfigKey.ConsoleName: if (Player.Console != null) { Player.Console.Info.Name = key.GetString(); } break; case ConfigKey.HelpColor: Color.Help = Color.Parse(key.GetString()); break; case ConfigKey.IRCDelay: IRC.SendDelay = key.GetInt(); break; case ConfigKey.IRCMessageColor: Color.IRC = Color.Parse(key.GetString()); break; case ConfigKey.LogMode: Logger.SplittingType = key.GetEnum <LogSplittingType>(); break; case ConfigKey.MapPath: if (!Paths.IgnoreMapPathConfigKey && GetString(ConfigKey.MapPath).Length > 0) { if (Paths.TestDirectory("MapPath", GetString(ConfigKey.MapPath), true)) { Paths.MapPath = Path.GetFullPath(GetString(ConfigKey.MapPath)); } } break; case ConfigKey.MaxUndo: BuildingCommands.MaxUndoCount = key.GetInt(); break; case ConfigKey.MeColor: Color.Me = Color.Parse(key.GetString()); break; case ConfigKey.NoPartialPositionUpdates: if (key.Enabled()) { Player.FullPositionUpdateInterval = 0; } else { Player.FullPositionUpdateInterval = Player.FullPositionUpdateIntervalDefault; } break; case ConfigKey.PatrolledRank: RankManager.PatrolledRank = Rank.Parse(key.GetString()); break; case ConfigKey.PrivateMessageColor: Color.PM = Color.Parse(key.GetString()); break; case ConfigKey.RelayAllBlockUpdates: Player.RelayAllUpdates = key.Enabled(); break; case ConfigKey.SayColor: Color.Say = Color.Parse(key.GetString()); break; case ConfigKey.SystemMessageColor: Color.Sys = Color.Parse(key.GetString()); break; case ConfigKey.TickInterval: Server.TicksPerSecond = 1000 / (float)key.GetInt(); break; case ConfigKey.UploadBandwidth: Server.MaxUploadSpeed = key.GetInt(); break; case ConfigKey.WarningColor: Color.Warning = Color.Parse(key.GetString()); break; } }
internal static void ApplyConfig() { Logger.SplittingType = (LogSplittingType)Enum.Parse(typeof(LogSplittingType), Settings[ConfigKey.LogMode], true); Logger.MarkLogStart(); Player.RelayAllUpdates = GetBool(ConfigKey.RelayAllBlockUpdates); if (GetBool(ConfigKey.NoPartialPositionUpdates)) { Session.FullPositionUpdateInterval = 0; } else { Session.FullPositionUpdateInterval = Session.FullPositionUpdateIntervalDefault; } // chat colors Color.Sys = Color.Parse(Settings[ConfigKey.SystemMessageColor]); Color.Say = Color.Parse(Settings[ConfigKey.SayColor]); Color.Help = Color.Parse(Settings[ConfigKey.HelpColor]); Color.Announcement = Color.Parse(Settings[ConfigKey.AnnouncementColor]); Color.PM = Color.Parse(Settings[ConfigKey.PrivateMessageColor]); Color.IRC = Color.Parse(Settings[ConfigKey.IRCMessageColor]); Color.Me = Color.Parse(Settings[ConfigKey.MeColor]); Color.Warning = Color.Parse(Settings[ConfigKey.WarningColor]); // default class if (!ConfigKey.DefaultRank.IsBlank()) { if (RankManager.ParseRank(Settings[ConfigKey.DefaultRank]) != null) { RankManager.DefaultRank = RankManager.ParseRank(Settings[ConfigKey.DefaultRank]); } else { RankManager.DefaultRank = RankManager.LowestRank; Logger.Log("Config.ApplyConfig: Could not parse DefaultRank; assuming that the lowest rank ({0}) is the default.", LogType.Warning, RankManager.DefaultRank.Name); } } else { RankManager.DefaultRank = RankManager.LowestRank; } // antispam Player.SpamChatCount = GetInt(ConfigKey.AntispamMessageCount); Player.SpamChatTimer = GetInt(ConfigKey.AntispamInterval); Player.AutoMuteDuration = TimeSpan.FromSeconds(GetInt(ConfigKey.AntispamMuteDuration)); // scheduler settings Server.MaxUploadSpeed = GetInt(ConfigKey.UploadBandwidth); Server.PacketsPerSecond = GetInt(ConfigKey.BlockUpdateThrottling); Server.TicksPerSecond = 1000 / (float)GetInt(ConfigKey.TickInterval); // rank to patrol World.RankToPatrol = RankManager.ParseRank(ConfigKey.PatrolledRank.GetString()); // IRC delay IRC.SendDelay = GetInt(ConfigKey.IRCDelay); BuildingCommands.MaxUndoCount = GetInt(ConfigKey.MaxUndo); if (!Paths.IgnoreMapPathConfigKey && GetString(ConfigKey.MapPath).Length > 0) { if (Paths.TestDirectory("MapPath", GetString(ConfigKey.MapPath), true)) { Paths.MapPath = Path.GetFullPath(GetString(ConfigKey.MapPath)); Logger.Log("Maps are stored at: {0}", LogType.SystemActivity, Paths.MapPath); } } AutoRankManager.CheckAutoRankSetting(); }