/// <summary> /// Loads server settings, loads the database, and prepares the system for use. /// </summary> public static void Setup() { Setting = new PbSettingsLoader(); TextFormats = new Text(); SysSettings = new Settings("System.txt", ReadSystemSettings); Setting.RegisterFile(SysSettings); SysSettings.LoadFile(); Rulesfile = new Settings("Rules.txt", ReadRules, "Settings/", false); Setting.RegisterFile(Rulesfile); Rulesfile.LoadFile(); if (RotateLogs) Logger.RotateLogs(); Permholder = new PermissionContainer(); Rankholder = new RankContainer(); Blockholder = new BlockContainer(); BmContainer = new BuildMode(); DefaultRank = Rankholder.GetRank(DefaultRank.Name); DB = new Database(); Logger.Log("Database", "Database loaded.", LogType.Info); Nh = new NetworkHandler(); Logger.Log("", "Core Initialized.", LogType.Info); Maps = new Dictionary<string, HypercubeMap>(StringComparer.InvariantCultureIgnoreCase); HypercubeMap.LoadMaps(); HypercubeMap m; Maps.TryGetValue(MapMain, out m); if (m == null) { var mainMap = new HypercubeMap("Maps/" + MapMain + ".cw", MapMain, 128, 128, 128); Maps.Add(MapMain, mainMap); Logger.Log("Core", "Main world not found, a new one has been created.", LogType.Warning); } Commandholder = new CommandHandler(); Fillholder = new FillContainer(); Luahandler = new HCLua(); Luahandler.RegisterFunctions(); Luahandler.LoadScripts(); Setting.SaveAll(); FillStacks(); ActionQueue = new ConcurrentQueue<MapAction>(); }
/// <summary> /// Loads the core server settings from file. /// </summary> public static void ReadSystemSettings() { ServerName = SysSettings.Read("Name", "Hypercube Server"); Motd = SysSettings.Read("MOTD", "Welcome to Hypercube!"); MapMain = SysSettings.Read("MainMap", "world"); WelcomeMessage = SysSettings.Read("Welcome Message", "&eWelcome to Hypercube!"); RotateLogs = bool.Parse(SysSettings.Read("RotateLogs", "true")); LogOutput = bool.Parse(SysSettings.Read("LogOutput", "true")); CompressHistory = bool.Parse(SysSettings.Read("CompressHistory", "true")); LogArguments = bool.Parse(SysSettings.Read("LogArguments", "false")); ColoredConsole = bool.Parse(SysSettings.Read("ColoredConsole", "true")); MaxBlockChanges = SysSettings.Read("MaxBlocksSecond", 33000); MaxHistoryEntries = SysSettings.Read("MaxHistoryEntries", 10); ClickDistance = SysSettings.Read("Click Distance", 160); DefaultRank = new Rank(SysSettings.Read("DefaultRank", "Guest"), "Default", "", "", false, 0, ""); if (Running) Logger.Log("Core", "System settings loaded.", LogType.Info); }
public bool CanBeSeen(Rank rank) { return rank.HasAllPermissions(ShowPermissions); }
public bool CanBeCalled(Rank rank) { return rank.HasAllPermissions(UsePermissions); }
public void LoadRanks() { NameList.Clear(); NumberList.Clear(); foreach (var id in Ranksfile.SettingsDictionary.Keys) { Ranksfile.SelectGroup(id); var newRank = new Rank { Id = int.Parse(id), Name = Ranksfile.Read("Name", "DEFAULT"), Prefix = Ranksfile.Read("Prefix", ""), Suffix = Ranksfile.Read("Suffix", ""), NextRank = Ranksfile.Read("NextRank", ""), Group = Ranksfile.Read("Group", "Default"), PointsInRank = Ranksfile.Read("Points", 5), Op = bool.Parse(Ranksfile.Read("IsOp", "false")), Permissions = PermissionContainer.SplitPermissions( Ranksfile.Read("Perms", "map.joinmap,player.chat,player.build,player.delete,chat.useemotes,command.tp")) }; NameList.Add(newRank.Name, newRank); NumberList.Add(newRank.Id, newRank); } if (NameList.Count == 0) { var guestRank = new Rank("Guest", "Default", "&f", "", false, 50, "Builder") { Id = 0, Permissions = PermissionContainer.SplitPermissions( "map.joinmap,player.chat,player.build,player.delete,chat.useemotes,command.tp") }; var builderRank = new Rank("Builder", "Default", "&e", "", false, 15, "") { Id = 1, Permissions = PermissionContainer.SplitPermissions( "map.joinmap,player.chat,player.build,player.delete,chat.useemotes,command.tp,map.viewhistory") }; var opRank = new Rank("Op", "Staff", "&9", "", true, 100, "") { Id = 2, Permissions = PermissionContainer.SplitPermissions( "map.joinmap,player.op,player.seehidden,player.hide,player.chat,player.build,player.delete,chat.useemotes,command.tp,command.bring,map.joinhiddenmap,map.viewhistorychat.readstaffchat,player.kick,player.mute,player.stop") }; var ownerRank = new Rank("Owner", "Staff", "&0", "", true, 0, "") { Id = 3, Permissions = PermissionContainer.SplitPermissions( "map.addmap,map.joinmap,player.op,player.seehidden,player.hide,player.chat,player.build,player.delete,chat.useemotes,command.tp,command.bring,map.viewhistory,map.joinhiddenmap,chat.readstaffchat,map.fillmap,player.kick,player.mute,player.stop,player.ban") }; NumberList.Add(0, guestRank); NameList.Add("Guest", guestRank); NumberList.Add(1, builderRank); NameList.Add("Builder", builderRank); NumberList.Add(2, opRank); NameList.Add("Op", opRank); NumberList.Add(3, ownerRank); NameList.Add("Owner", ownerRank); SaveRanks(); } CreateHierarchy(); ServerCore.Logger.Log("RankContainer", "Ranks loaded.", LogType.Info); }
/// <summary> /// Is rank1 a higher rank than rank 2? /// </summary> /// <param name="rank1"></param> /// <param name="rank2"></param> /// <returns></returns> public bool IsRankHigher(Rank rank1, Rank rank2) { var myList = RankHierarchy[rank1]; return !myList.Contains(rank2); }