static void FixupOldPerms() { var perms = SrvProperties.oldPerms; Server.opchatperm = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator); Server.adminchatperm = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); if (perms.clearPerm == -1 && perms.nextPerm == -1 && perms.viewPerm == -1 && perms.opchatPerm == -1 && perms.adminchatPerm == -1) { return; } // Backwards compatibility with old config, where some permissions were global if (perms.viewPerm != -1) { CommandOtherPerms.Find("review", 1).Permission = perms.viewPerm; } if (perms.nextPerm != -1) { CommandOtherPerms.Find("review", 2).Permission = perms.nextPerm; } if (perms.clearPerm != -1) { CommandOtherPerms.Find("review", 3).Permission = perms.clearPerm; } if (perms.opchatPerm != -1) { CommandOtherPerms.Find("opchat").Permission = perms.opchatPerm; } if (perms.adminchatPerm != -1) { CommandOtherPerms.Find("adminchat").Permission = perms.adminchatPerm; } CommandOtherPerms.Save(); }
public static void PrintCommandInfo(Player p, Command cmd) { var perms = GrpCommands.allowedCommands.Find(C => C.commandName == cmd.name); StringBuilder builder = new StringBuilder(); builder.Append("Usable by: "); if (perms == null) { builder.Append(Group.GetColoredName(cmd.defaultRank) + "%S+"); } else { PrintRanks(perms.lowestRank, perms.allow, perms.disallow, builder); } Player.Message(p, builder.ToString()); PrintAliases(p, cmd); CommandPerm[] addPerms = cmd.ExtraPerms; if (addPerms == null) { return; } Player.Message(p, "%TExtra permissions:"); for (int i = 0; i < addPerms.Length; i++) { var extra = CommandOtherPerms.Find(cmd, i + 1); LevelPermission perm = (LevelPermission)extra.Permission; Player.Message(p, "{0}) {1}%S{2}", i + 1, Group.GetColoredName(perm), extra.Description); } }
public void Add(Command cmd) { commands.Add(cmd); CommandPerm[] perms = cmd.AdditionalPerms; if (!AddOtherPerms || perms == null) { return; } for (int i = 0; i < perms.Length; i++) { CommandOtherPerms.Add(cmd, (int)perms[i].Perm, perms[i].Description, i + 1); } }
public static void LoadAllSettings() { Colors.LoadExtColors(); Alias.Load(); BlockDefinition.LoadGlobal(); SrvProperties.Load("properties/server.properties"); Updater.Load("properties/update.properties"); Group.InitAll(); Command.InitAll(); GrpCommands.fillRanks(); Block.SetBlocks(); Awards.Load(); Economy.Load(); Warp.LOAD(); CommandOtherPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); }
public static void LoadAllSettings() { zombie.LoadInfectMessages(); Colors.LoadExtColors(); Alias.Load(); Bots.BotsFile.Load(); BlockDefinition.LoadGlobal(); SrvProperties.Load("properties/server.properties"); Updater.Load("properties/update.properties"); Group.InitAll(); Command.InitAll(); GrpCommands.fillRanks(); Block.SetBlocks(); Awards.Load(); Economy.Load(); WarpList.Global.Load(null); CommandOtherPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); FixupOldPerms(); }
static void ShowAltsTask(SchedulerTask task) { string name = (string)task.State; Player p = PlayerInfo.FindExact(name); if (p == null || p.ip == "127.0.0.1" || p.disconnected) { return; } List <string> alts = PlayerInfo.FindAccounts(p.ip); // Remove online accounts from the list of accounts on the IP for (int i = alts.Count - 1; i >= 0; i--) { if (PlayerInfo.FindExact(alts[i]) == null) { continue; } alts.RemoveAt(i); } if (alts.Count == 0) { return; } LevelPermission adminChatRank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); string altsMsg = p.ColoredName + " %Sis lately known as: " + alts.Join(); if (p.group.Permission < adminChatRank || !Server.adminsjoinsilent) { Chat.MessageOps(altsMsg); //IRCBot.Say(temp, true); //Tells people in op channel on IRC } Server.s.Log(altsMsg); }
void CompleteLoginProcess() { LevelPermission adminChatRank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); SendUserMOTD(); SendMap(null); if (disconnected) { return; } loggedIn = true; PlayerInfo.Online.Add(this); connections.Remove(this); RemoveFromPending(); Server.s.PlayerListUpdate(); //OpenClassic Client Check SendBlockchange(0, 0, 0, 0); timeLogged = DateTime.Now; lastLogin = DateTime.Now; time = new TimeSpan(0, 0, 0, 1); DataTable playerDb = Database.Backend.GetRows("Players", "*", "WHERE Name=@0", name); if (playerDb.Rows.Count == 0) { InitPlayerStats(playerDb); } else { LoadPlayerStats(playerDb); } Server.Background.QueueOnce(ShowAltsTask, name, TimeSpan.Zero); CheckState(); ZombieStats stats = Server.zombie.LoadZombieStats(name); Game.MaxInfected = stats.MaxInfected; Game.TotalInfected = stats.TotalInfected; Game.MaxRoundsSurvived = stats.MaxRounds; Game.TotalRoundsSurvived = stats.TotalRounds; if (!Directory.Exists("players")) { Directory.CreateDirectory("players"); } PlayerDB.Load(this); Game.Team = Team.FindTeam(this); SetPrefix(); playerDb.Dispose(); LoadCpeData(); if (Server.verifyadmins && group.Permission >= Server.verifyadminsrank) { adminpen = true; } if (Server.noEmotes.Contains(name)) { parseEmotes = !Server.parseSmiley; } hidden = group.CanExecute("hide") && Server.hidden.Contains(name); if (hidden) { SendMessage("&8Reminder: You are still hidden."); } if (group.Permission >= adminChatRank && Server.adminsjoinsilent) { hidden = true; adminchat = true; } if (PlayerConnect != null) { PlayerConnect(this); } OnPlayerConnectEvent.Call(this); if (cancellogin) { cancellogin = false; return; } string joinm = "&a+ " + FullName + " %S" + PlayerDB.GetLoginMessage(this); if (hidden) { joinm = "&8(hidden)" + joinm; } const LevelPermission perm = LevelPermission.Guest; if (group.Permission > perm || (Server.guestJoinNotify && group.Permission <= perm)) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { if (Entities.CanSee(pl, this)) { Player.Message(pl, joinm); } } } if (Server.agreetorulesonentry && group.Permission == LevelPermission.Guest && !Server.agreed.Contains(name)) { SendMessage("&9You must read the &c/rules&9 and &c/agree&9 to them before you can build and use commands!"); agreed = false; } if (Server.verifyadmins && group.Permission >= Server.verifyadminsrank) { if (!Directory.Exists("extra/passwords") || !File.Exists("extra/passwords/" + name + ".dat")) { SendMessage("&cPlease set your admin verification password with &a/setpass [Password]!"); } else { SendMessage("&cPlease complete admin verification with &a/pass [Password]!"); } } Server.s.Log(name + " [" + ip + "] has joined the server."); Game.InfectMessages = PlayerDB.GetInfectMessages(this); Server.zombie.PlayerJoinedServer(this); ushort x = (ushort)(level.spawnx * 32 + 16); ushort y = (ushort)(level.spawny * 32 + 32); ushort z = (ushort)(level.spawnz * 32 + 16); pos = new ushort[3] { x, y, z }; rot = new byte[2] { level.rotx, level.roty }; Entities.SpawnEntities(this, x, y, z, rot[0], rot[1]); PlayerActions.CheckGamesJoin(this, null); Loading = false; }
public static void MessageAdmins(Player p, string message) { LevelPermission rank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); MessageStaff(p, message, rank, "Admins"); }
public static void MessageOps(Player p, string message) { LevelPermission rank = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator); MessageStaff(p, message, rank, "Ops"); }
/// <summary> Sends a message to all players who are have the permission to read adminchat. </summary> public static void MessageAdmins(string message) { LevelPermission rank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); MessageWhere(message, pl => pl.Rank >= rank); }
/// <summary> Sends a message to all players who are have the permission to read opchat. </summary> public static void MessageOps(string message) { LevelPermission rank = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator); MessageWhere(message, pl => pl.Rank >= rank); }
protected void MessageNeedPerms(Player p, string action, int num = 1) { int perm = CommandOtherPerms.GetPerm(this, num); MessageNeedMinPerm(p, action, perm); }
protected bool CheckAdditionalPerm(Player p, int num = 1) { return(p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, num)); }
protected void MessageNeedExtra(Player p, string action, int num = 1) { int perm = CommandOtherPerms.GetPerm(this, num); Formatter.MessageNeedMinPerm(p, action, (LevelPermission)perm); }
protected bool CheckExtraPerm(Player p, int num = 1) { return(p == null || (int)p.Rank >= CommandOtherPerms.GetPerm(this, num)); }
public void ChatLevelAdmins(string message) { LevelPermission rank = CommandOtherPerms.FindPerm("adminchat", LevelPermission.Admin); ChatLevel(message, rank); }
public void ChatLevelOps(string message) { LevelPermission rank = CommandOtherPerms.FindPerm("opchat", LevelPermission.Operator); ChatLevel(message, rank); }