private static void HandleCreate(GameSession session, PacketReader packet) { Party party = GameServer.PartyManager.GetPartyByLeader(session.Player); if (party is null || party.Leader.CharacterId != session.Player.CharacterId) { return; } int maxClubCount = int.Parse(ConstantsMetadataStorage.GetConstant("ClubMaxCount")); // Fail if a party member is offline or if member has joined max amount of clubs if (party.Members.Any(x => !x.Session.Connected()) || party.Members.Any(x => x.Clubs.Count >= maxClubCount)) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.SomePartyMembersCannotBeInvited)); return; } string clubName = packet.ReadUnicodeString(); if (!ValidClubName(session, clubName)) { return; } Club club = new(party, clubName); GameServer.ClubManager.AddClub(club); party.BroadcastPacketParty(ClubPacket.Create(party, club)); }
private static void HandleRename(GameSession session, PacketReader packet) { long clubId = packet.ReadLong(); string clubNewName = packet.ReadUnicodeString(); Club club = GameServer.ClubManager.GetClubById(clubId); if (club is null) { return; } if (club.LastNameChangeTimestamp > TimeInfo.Now() + 3600) // 1 hour restriction to change names { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.CanOnlyBeRenamedOnceAnHour)); return; } if (!ValidClubName(session, clubNewName)) { return; } if (clubNewName == club.Name) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.NewNameIsCurrentName)); return; } club.SetName(clubNewName); }
private static bool ValidClubName(GameSession session, string clubName) { if (DatabaseManager.Clubs.NameExists(clubName)) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.ClubWithNameAlreadyExists)); return(false); } if (clubName.Contains(' ')) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.NoSpacesInName)); return(false); } return(true); }
private static void HandleSendInvite(GameSession session, PacketReader packet) { long clubId = packet.ReadLong(); string invitee = packet.ReadUnicodeString(); Player other = GameServer.PlayerManager.GetPlayerByName(invitee); if (other == null) { return; } if (other.Clubs.Any(x => x.Id == clubId)) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.AlreadyInClub)); return; } if (other.Clubs.Count >= int.Parse(ConstantsMetadataStorage.GetConstant("ClubMaxCount"))) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.PlayerCannotJoinMoreClubs)); return; } Club club = GameServer.ClubManager.GetClubById(clubId); if (club == null) { return; } if (club.Members.Count >= int.Parse(ConstantsMetadataStorage.GetConstant("ClubMaxMembers"))) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.ClubIsFull)); return; } session.Send(ClubPacket.InviteSentReceipt(clubId, other)); other.Session.Send(ClubPacket.Invite(club, other)); }