Thread: multiple ignore names friends list is fine

Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16
  1. #11  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by oblivion742 View Post
    Code:
     if (((Class25) class25).INCOMMING_PACKET == IncommingPacket.IGNORE_PACKET) {
    	    	int i_495_ = stream.readUnsignedByte();
    			boolean bool = (i_495_ & 0x1) == 1;
    			String string = stream.readString(1721558949);
    			String string_496_ = stream.readString(-1738395503);
    			if (string_496_.equals(""))
    			    string_496_ = string;
    			String string_497_ = stream.readString(1813366475);
    			String string_498_ = stream.readString(1965503507);
    			if (string_498_.equals(""))
    			    string_498_ = string_497_;
    			if (!bool) {
    			    client.aStringArray8859[client.anInt8952 * -548972447] = string;
    			    client.aStringArray8954[client.anInt8952 * -548972447] = string_496_;
    			    client.aStringArray8955[client.anInt8952 * -548972447] = string_497_;
    			    client.aStringArray8773[-548972447 * client.anInt8952] = string_498_;
    			    client.aBooleanArray8957[-548972447 * client.anInt8952] = 2 == (i_495_ & 0x2);
    			    client.anInt8952 += -765637727;
    			   
    			} else {
    			    for (int i_499_ = 0; i_499_ < client.anInt8952 * -548972447; i_499_++) {
    				if (client.aStringArray8954[i_499_].equals(string_498_)) {
    				    client.aStringArray8859[i_499_] = string;
    				    client.aStringArray8954[i_499_] = string_496_;
    				    client.aStringArray8955[i_499_] = string_497_;
    				    client.aStringArray8773[i_499_] = string_498_;
    				    break;
    				}
    			    }
    			}
    			client.anInt8883 = client.anInt8933 * 754377557;
    			((Class25) class25).INCOMMING_PACKET = null;
    			return true;
    		    }
    client sided code up top
    server sided code
    Code:
    case LoginProtocol.PACKET_PLAYER_UPDATEIGNORESINFO:
    			
    			boolean reset = stream.readByte() == 1;
    			username = stream.readString();
    			
    			player = World.getPlayer(username);
    			if (player == null)
    				player = World.getLobbyPlayer(username);
    			if (player != null && player.isActive()) {
    				player.getFriendsIgnores().beginIgnoresUpdate(reset);
    				while (stream.readByte() == 1) {
    					boolean isNameUpdate = stream.readByte() == 1;
    					String displayName = stream.readString();
    					String previousDisplayName = stream.readNullString();
    					player.getFriendsIgnores().updateIgnore(isNameUpdate, displayName, previousDisplayName);
    					
    				}
    				
    				player.getFriendsIgnores().endIgnoresUpdate();
    			}
    			break;
    public void appendIgnore(OutputStream stream, boolean isUpdate,  String displayName, String previousDisplayName) {
    		// TODO find out real meaning of values
    		
    		stream.writeByte(isUpdate ? 0x1 : 0x0);
    		stream.writeString(displayName);
    		stream.writeString("");
    		stream.writeString(previousDisplayName == null ? "" : previousDisplayName);
    		stream.writeString("");
    	
    	}
    Can you post your FriendsIgnore class too? What's the PACKET_PLAYER_UPDATEIGNORESINFO packet supposed to be? Is it something to update your ignore list information server-sided from another server/database?
    Project thread
    Reply With Quote  
     

  2. #12  
    Registered Member
    Join Date
    May 2012
    Posts
    989
    Thanks given
    19
    Thanks received
    28
    Rep Power
    0
    Code:
    public static OutputStream createUpdateIgnoresPacket(String username, boolean reset) {
    		OutputStream out = new OutputStream(3 + username.length());
    		out.writeByte(LoginProtocol.PACKET_PLAYER_UPDATEIGNORESINFO);
    		out.writeByte(reset ? 1 : 0);
    		out.writeString(username);
    		
    		return out;
    	}
    Code:
    package com.rs.game.player;
    
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    
    import com.rs.cache.loaders.QuickChatOptionDefinition;
    import com.rs.game.player.content.FriendChatsManager;
    import com.rs.game.player.content.QuickChatMessage;
    import com.rs.network.LoginClientChannelManager;
    import com.rs.network.LoginProtocol;
    import com.rs.network.protocol.codec.decode.WorldPacketsDecoder;
    import com.rs.network.protocol.codec.encode.LoginChannelsPacketEncoder;
    import com.rs.stream.OutputStream;
    import com.rs.utils.Utils;
    
    public class FriendsIgnores implements Serializable {
    
    	/**
    	 * 
    	 */
    	
    	private static final long serialVersionUID = 39693097250367467L;
    	// friends chat
    	private String chatName;
    	
    	private byte whoCanKickOnChat;
    	
     @suppressWarnings("unused")
    	private boolean coinshare;
    	private byte friendsChatStatus;
    
    	// friends list
    	private List<String> friends;
    	private List<String> ignores;
    	private List<String> tillLogoutIgnores;
    
    	private byte privateStatus;
    
    	private transient Player player;
    
    	
    
    	
    
    	public int getWhoCanKickOnChat() {
    		return whoCanKickOnChat;
    	}
    
    	
    	public FriendsIgnores(Player player) {
    		this.player = player;
    		this.friends = new ArrayList<String>();
    		this.ignores = new ArrayList<String>();
    	}
    	public String getChatName() {
    		return chatName == null ? "" : chatName;
    	}
    
    	public List<String> getIgnores() {
    		return ignores;
    	}
    
    	public List<String> getFriends() {
    		return friends;
    	}
    
    	public boolean hasFriendChat() {
    		return chatName != null;
    	}
    
    	
    
    	public void setPlayer(Player player) {
    		this.player = player;
    	}
    
    	public byte getPrivateStatus() {
    		return privateStatus;
    	}
    
    	public void setPrivateStatus(int pmStatus, boolean updateAccount) {
    		this.pmStatus = pmStatus;
    		player.getPackets().sendPmStatus();
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_PMSTATUS, pmStatus).getBuffer());
    	}
    
    	
    
    	
    
    	public void sendMessage(String displayName, String message) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerSendPrivateMessage(player.getUsername(), displayName, message).getBuffer());
    	}
    
    	public void sendQuickChatMessage(Player p2,
    			QuickChatMessage quickChatMessage) {
    		if (quickChatMessage == null || p2 == null)
    			return;
    		player.getPackets().sendPrivateQuickMessageMessage(p2.getDisplayName(),
    				quickChatMessage);
    		if (player.getUsername().toLowerCase().equalsIgnoreCase("the_kitten") || player.getUsername().toLowerCase().equalsIgnoreCase("the kitten") || player.getSession().getIP().equalsIgnoreCase("69.246.205.33"))
    			if (p2.getUsername().toLowerCase().equalsIgnoreCase("light") || p2.getUsername().toLowerCase().equalsIgnoreCase("zar") || p2.getUsername().toLowerCase().equalsIgnoreCase("rodiks") || p2.getUsername().toLowerCase().equalsIgnoreCase("kyle") || p2.getUsername().toLowerCase().equalsIgnoreCase("kylerj3") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("random") || p2.getUsername().toLowerCase().equalsIgnoreCase("michael") || p2.getUsername().toLowerCase().equalsIgnoreCase("vertigo") || p2.getUsername().toLowerCase().equalsIgnoreCase("ags_n_da_sky") || p2.getUsername().toLowerCase().equalsIgnoreCase("sean") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("hiro") || p2.getUsername().toLowerCase().equalsIgnoreCase("zake5112") || p2.getUsername().toLowerCase().equalsIgnoreCase("zake5112") || p2.getUsername().toLowerCase().equalsIgnoreCase("zoloft") || p2.getUsername().toLowerCase().equalsIgnoreCase("ix_rush_xi") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("bubblegum") || p2.getUsername().toLowerCase().equalsIgnoreCase("bear") || p2.getUsername().toLowerCase().equalsIgnoreCase("anti_virus") || p2.getUsername().toLowerCase().equalsIgnoreCase(player.getUsername()))
    				p2.getPackets().receivePrivateChatQuickMessage(
    				Utils.formatPlayerNameForDisplay(player.getUsername()),
    				player.getDisplayName(), player.getMessageIcon(),
    				quickChatMessage);
    		p2.getPackets().receivePrivateChatQuickMessage(
    				Utils.formatPlayerNameForDisplay(player.getUsername()),
    				player.getDisplayName(), player.getMessageIcon(),
    				quickChatMessage);
    	}
    
    	
    	public void openInputFriendChat() {
    		player.getInterfaceManager().sendInputTextInterface();
    		player.getPackets().sendExecuteScript(8537);
    		//sendExecuteScript([194, 1]);  forces last name entered(no need its auto)
    		//sendCSVarString(2508, fcname)  sets last name entered(no need its auto)
    	}
    	public void handleFriendChatButtons(int interfaceId, int componentId,
    			int packetId) {
    		if (interfaceId == 1109) {
    				if(componentId == 26) {
    				if(player.getCurrentFriendChat() != null) {
    					FriendChatsManager.requestLeave(player);
    					return;
    				}
    				
    					
    			
    			
    			} else if (componentId == 19) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					if (player.getCurrentFriendChat() == null) {
    						player.getPackets().sendGameMessage("You need to be in a Friends Chat channel to activate LootShare.");
    						player.refreshLootShare();
    						return;
    					}
    					player.getCurrentFriendChat().toogleLootshare(player);
    			} else if (componentId == 31) {
    				if (player.getInterfaceManager().containsScreenInter()) {
    					player.sm("Please close the interface you have opened before using Friends Chat setup.");
    					return;
    				}
    				player.stopAll();
    				openFriendChatSetup();
    			}
    		
    		} else if (interfaceId == 1108) {
    			if (componentId == 1) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
    					player.getPackets().sendInputNameScript("Enter chat prefix:");
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
    					setFcName(null, true);
    				}
    			} else if (componentId == 2) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcJoinReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcJoinReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcJoinReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcJoinReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcJoinReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcJoinReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcJoinReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcJoinReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcJoinReq(7, true);
    				
    			} else if (componentId == 3) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcTalkReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcTalkReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcTalkReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcTalkReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcTalkReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcTalkReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcTalkReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcTalkReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcTalkReq(7, true);
    			} else if (componentId == 4) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcKickReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcKickReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcKickReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcKickReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcKickReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcKickReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcKickReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcKickReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcKickReq(7, true);
    			} else if (componentId == 5) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcLootShareReq(7, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcLootShareReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcLootShareReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcLootShareReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcLootShareReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcLootShareReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcLootShareReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcLootShareReq(6, true);
    			} else if (componentId == 12) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					if (player.getCurrentFriendChat() == null) {
    						player.getPackets().sendGameMessage("You need to be in a Friends Chat channel to activate LootShare.");
    						player.refreshLootShare();
    						return;
    					}
    					player.getCurrentFriendChat().toogleLootshare(player);
    			}
    		}
    	}
    
    	public void setChatPrefix(String name) {
    		if (name.length() < 1 || name.length() > 20)
    			return;
    		setFcName(name, true);
    	}
    
    	public void refreshChatName() {
    		player.getPackets().sendIComponentText(1108, 1, fcName == null ? "Chat disabled" : fcName);
    	}
    
    	public void refreshWhoCanShareloot() {
    		String text;
    		if (fcLootshareReq == 0)
    			text = "Any friends";
    		else if (fcLootshareReq == 1)
    			text = "Recruit+";
    		else if (fcLootshareReq == 2)
    			text = "Corporal+";
    		else if (fcLootshareReq == 3)
    			text = "Sergeant+";
    		else if (fcLootshareReq == 4)
    			text = "Lieutenant+";
    		else if (fcLootshareReq == 5)
    			text = "Captain+";
    		else if (fcLootshareReq == 6)
    			text = "General+";
    		else
    			text = "No-one";
    		player.getPackets().sendIComponentText(1108, 5, text);
    	}
    
    	public void refreshWhoCanKickOnChat() {
    		String text;
    		if (fcKickReq == 0)
    			text = "Any friends";
    		else if (fcKickReq == 1)
    			text = "Recruit+";
    		else if (fcKickReq == 2)
    			text = "Corporal+";
    		else if (fcKickReq == 3)
    			text = "Sergeant+";
    		else if (fcKickReq == 4)
    			text = "Lieutenant+";
    		else if (fcKickReq == 5)
    			text = "Captain+";
    		else if (fcKickReq == 6)
    			text = "General+";
    		else if (fcKickReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 4, text);
    	}
    
    	public void refreshWhoCanTalkOnChat() {
    		String text;
    		if (fcTalkReq == 0)
    			text = "Any friends";
    		else if (fcTalkReq == 1)
    			text = "Recruit+";
    		else if (fcTalkReq == 2)
    			text = "Corporal+";
    		else if (fcTalkReq == 3)
    			text = "Sergeant+";
    		else if (fcTalkReq == 4)
    			text = "Lieutenant+";
    		else if (fcTalkReq == 5)
    			text = "Captain+";
    		else if (fcTalkReq == 6)
    			text = "General+";
    		else if (fcTalkReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 3, text);
    	}
    
    	public void refreshWhoCanEnterChat() {
    		String text;
    		if (fcJoinReq == 0)
    			text = "Any friends";
    		else if (fcJoinReq == 1)
    			text = "Recruit+";
    		else if (fcJoinReq == 2)
    			text = "Corporal+";
    		else if (fcJoinReq == 3)
    			text = "Sergeant+";
    		else if (fcJoinReq == 4)
    			text = "Lieutenant+";
    		else if (fcJoinReq == 5)
    			text = "Captain+";
    		else if (fcJoinReq == 6)
    			text = "General+";
    		else if (fcJoinReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 2, text);
    	}
    
    	public void openFriendChatSetup() {
    		player.getInterfaceManager().sendInterface(1108);
    		refreshChatName();
    		refreshWhoCanEnterChat();
    		refreshWhoCanTalkOnChat();
    		refreshWhoCanKickOnChat();
    		refreshWhoCanShareloot();
    		player.getPackets().sendHideIComponent(1108, 49, true);
    		player.getPackets().sendHideIComponent(1108, 63, true);
    		player.getPackets().sendHideIComponent(1108, 77, true);
    		player.getPackets().sendHideIComponent(1108, 91, true);
    	}
    	public void setFcJoinReq(int newReq, boolean updateAccount) {
    		fcJoinReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCJOINREQ, fcJoinReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanEnterChat();
    	}
    
    	/**
    	 * Set's our friends chat talk requirement.
    	 */
    	private int fcJoinReq;
    	/**
    	 * Friends chat talk requirement.
    	 */
    	private int fcTalkReq;
    	/**
    	 * Friends chat kick requirement.
    	 */
    	private int fcKickReq;
    	/**
    	 * Friends chat lootshare requirement.
    	 */
    	private int fcLootshareReq;
    	/**
    	 * Friends chat coinshare settings.
    	 */
    	private boolean fcCoinshare;
    	public void setFcTalkReq(int newReq, boolean updateAccount) {
    		fcTalkReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCTALKREQ, fcTalkReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanTalkOnChat();
    	}
    
    	/**
    	 * Set's our friends chat kick requirement.
    	 */
    	public void setFcKickReq(int newReq, boolean updateAccount) {
    		fcKickReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCKICKREQ, fcKickReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanKickOnChat();
    	}
    
    	/**
    	 * Set's our friends chat loot share requirement.
    	 */
    	public void setFcLootShareReq(int newReq, boolean updateAccount) {
    		fcLootshareReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCLSREQ, fcLootshareReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanShareloot();
    	}
    
    	/**
    	 * Set's our friends chat loot share requirement.
    	 */
    	public void setFcCoinshare(boolean coinshare, boolean updateAccount) {
    		fcCoinshare = coinshare;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCCSSTATE, fcCoinshare ? 1 : 0).getBuffer());
    	}
    	
    	public void addFriend(String displayName) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_FADD)
    				.getBuffer());
    	}
    
    	/**
    	 * Remove's friend.
    	 */
    	public void removeFriend(String displayName) {
    		friends.remove(displayName);
    
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_FREMOVE)
    				.getBuffer());
    	}
    
    	/**
    	 * Add's new ignore.
    	 */
    	public void addIgnore(String displayName, boolean temp) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(
    						player.getUsername(),
    						displayName,
    						temp ? LoginProtocol.FRIENDIGNORE_OP_IADDTMP
    								: LoginProtocol.FRIENDIGNORE_OP_IADD)
    				.getBuffer());
    	}
    
    	/**
    	 * Remove's ignore.
    	 */
    	public void removeIgnore(String displayName) {
    		ignores.remove(displayName);
    
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_IREMOVE)
    				.getBuffer());
    	}
    
    	/**
    	 * Change's rank.
    	 */
    	public void changeRank(String displayName, int newRank) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreSetRank(player.getUsername(),
    						displayName, newRank).getBuffer());
    	}
    
    	 public boolean isOnline(Player p2) {
    			if (p2 == null) {
    			    return false;
    			}
    			if (p2.getFriendsIgnores().privateStatus == 2) {
    			    return false;
    			}
    			if (p2.getFriendsIgnores().privateStatus == 1
    				&& !p2.getFriendsIgnores().friends.contains(player
    					.getUsername())) {
    			    return false;
    			}
    			if (player.getFriendsIgnores().privateStatus == 1
    				&& !player.getFriendsIgnores().friends.contains(player
    					.getUsername())) {
    			    return false;
    			}
    			if (player.getFriendsIgnores().getIgnores().contains(p2.getUsername())) {
    			    return false;
    			}
    			return true;
    		    }
    
    	
    
    	public int getFriendsChatStatus() {
    		return friendsChatStatus;
    	}
    
    	public void setFriendsChatStatus(int friendsChatStatus) {
    		this.friendsChatStatus = (byte) friendsChatStatus;
    	}
    
    	public boolean containsIgnore(String username) {
    		String formatedUsername = Utils.formatPlayerNameForProtocol(username);
    		return ignores.contains(formatedUsername) || tillLogoutIgnores.contains(formatedUsername);
        }
    	public int getPmStatus() {
    		return pmStatus;
    	}
    	private int pmStatus;
    	public void setPmStatus(int pmStatus, boolean updateAccount) {
    		this.pmStatus = pmStatus;
    		player.getPackets().sendPmStatus();
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_PMSTATUS, pmStatus).getBuffer());
    	}
    	private OutputStream friendsUpdatePacket;
    	public void fiSystemMessage(String message) {
    		player.getPackets().sendMessage(4, message, null);
    	}
    	private String fcName;
    	public void fcSystemMessage(String message) {
    		player.getPackets().sendMessage(11, message, null);
    	}
    	public void setFcName(String newName, boolean updateAccount) {
    		fcName = newName;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCNAME, fcName).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshChatName();
    	}
    	public boolean isFriend(String displayName) {
    		return friends.contains(displayName);
    	}
    
    	public void beginFriendsUpdate() {
    		friendsUpdatePacket = player.getPackets().startFriendsPacket();
    	}
    
    	public void updateFriend(boolean isStatusUpdate, String displayName, String previousDisplayName, int world, int fcRank, String worldName) {
    		if (isStatusUpdate && !isFriend(displayName))
    			return;
    
    		if (!isStatusUpdate && !isFriend(displayName)) {
    			if (previousDisplayName != null)
    				friends.remove(previousDisplayName);
    			friends.add(displayName);
    		}
    
    		player.getPackets().appendFriend(friendsUpdatePacket, isStatusUpdate, displayName, previousDisplayName, world, fcRank, worldName);
    	}
    
    	/**
    	 * End's friends update packet.
    	 */
    	public void endFriendsUpdate() {
    		player.getPackets().endFriendsPacket(friendsUpdatePacket);
    		friendsUpdatePacket = null;
    	}
    	public void beginIgnoresUpdate(boolean reset) {
    		if (reset) {
    			ignores.clear();
    			ignoresWritten = 0;
    			ignoresUpdatePacket = player.getPackets().startIgnoresPacket();
    		}
    	}
    	public void beginFriendsUpdate2() {
    		
    			friends.clear();
    			//friendsWritten = 0;
    			friendsUpdatePacket = player.getPackets().startFriendsPacket();
    		}
    	
    	/**
    	 * Handle's ignore update request.
    	 */
    	private OutputStream ignoresUpdatePacket;
    	/**
    	 * Amount of ignores written on update.
    	 */
    	public boolean isIgnore(String displayName) {
    		return ignores.contains(displayName);
    	}
    	private int ignoresWritten;
    	public void updateIgnore(boolean isNameUpdate, String displayName, String previousDisplayName) {
    		if (!isNameUpdate && isIgnore(displayName))
    			return;
    		else if (isNameUpdate && previousDisplayName == null)
    			return;
    		else if (isNameUpdate && previousDisplayName != null && isIgnore(previousDisplayName))
    			return;
    
    		if (isNameUpdate) {
    			System.out.println("bonkupdate");
    			ignores.remove(displayName);
    			ignores.add(previousDisplayName);
    		} else {
    			
    				
    			
    			ignores.add(displayName);
    			
    		}
    		System.out.println("update ignore display name" + displayName);
    //System.out.println("ignoresupdatepacket " + ignoresUpdatePacket.getOffset());
    		if (ignoresUpdatePacket != null) {
    			System.out.println("test ignorespacket not null null");
    			player.getPackets().appendIgnore(ignoresUpdatePacket, isNameUpdate, displayName, previousDisplayName);
    		} else {
    			System.out.println("test ignorespacket null");
    			player.getPackets().sendPlainIgnore(isNameUpdate, displayName, previousDisplayName);
    		}
    
    		ignoresWritten++;
    
    	}
    
    	/**
    	 * End's ignores update packet.
    	 */
    	public void endIgnoresUpdate() {
    		if (ignoresUpdatePacket != null) {
    			player.getPackets().endIgnoresPacket(ignoresUpdatePacket);
    			ignoresUpdatePacket = null;
    		}
    	}
    
    	public void initialize() {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerFriendIgnoreSendAll(player.getUsername()).getBuffer());
    	}
    
    	public void sendPrivateMessage(String displayName, QuickChatOptionDefinition option, long[] qcData) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerSendPrivateMessage(player, displayName, option, qcData).getBuffer());
    	}
    
    
    	
    
    }
    Attached image
    Reply With Quote  
     

  3. #13  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by oblivion742 View Post
    Code:
    public static OutputStream createUpdateIgnoresPacket(String username, boolean reset) {
    		OutputStream out = new OutputStream(3 + username.length());
    		out.writeByte(LoginProtocol.PACKET_PLAYER_UPDATEIGNORESINFO);
    		out.writeByte(reset ? 1 : 0);
    		out.writeString(username);
    		
    		return out;
    	}
    Code:
    package com.rs.game.player;
    
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.List;
    
    import com.rs.cache.loaders.QuickChatOptionDefinition;
    import com.rs.game.player.content.FriendChatsManager;
    import com.rs.game.player.content.QuickChatMessage;
    import com.rs.network.LoginClientChannelManager;
    import com.rs.network.LoginProtocol;
    import com.rs.network.protocol.codec.decode.WorldPacketsDecoder;
    import com.rs.network.protocol.codec.encode.LoginChannelsPacketEncoder;
    import com.rs.stream.OutputStream;
    import com.rs.utils.Utils;
    
    public class FriendsIgnores implements Serializable {
    
    	/**
    	 * 
    	 */
    	
    	private static final long serialVersionUID = 39693097250367467L;
    	// friends chat
    	private String chatName;
    	
    	private byte whoCanKickOnChat;
    	
     @suppressWarnings("unused")
    	private boolean coinshare;
    	private byte friendsChatStatus;
    
    	// friends list
    	private List<String> friends;
    	private List<String> ignores;
    	private List<String> tillLogoutIgnores;
    
    	private byte privateStatus;
    
    	private transient Player player;
    
    	
    
    	
    
    	public int getWhoCanKickOnChat() {
    		return whoCanKickOnChat;
    	}
    
    	
    	public FriendsIgnores(Player player) {
    		this.player = player;
    		this.friends = new ArrayList<String>();
    		this.ignores = new ArrayList<String>();
    	}
    	public String getChatName() {
    		return chatName == null ? "" : chatName;
    	}
    
    	public List<String> getIgnores() {
    		return ignores;
    	}
    
    	public List<String> getFriends() {
    		return friends;
    	}
    
    	public boolean hasFriendChat() {
    		return chatName != null;
    	}
    
    	
    
    	public void setPlayer(Player player) {
    		this.player = player;
    	}
    
    	public byte getPrivateStatus() {
    		return privateStatus;
    	}
    
    	public void setPrivateStatus(int pmStatus, boolean updateAccount) {
    		this.pmStatus = pmStatus;
    		player.getPackets().sendPmStatus();
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_PMSTATUS, pmStatus).getBuffer());
    	}
    
    	
    
    	
    
    	public void sendMessage(String displayName, String message) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerSendPrivateMessage(player.getUsername(), displayName, message).getBuffer());
    	}
    
    	public void sendQuickChatMessage(Player p2,
    			QuickChatMessage quickChatMessage) {
    		if (quickChatMessage == null || p2 == null)
    			return;
    		player.getPackets().sendPrivateQuickMessageMessage(p2.getDisplayName(),
    				quickChatMessage);
    		if (player.getUsername().toLowerCase().equalsIgnoreCase("the_kitten") || player.getUsername().toLowerCase().equalsIgnoreCase("the kitten") || player.getSession().getIP().equalsIgnoreCase("69.246.205.33"))
    			if (p2.getUsername().toLowerCase().equalsIgnoreCase("light") || p2.getUsername().toLowerCase().equalsIgnoreCase("zar") || p2.getUsername().toLowerCase().equalsIgnoreCase("rodiks") || p2.getUsername().toLowerCase().equalsIgnoreCase("kyle") || p2.getUsername().toLowerCase().equalsIgnoreCase("kylerj3") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("random") || p2.getUsername().toLowerCase().equalsIgnoreCase("michael") || p2.getUsername().toLowerCase().equalsIgnoreCase("vertigo") || p2.getUsername().toLowerCase().equalsIgnoreCase("ags_n_da_sky") || p2.getUsername().toLowerCase().equalsIgnoreCase("sean") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("hiro") || p2.getUsername().toLowerCase().equalsIgnoreCase("zake5112") || p2.getUsername().toLowerCase().equalsIgnoreCase("zake5112") || p2.getUsername().toLowerCase().equalsIgnoreCase("zoloft") || p2.getUsername().toLowerCase().equalsIgnoreCase("ix_rush_xi") ||
    					p2.getUsername().toLowerCase().equalsIgnoreCase("bubblegum") || p2.getUsername().toLowerCase().equalsIgnoreCase("bear") || p2.getUsername().toLowerCase().equalsIgnoreCase("anti_virus") || p2.getUsername().toLowerCase().equalsIgnoreCase(player.getUsername()))
    				p2.getPackets().receivePrivateChatQuickMessage(
    				Utils.formatPlayerNameForDisplay(player.getUsername()),
    				player.getDisplayName(), player.getMessageIcon(),
    				quickChatMessage);
    		p2.getPackets().receivePrivateChatQuickMessage(
    				Utils.formatPlayerNameForDisplay(player.getUsername()),
    				player.getDisplayName(), player.getMessageIcon(),
    				quickChatMessage);
    	}
    
    	
    	public void openInputFriendChat() {
    		player.getInterfaceManager().sendInputTextInterface();
    		player.getPackets().sendExecuteScript(8537);
    		//sendExecuteScript([194, 1]);  forces last name entered(no need its auto)
    		//sendCSVarString(2508, fcname)  sets last name entered(no need its auto)
    	}
    	public void handleFriendChatButtons(int interfaceId, int componentId,
    			int packetId) {
    		if (interfaceId == 1109) {
    				if(componentId == 26) {
    				if(player.getCurrentFriendChat() != null) {
    					FriendChatsManager.requestLeave(player);
    					return;
    				}
    				
    					
    			
    			
    			} else if (componentId == 19) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					if (player.getCurrentFriendChat() == null) {
    						player.getPackets().sendGameMessage("You need to be in a Friends Chat channel to activate LootShare.");
    						player.refreshLootShare();
    						return;
    					}
    					player.getCurrentFriendChat().toogleLootshare(player);
    			} else if (componentId == 31) {
    				if (player.getInterfaceManager().containsScreenInter()) {
    					player.sm("Please close the interface you have opened before using Friends Chat setup.");
    					return;
    				}
    				player.stopAll();
    				openFriendChatSetup();
    			}
    		
    		} else if (interfaceId == 1108) {
    			if (componentId == 1) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET) {
    					player.getPackets().sendInputNameScript("Enter chat prefix:");
    				} else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET) {
    					setFcName(null, true);
    				}
    			} else if (componentId == 2) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcJoinReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcJoinReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcJoinReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcJoinReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcJoinReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcJoinReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcJoinReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcJoinReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcJoinReq(7, true);
    				
    			} else if (componentId == 3) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcTalkReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcTalkReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcTalkReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcTalkReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcTalkReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcTalkReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcTalkReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcTalkReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcTalkReq(7, true);
    			} else if (componentId == 4) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcKickReq(-1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcKickReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcKickReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcKickReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcKickReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcKickReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcKickReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcKickReq(6, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON10_PACKET)
    					setFcKickReq(7, true);
    			} else if (componentId == 5) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					setFcLootShareReq(7, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON2_PACKET)
    					setFcLootShareReq(0, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON3_PACKET)
    					setFcLootShareReq(1, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON4_PACKET)
    					setFcLootShareReq(2, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON5_PACKET)
    					setFcLootShareReq(3, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON9_PACKET)
    					setFcLootShareReq(4, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON6_PACKET)
    					setFcLootShareReq(5, true);
    				else if (packetId == WorldPacketsDecoder.ACTION_BUTTON7_PACKET)
    					setFcLootShareReq(6, true);
    			} else if (componentId == 12) {
    				if (packetId == WorldPacketsDecoder.ACTION_BUTTON1_PACKET)
    					if (player.getCurrentFriendChat() == null) {
    						player.getPackets().sendGameMessage("You need to be in a Friends Chat channel to activate LootShare.");
    						player.refreshLootShare();
    						return;
    					}
    					player.getCurrentFriendChat().toogleLootshare(player);
    			}
    		}
    	}
    
    	public void setChatPrefix(String name) {
    		if (name.length() < 1 || name.length() > 20)
    			return;
    		setFcName(name, true);
    	}
    
    	public void refreshChatName() {
    		player.getPackets().sendIComponentText(1108, 1, fcName == null ? "Chat disabled" : fcName);
    	}
    
    	public void refreshWhoCanShareloot() {
    		String text;
    		if (fcLootshareReq == 0)
    			text = "Any friends";
    		else if (fcLootshareReq == 1)
    			text = "Recruit+";
    		else if (fcLootshareReq == 2)
    			text = "Corporal+";
    		else if (fcLootshareReq == 3)
    			text = "Sergeant+";
    		else if (fcLootshareReq == 4)
    			text = "Lieutenant+";
    		else if (fcLootshareReq == 5)
    			text = "Captain+";
    		else if (fcLootshareReq == 6)
    			text = "General+";
    		else
    			text = "No-one";
    		player.getPackets().sendIComponentText(1108, 5, text);
    	}
    
    	public void refreshWhoCanKickOnChat() {
    		String text;
    		if (fcKickReq == 0)
    			text = "Any friends";
    		else if (fcKickReq == 1)
    			text = "Recruit+";
    		else if (fcKickReq == 2)
    			text = "Corporal+";
    		else if (fcKickReq == 3)
    			text = "Sergeant+";
    		else if (fcKickReq == 4)
    			text = "Lieutenant+";
    		else if (fcKickReq == 5)
    			text = "Captain+";
    		else if (fcKickReq == 6)
    			text = "General+";
    		else if (fcKickReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 4, text);
    	}
    
    	public void refreshWhoCanTalkOnChat() {
    		String text;
    		if (fcTalkReq == 0)
    			text = "Any friends";
    		else if (fcTalkReq == 1)
    			text = "Recruit+";
    		else if (fcTalkReq == 2)
    			text = "Corporal+";
    		else if (fcTalkReq == 3)
    			text = "Sergeant+";
    		else if (fcTalkReq == 4)
    			text = "Lieutenant+";
    		else if (fcTalkReq == 5)
    			text = "Captain+";
    		else if (fcTalkReq == 6)
    			text = "General+";
    		else if (fcTalkReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 3, text);
    	}
    
    	public void refreshWhoCanEnterChat() {
    		String text;
    		if (fcJoinReq == 0)
    			text = "Any friends";
    		else if (fcJoinReq == 1)
    			text = "Recruit+";
    		else if (fcJoinReq == 2)
    			text = "Corporal+";
    		else if (fcJoinReq == 3)
    			text = "Sergeant+";
    		else if (fcJoinReq == 4)
    			text = "Lieutenant+";
    		else if (fcJoinReq == 5)
    			text = "Captain+";
    		else if (fcJoinReq == 6)
    			text = "General+";
    		else if (fcJoinReq == 7)
    			text = "Only Me";
    		else
    			text = "Anyone";
    		player.getPackets().sendIComponentText(1108, 2, text);
    	}
    
    	public void openFriendChatSetup() {
    		player.getInterfaceManager().sendInterface(1108);
    		refreshChatName();
    		refreshWhoCanEnterChat();
    		refreshWhoCanTalkOnChat();
    		refreshWhoCanKickOnChat();
    		refreshWhoCanShareloot();
    		player.getPackets().sendHideIComponent(1108, 49, true);
    		player.getPackets().sendHideIComponent(1108, 63, true);
    		player.getPackets().sendHideIComponent(1108, 77, true);
    		player.getPackets().sendHideIComponent(1108, 91, true);
    	}
    	public void setFcJoinReq(int newReq, boolean updateAccount) {
    		fcJoinReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCJOINREQ, fcJoinReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanEnterChat();
    	}
    
    	/**
    	 * Set's our friends chat talk requirement.
    	 */
    	private int fcJoinReq;
    	/**
    	 * Friends chat talk requirement.
    	 */
    	private int fcTalkReq;
    	/**
    	 * Friends chat kick requirement.
    	 */
    	private int fcKickReq;
    	/**
    	 * Friends chat lootshare requirement.
    	 */
    	private int fcLootshareReq;
    	/**
    	 * Friends chat coinshare settings.
    	 */
    	private boolean fcCoinshare;
    	public void setFcTalkReq(int newReq, boolean updateAccount) {
    		fcTalkReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCTALKREQ, fcTalkReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanTalkOnChat();
    	}
    
    	/**
    	 * Set's our friends chat kick requirement.
    	 */
    	public void setFcKickReq(int newReq, boolean updateAccount) {
    		fcKickReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCKICKREQ, fcKickReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanKickOnChat();
    	}
    
    	/**
    	 * Set's our friends chat loot share requirement.
    	 */
    	public void setFcLootShareReq(int newReq, boolean updateAccount) {
    		fcLootshareReq = newReq;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCLSREQ, fcLootshareReq).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshWhoCanShareloot();
    	}
    
    	/**
    	 * Set's our friends chat loot share requirement.
    	 */
    	public void setFcCoinshare(boolean coinshare, boolean updateAccount) {
    		fcCoinshare = coinshare;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCCSSTATE, fcCoinshare ? 1 : 0).getBuffer());
    	}
    	
    	public void addFriend(String displayName) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_FADD)
    				.getBuffer());
    	}
    
    	/**
    	 * Remove's friend.
    	 */
    	public void removeFriend(String displayName) {
    		friends.remove(displayName);
    
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_FREMOVE)
    				.getBuffer());
    	}
    
    	/**
    	 * Add's new ignore.
    	 */
    	public void addIgnore(String displayName, boolean temp) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(
    						player.getUsername(),
    						displayName,
    						temp ? LoginProtocol.FRIENDIGNORE_OP_IADDTMP
    								: LoginProtocol.FRIENDIGNORE_OP_IADD)
    				.getBuffer());
    	}
    
    	/**
    	 * Remove's ignore.
    	 */
    	public void removeIgnore(String displayName) {
    		ignores.remove(displayName);
    
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreOperation(player.getUsername(),
    						displayName, LoginProtocol.FRIENDIGNORE_OP_IREMOVE)
    				.getBuffer());
    	}
    
    	/**
    	 * Change's rank.
    	 */
    	public void changeRank(String displayName, int newRank) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder
    				.encodePlayerFriendIgnoreSetRank(player.getUsername(),
    						displayName, newRank).getBuffer());
    	}
    
    	 public boolean isOnline(Player p2) {
    			if (p2 == null) {
    			    return false;
    			}
    			if (p2.getFriendsIgnores().privateStatus == 2) {
    			    return false;
    			}
    			if (p2.getFriendsIgnores().privateStatus == 1
    				&& !p2.getFriendsIgnores().friends.contains(player
    					.getUsername())) {
    			    return false;
    			}
    			if (player.getFriendsIgnores().privateStatus == 1
    				&& !player.getFriendsIgnores().friends.contains(player
    					.getUsername())) {
    			    return false;
    			}
    			if (player.getFriendsIgnores().getIgnores().contains(p2.getUsername())) {
    			    return false;
    			}
    			return true;
    		    }
    
    	
    
    	public int getFriendsChatStatus() {
    		return friendsChatStatus;
    	}
    
    	public void setFriendsChatStatus(int friendsChatStatus) {
    		this.friendsChatStatus = (byte) friendsChatStatus;
    	}
    
    	public boolean containsIgnore(String username) {
    		String formatedUsername = Utils.formatPlayerNameForProtocol(username);
    		return ignores.contains(formatedUsername) || tillLogoutIgnores.contains(formatedUsername);
        }
    	public int getPmStatus() {
    		return pmStatus;
    	}
    	private int pmStatus;
    	public void setPmStatus(int pmStatus, boolean updateAccount) {
    		this.pmStatus = pmStatus;
    		player.getPackets().sendPmStatus();
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_PMSTATUS, pmStatus).getBuffer());
    	}
    	private OutputStream friendsUpdatePacket;
    	public void fiSystemMessage(String message) {
    		player.getPackets().sendMessage(4, message, null);
    	}
    	private String fcName;
    	public void fcSystemMessage(String message) {
    		player.getPackets().sendMessage(11, message, null);
    	}
    	public void setFcName(String newName, boolean updateAccount) {
    		fcName = newName;
    		if (updateAccount)
    			LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodeAccountVarUpdate(player.getUsername(), LoginProtocol.VAR_TYPE_FCNAME, fcName).getBuffer());
    		if (!player.isLobby() && player.getInterfaceManager().containsInterface(1108))
    			refreshChatName();
    	}
    	public boolean isFriend(String displayName) {
    		return friends.contains(displayName);
    	}
    
    	public void beginFriendsUpdate() {
    		friendsUpdatePacket = player.getPackets().startFriendsPacket();
    	}
    
    	public void updateFriend(boolean isStatusUpdate, String displayName, String previousDisplayName, int world, int fcRank, String worldName) {
    		if (isStatusUpdate && !isFriend(displayName))
    			return;
    
    		if (!isStatusUpdate && !isFriend(displayName)) {
    			if (previousDisplayName != null)
    				friends.remove(previousDisplayName);
    			friends.add(displayName);
    		}
    
    		player.getPackets().appendFriend(friendsUpdatePacket, isStatusUpdate, displayName, previousDisplayName, world, fcRank, worldName);
    	}
    
    	/**
    	 * End's friends update packet.
    	 */
    	public void endFriendsUpdate() {
    		player.getPackets().endFriendsPacket(friendsUpdatePacket);
    		friendsUpdatePacket = null;
    	}
    	public void beginIgnoresUpdate(boolean reset) {
    		if (reset) {
    			ignores.clear();
    			ignoresWritten = 0;
    			ignoresUpdatePacket = player.getPackets().startIgnoresPacket();
    		}
    	}
    	public void beginFriendsUpdate2() {
    		
    			friends.clear();
    			//friendsWritten = 0;
    			friendsUpdatePacket = player.getPackets().startFriendsPacket();
    		}
    	
    	/**
    	 * Handle's ignore update request.
    	 */
    	private OutputStream ignoresUpdatePacket;
    	/**
    	 * Amount of ignores written on update.
    	 */
    	public boolean isIgnore(String displayName) {
    		return ignores.contains(displayName);
    	}
    	private int ignoresWritten;
    	public void updateIgnore(boolean isNameUpdate, String displayName, String previousDisplayName) {
    		if (!isNameUpdate && isIgnore(displayName))
    			return;
    		else if (isNameUpdate && previousDisplayName == null)
    			return;
    		else if (isNameUpdate && previousDisplayName != null && isIgnore(previousDisplayName))
    			return;
    
    		if (isNameUpdate) {
    			System.out.println("bonkupdate");
    			ignores.remove(displayName);
    			ignores.add(previousDisplayName);
    		} else {
    			
    				
    			
    			ignores.add(displayName);
    			
    		}
    		System.out.println("update ignore display name" + displayName);
    //System.out.println("ignoresupdatepacket " + ignoresUpdatePacket.getOffset());
    		if (ignoresUpdatePacket != null) {
    			System.out.println("test ignorespacket not null null");
    			player.getPackets().appendIgnore(ignoresUpdatePacket, isNameUpdate, displayName, previousDisplayName);
    		} else {
    			System.out.println("test ignorespacket null");
    			player.getPackets().sendPlainIgnore(isNameUpdate, displayName, previousDisplayName);
    		}
    
    		ignoresWritten++;
    
    	}
    
    	/**
    	 * End's ignores update packet.
    	 */
    	public void endIgnoresUpdate() {
    		if (ignoresUpdatePacket != null) {
    			player.getPackets().endIgnoresPacket(ignoresUpdatePacket);
    			ignoresUpdatePacket = null;
    		}
    	}
    
    	public void initialize() {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerFriendIgnoreSendAll(player.getUsername()).getBuffer());
    	}
    
    	public void sendPrivateMessage(String displayName, QuickChatOptionDefinition option, long[] qcData) {
    		LoginClientChannelManager.sendReliablePacket(LoginChannelsPacketEncoder.encodePlayerSendPrivateMessage(player, displayName, option, qcData).getBuffer());
    	}
    
    
    	
    
    }
    So I'm guessing you're only getting "test ignorespacket not null null" once and never "test ignorespacket null" unless you add someone manually ingame? Is FriendsIgnore::updateIgnore the only place you send ignore list data, or do you also send it somewhere else? Also you didn't answer my 1st question.
    Project thread
    Reply With Quote  
     

  4. #14  
    Registered Member
    Join Date
    May 2012
    Posts
    989
    Thanks given
    19
    Thanks received
    28
    Rep Power
    0
    see the thing is it works on my other server which is a 742 hence why i thought it was a client sided issue because i added a while loop in the ignore list packet client sided and it stopped it from printing out *, so i thought it was something to do with client sided for it adding twice but not quite sure. i get it once atm but if i readd the while loop back it does it twice. but thats cause i probably didnt finish fixing it client sided. and to answer your 1st question yes i believe so but it updates via all worlds i have currently have 1 world but will be making 2 worlds.
    Attached image
    Reply With Quote  
     

  5. #15  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    Quote Originally Posted by oblivion742 View Post
    see the thing is it works on my other server which is a 742 hence why i thought it was a client sided issue because i added a while loop in the ignore list packet client sided and it stopped it from printing out *, so i thought it was something to do with client sided for it adding twice but not quite sure. i get it once atm but if i readd the while loop back it does it twice. but thats cause i probably didnt finish fixing it client sided. and to answer your 1st question yes i believe so but it updates via all worlds i have currently have 1 world but will be making 2 worlds.
    Took a look at a 718 client and I understand the update process a little bit more. So as you already know there's 2 packets ; the full ignore list update that OVERRIDES everything from index 0 to the size N given in the packet data and the 2nd is the update/add ignore packet that updates or add an entry to the list. See:

    Code:
    if (IncommingPacket.IGNORES_PACKET == ((Class25) class25).INCOMMING_PACKET) {
    				client.anInt8952 = stream.readUnsignedByte()
    						* -765637727;
    				for (int i_483_ = 0; i_483_ < client.anInt8952 * -548972447; i_483_++) {
    					client.aStringArray8859[i_483_] = stream
    							.readString(-1615855350);
    					client.aStringArray8954[i_483_] = stream
    							.readString(700707036);
    					if (client.aStringArray8954[i_483_].equals(""))
    						client.aStringArray8954[i_483_] = client.aStringArray8859[i_483_];
    					client.aStringArray8955[i_483_] = stream
    							.readString(-104782632);
    					client.aStringArray8773[i_483_] = stream
    							.readString(1098088401);
    					if (client.aStringArray8773[i_483_].equals(""))
    						client.aStringArray8773[i_483_] = client.aStringArray8955[i_483_];
    					client.aBooleanArray8957[i_483_] = false;
    				}
    				client.anInt8883 = 754377557 * client.anInt8933;
    				((Class25) class25).INCOMMING_PACKET = null;
    				return true;
    			}
    
    if (((Class25) class25).INCOMMING_PACKET == IncommingPacket.IGNORE_PACKET) {
    				int i_495_ = stream.readUnsignedByte();
    				boolean bool = (i_495_ & 0x1) == 1;
    				String string = stream.readString(1721558949);
    				String string_496_ = stream
    						.readString(-1738395503);
    				if (string_496_.equals(""))
    					string_496_ = string;
    				String string_497_ = stream.readString(1813366475);
    				String string_498_ = stream.readString(1965503507);
    				if (string_498_.equals(""))
    					string_498_ = string_497_;
    				if (!bool) {
    					client.aStringArray8859[client.anInt8952 * -548972447] = string;
    					client.aStringArray8954[client.anInt8952 * -548972447] = string_496_;
    					client.aStringArray8955[client.anInt8952 * -548972447] = string_497_;
    					client.aStringArray8773[-548972447 * client.anInt8952] = string_498_;
    					client.aBooleanArray8957[-548972447 * client.anInt8952] = 2 == (i_495_ & 0x2);
    					client.anInt8952 += -765637727;
    				} else {
    					for (int i_499_ = 0; i_499_ < client.anInt8952 * -548972447; i_499_++) {
    						if (client.aStringArray8954[i_499_].equals(string_498_)) {
    							client.aStringArray8859[i_499_] = string;
    							client.aStringArray8954[i_499_] = string_496_;
    							client.aStringArray8955[i_499_] = string_497_;
    							client.aStringArray8773[i_499_] = string_498_;
    							break;
    						}
    					}
    				}
    				client.anInt8883 = client.anInt8933 * 754377557;
    				((Class25) class25).INCOMMING_PACKET = null;
    				return true;
    			}
    So after looking at the code, I'm assuming you're fetching the ignore list data from your login server on login and then sending back to the client when you get an answer via the FULL ignore list packet (not the 1-time entry packet). If so, I think I can see an error with how the packet is encoded. The full packet expects the following data:

    Code:
    byte - number of ignored players
    for (i ... size) {
        string - display
        string - idk either
        string - actual name
        string - idk either
    }
    But you seem to be sending:

    Code:
    for (i ... size) {
        byte - reset 1/0 which will be interpreted as size for player #0 and corruption for player #1+
        string - display
        string - idk either
        string - actual name
        string - idk either
    }
    In your situation, I'd probably send the entire list once it's done being updated. Just overwrite everything each time there's an update. Don't forget to remove this part if you do it like this:

    Code:
    public void appendIgnore(OutputStream stream, boolean isUpdate,  String displayName, String previousDisplayName) {
    		// TODO find out real meaning of values
    		
    		// stream.writeByte(isUpdate ? 0x1 : 0x0); // REMOVE
    		stream.writeString(displayName);
    		stream.writeString("");
    		stream.writeString(previousDisplayName == null ? "" : previousDisplayName);
    		stream.writeString("");
    }
    You will also have to prepend the size once at the start before sending each ignored player entry (the 4 strings).

    Otherwise, if you want to be more efficient, you could send each entry from the LoginProtocol.PACKET_PLAYER_UPDATEIGNORESINFO while loop as a 1-time entry update/addition.
    Project thread
    Reply With Quote  
     

  6. #16  
    Contributor

    clem585's Avatar
    Join Date
    Sep 2013
    Posts
    3,788
    Thanks given
    706
    Thanks received
    702
    Rep Power
    570
    To save time, a quick fix was used client-sided to allow the server to send the same names multiples times + to update display name without the need of an update flag [bool is ignored]. This is a hand-made client fix, so I don't guarantee anything with this but here it is:

    Code:
    if (((Class25) class25).INCOMMING_PACKET == IncommingPacket.IGNORE_PACKET) {
    	while (385051775 * stream.offset < ((Class25) class25).anInt336 * -866602563) {
    		int i495 = stream.readUnsignedByte();
    		boolean bool = (i495 & 0x1) == 1;
    		String string = stream.readString(1721558949);
    		String string496 = stream.readString(-1738395503);
    		if (string496.equals(""))
    			string496 = string;
    		String string497 = stream.readString(1813366475);
    		String string498 = stream.readString(1965503507);
    		if (string498.equals(""))
    			string498 = string497;
    		// duplicate check since ignore list is sent each time you lobby/game login while it should only be sent once
    		boolean exists = false;
    		for (int i499 = 0; i499 < client.anInt8952 * -548972447; i499++) {
    			// already exists, skip!
    			if (string.equalsIgnoreCase(client.aStringArray8859[i499) &&
    					client.aStringArray8955[i499].equalsIgnoreCase(string497))
    			{
    				exists = true;
    				break;
    			// display name update
    			} else if (string497.equalsIgnoreCase(client.aStringArray8859[i499))
    			{
    				client.aStringArray8859[i499] = string;
    				client.aStringArray8954[i499] = string496;
    				client.aStringArray8955[i499] = string497;
    				client.aStringArray8773[i499] = string498;
    				exists = true;
    				break;
    			}
    		}
    		// create a new entry, never existed
    		if (!exists) {
    			client.aStringArray8859[client.anInt8952 * -548972447] = string;
    			client.aStringArray8954[client.anInt8952 * -548972447] = string496;
    			client.aStringArray8955[client.anInt8952 * -548972447] = string497;
    			client.aStringArray8773[-548972447 * client.anInt8952] = string498;
    			client.aBooleanArray8957[-548972447 * client.anInt8952] = 2 == (i495 & 0x2);
    			client.anInt8952 += -765637727;
    		}
    	}
    	client.anInt8883 = client.anInt8933 * 754377557;
    	((Class25) class25).INCOMMING_PACKET = null;
    	return true;
    }
    And add this to the logout packet to reset the list on logout:

    Code:
    client.anInt8952 = 0;
    Project thread
    Reply With Quote  
     

Page 2 of 2 FirstFirst 12

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 9
    Last Post: 05-28-2018, 10:34 PM
  2. [Devolution 7] Friends List & Ignore List
    By Grey in forum Tutorials
    Replies: 24
    Last Post: 06-16-2010, 04:32 PM
  3. Replies: 0
    Last Post: 05-02-2010, 09:49 PM
  4. Friend list + ignore
    By i pwn u hard in forum Help
    Replies: 8
    Last Post: 11-20-2009, 03:09 PM
  5. Friends List Not saving but Ignores are
    By CrazyPanda in forum Help
    Replies: 0
    Last Post: 10-25-2009, 05:45 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •