static void LoadZones(Map mapFile, OpticraftDataStore dataStore) { if (dataStore.Zones.Length == 0) { return; } // TODO: investigate side effects PlayerInfo conversionPlayer = new PlayerInfo("OpticraftConversion", RankManager.HighestRank, true, RankChangeType.AutoPromoted); foreach (OpticraftZone optiZone in dataStore.Zones) { //Make zone Zone fZone = new Zone { Name = optiZone.Name, }; BoundingBox bBox = new BoundingBox(optiZone.X1, optiZone.Y1, optiZone.Z1, optiZone.X2, optiZone.X2, optiZone.Z2); fZone.Create(bBox, conversionPlayer); //Min rank Rank minRank = RankManager.FindRank(optiZone.MinimumRank); if (minRank != null) { fZone.Controller.MinRank = minRank; } foreach (string playerName in optiZone.Builders) { //These are all lower case names if (!Player.IsValidName(playerName)) { continue; } PlayerInfo pInfo = PlayerDB.FindPlayerInfoExact(playerName); if (pInfo != null) { fZone.Controller.Include(pInfo); } } //Excluded names are not as of yet implemented in opticraft, but will be soon // So add compatibility for them when they arrive. if (optiZone.Excluded != null) { foreach (string playerName in optiZone.Excluded) { //These are all lower case names if (!Player.IsValidName(playerName)) { continue; } PlayerInfo pInfo = PlayerDB.FindPlayerInfoExact(playerName); if (pInfo != null) { fZone.Controller.Exclude(pInfo); } } } mapFile.AddZone(fZone); } }
public static void DoAutoPromo(SchedulerTask task) { string warpfile = "warp.txt"; try { if (!File.Exists(warpfile)) { return; } using (StreamReader reader = File.OpenText(warpfile)) { while (!reader.EndOfStream) { string[] fields = reader.ReadLine().Split(' '); if (fields.Length != 3) { continue; } try { PlayerInfo info = PlayerDB.FindPlayerInfoExact(fields[0]); if (info == null) { continue; } Rank newRank = RankManager.FindRank(fields[1]); if (newRank == null) { continue; } if (info.Rank == newRank) { continue; } info.ChangeRank(Player.Console, newRank, "PROMOTION FROM FORUM (" + fields[2] + ")", true, true, false); } catch (Exception) { } } } } catch (Exception) { } try { File.Delete(warpfile); } catch (Exception) { } }
private void playerList_SelectedIndexChanged(object sender, EventArgs e) { try { string s = ( string )playerList.Items[playerList.SelectedIndex]; s = s.Substring(s.IndexOf('-'), s.Length - s.IndexOf('-')) .Replace("-", "") .Replace(" ", "") .Trim(); PlayerInfo player = PlayerDB.FindPlayerInfoExact(s); if (player == null) { return; } v = new SkinViewer(player); v.Show(); } catch { } //do nothing at all }
public static void OnCheckingPlayerLogin(object sender, CheckingPlayerLoginEventArgs e) { PlayerInfo Info = PlayerDB.FindPlayerInfoExact(e.Name); bool ipMatch = false; bool lowLevel = true; if (Info != null) { if (Info.TimesVisited > 1 && Info.LastIP.Equals(e.Player.IP)) { ipMatch = true; } if (Info.Rank.Can(Permission.Kick)) { lowLevel = false; } } bool verifyMain = Server.VerifyName(e.Name, e.VerificationCode, NKMods.mainSalt); bool verifyWom = Server.VerifyName(e.Name, e.VerificationCode, NKMods.womSalt); if (verifyMain || (ipMatch && lowLevel) || (verifyWom && lowLevel) || (verifyWom && ipMatch)) { e.Verify = true; return; } if (verifyWom && !lowLevel) { e.Player.KickNow("You cannot connect via WoM Direct at your rank", LeaveReason.UnverifiedName); e.Abort = true; return; } e.Player.KickNow("It seems that minecraft.net authentication is down, sorry.", LeaveReason.UnverifiedName); e.Abort = true; return; }
public static void RevertNames() //reverts names for online players. offline players get reverted upon leaving the game { List <PlayerInfo> TDPlayers = new List <PlayerInfo>(PlayerDB.PlayerInfoList.Where(r => (r.isOnBlueTeam || r.isOnRedTeam) && r.IsOnline).ToArray()); for (int i = 0; i < TDPlayers.Count(); i++) { string p1 = TDPlayers[i].Name.ToString(); PlayerInfo pI = PlayerDB.FindPlayerInfoExact(p1); Player p = pI.PlayerObject; if (p != null) { p.iName = null; pI.tempDisplayedName = null; pI.isOnRedTeam = false; pI.isOnBlueTeam = false; pI.isPlayingTD = false; pI.Health = 100; p.entityChanged = true; //reset all special messages if (p.usesCPE) { p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f")); p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f")); p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&f")); } //undo gunmode (taken from GunHandler.cs) p.GunMode = false; try { foreach (Vector3I block in p.GunCache.Values) { p.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, p.WorldMap.GetBlock(block))); Vector3I removed; p.GunCache.TryRemove(block.ToString(), out removed); } if (p.bluePortal.Count > 0) { int j = 0; foreach (Vector3I block in p.bluePortal) { if (p.WorldMap != null && p.World.IsLoaded) { p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.blueOld[j])); j++; } } p.blueOld.Clear(); p.bluePortal.Clear(); } if (p.orangePortal.Count > 0) { int j = 0; foreach (Vector3I block in p.orangePortal) { if (p.WorldMap != null && p.World.IsLoaded) { p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.orangeOld[j])); j++; } } p.orangeOld.Clear(); p.orangePortal.Clear(); } } catch (Exception ex) { Logger.Log(LogType.SeriousError, "" + ex); } if (p.IsOnline) { p.Message("Your status has been reverted."); } } } }
public Zone([NotNull] string raw, [CanBeNull] World world) : this() { if (raw == null) { throw new ArgumentNullException("raw"); } string[] parts = raw.Split(','); string[] header = parts[0].Split(' '); Name = header[0]; Bounds = new BoundingBox(Int32.Parse(header[1]), Int32.Parse(header[2]), Int32.Parse(header[3]), Int32.Parse(header[4]), Int32.Parse(header[5]), Int32.Parse(header[6])); Rank buildRank = Rank.Parse(header[7]); if (header[0].Contains("Door_")) { buildRank = RankManager.DefaultRank; } // if all else fails, fall back to lowest class... ignore door instances if (buildRank == null && !header[0].Contains("Door_")) { if (world != null) { Controller.MinRank = world.BuildSecurity.MinRank; } else { Controller.ResetMinRank(); } Logger.Log(LogType.Error, "Zone: Error parsing zone definition: unknown rank \"{0}\". Permission reset to default ({1}). Ignore this message if you have recently changed rank permissions.", header[7], Controller.MinRank.Name); } else { Controller.MinRank = buildRank; } if (PlayerDB.IsLoaded) { // Part 2: if (parts[1].Length > 0) { foreach (string playerName in parts[1].Split(' ')) { if (!Player.IsValidName(playerName)) { Logger.Log(LogType.Warning, "Invalid entry in zone \"{0}\" whitelist: {1}", Name, playerName); continue; } PlayerInfo info = PlayerDB.FindPlayerInfoExact(playerName); if (info == null) { Logger.Log(LogType.Warning, "Unrecognized player in zone \"{0}\" whitelist: {1}", Name, playerName); continue; // player name not found in the DB (discarded) } Controller.Include(info); } } // Part 3: excluded list if (parts[2].Length > 0) { foreach (string playerName in parts[2].Split(' ')) { if (!Player.IsValidName(playerName)) { Logger.Log(LogType.Warning, "Invalid entry in zone \"{0}\" blacklist: {1}", Name, playerName); continue; } PlayerInfo info = PlayerDB.FindPlayerInfoExact(playerName); if (info == null) { Logger.Log(LogType.Warning, "Unrecognized player in zone \"{0}\" whitelist: {1}", Name, playerName); continue; // player name not found in the DB (discarded) } Controller.Exclude(info); } } } else { rawWhitelist = parts[1]; rawBlacklist = parts[2]; } // Part 4: extended header if (parts.Length > 3) { string[] xheader = parts[3].Split(' '); if (xheader[0] == "-") { CreatedBy = null; CreatedDate = DateTime.MinValue; } else { CreatedBy = xheader[0]; CreatedDate = DateTime.Parse(xheader[1]); } if (xheader[2] == "-") { EditedBy = null; EditedDate = DateTime.MinValue; } else { EditedBy = xheader[2]; EditedDate = DateTime.Parse(xheader[3]); } } //message if (parts.Length > 4 && !string.IsNullOrWhiteSpace(parts[4])) { Message = parts[4].Replace('\\', ','); } else { Message = null; } }