Thread: Player has logged in Notification

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Player has logged in Notification 
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    I'm trying to make it send a message that a player has logged in through PM, like most other servers have.

    Edit: Got it to work but it spams all online players at once when you log in:

    Attached image

    Code:

    Code:
    	/**
    	 * Updates the player's friend list.
    	 * @param online	If <code>true</code>, the players who have this player added, will be sent the notification this player has logged in.
    	 * @return			The PlayerRelations instance.
    	 */
    	public PlayerRelations updateLists(boolean online) {
    		if (status == PrivateChatStatus.OFF)
    			online = false;
    		player.getPacketSender().sendFriendStatus(2);
    		for (Player players : World.getPlayers()) {
    			if(players == null)
    				continue;
    			boolean temporaryOnlineStatus = online;
    			if (players.getRelations().friendList.contains(player.getLongUsername())) {
    				if (status.equals(PrivateChatStatus.FRIENDS_ONLY) && !friendList.contains(players.getLongUsername()) ||
    						status.equals(PrivateChatStatus.OFF) || ignoreList.contains(players.getLongUsername())) {
    					temporaryOnlineStatus = false;
    				}
    				players.getPacketSender().sendFriend(player.getLongUsername(), temporaryOnlineStatus ? 1 : 0);
    			}
    			boolean tempOn = true;
    			if (player.getRelations().friendList.contains(players.getLongUsername())) {
    				if (players.getRelations().status.equals(PrivateChatStatus.FRIENDS_ONLY) && !players.getRelations().getFriendList().contains(player.getLongUsername()) ||
    						players.getRelations().status.equals(PrivateChatStatus.OFF) || players.getRelations().getIgnoreList().contains(player.getLongUsername())) {
    					tempOn = false;
    				}
    				player.getPacketSender().sendFriend(players.getLongUsername(), tempOn ? 1 : 0);
    			}	
    		}
    		return this;
    	}
    	
    	public void sendStatus() {
    		int privateChat = status == PrivateChatStatus.OFF ? 2 : status == PrivateChatStatus.FRIENDS_ONLY ? 1 : 0;
    		player.getPacketSender().sendChatOptions(0, privateChat, 0);
    	}
    
    	public void sendFriends() {
    		for(int i = 0; i < player.getRelations().getFriendList().size(); i++) {
    			player.getPacketSender().sendFriend(player.getRelations().getFriendList().get(i), 0);
    		}
    	}
    	
    	public PlayerRelations onLogin(Player player) {
    		player.getPacketSender().sendIgnoreList();
    		sendFriends();
    		sendStatus();
    		return this;
    	}
    Can't seem to get it to work,

    Thanks.
    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    Explain more carefully what the problem is.
    Does it spam to the player who's logging in with all the players who are currently logged in?
    Does it spam all players who are logged in with all players who are currently logged in?
    Explain. Not going to try to understand the code until I've understood the issue.
    Attached image
    Reply With Quote  
     

  3. #3  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by Kris View Post
    Explain more carefully what the problem is.
    Does it spam to the player who's logging in with all the players who are currently logged in?
    Does it spam all players who are logged in with all players who are currently logged in?
    Explain. Not going to try to understand the code until I've understood the issue.
    It spams the player that logs in with all of his friends that are online.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jan 2015
    Posts
    16
    Thanks given
    0
    Thanks received
    3
    Rep Power
    11
    Quote Originally Posted by Temperature View Post
    It spams the player that logs in with all of his friends that are online.
    Why not go about handling this in a different way such as in your initialize() method. Instead of checking for what friends are online constantly to send that message you can easily do it by sending the message when the player logs in it sends the message to his online friends.
    Reply With Quote  
     

  5. #5  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    just make it so the boolean returns false if they're not friends.

    Code:
    if (players.getRelations().friendList.contains(player.getLongUsername())) {
    return false
    }
    so its

    Code:
    	public PlayerRelations updateLists(boolean online) {
    		if (status == PrivateChatStatus.OFF || players.getRelations().friendList.contains(player.getLongUsername()))
    			online = false;
    ...
    }

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  6. #6  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by Eclipse View Post
    just make it so the boolean returns false if they're not friends.

    Code:
    if (players.getRelations().friendList.contains(player.getLongUsername())) {
    return false
    }
    so its

    Code:
    	public PlayerRelations updateLists(boolean online) {
    		if (status == PrivateChatStatus.OFF || players.getRelations().friendList.contains(player.getLongUsername()))
    			online = false;
    ...
    }
    They are friends, but already logged in. So they shouldn't show up.
    Reply With Quote  
     

  7. #7  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Code:
    players.getPacketSender().sendFriend(player.getLongUsername(), temporaryOnlineStatus ? 1 : 0);
    if(!temporaryOnlineStatus) {
    System.out.println("send online code!");
    }
    However idk why you wish to do this as this would be quite a spam for a player. Also it already tells you when someone logs in throw the friend list packet.
    If you are really sure you still want this, make it check the player that log in through the player load and have it only show to people that has the player on his / hers friendlist.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  8. #8  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by arch337 View Post
    Code:
    players.getPacketSender().sendFriend(player.getLongUsername(), temporaryOnlineStatus ? 1 : 0);
    if(!temporaryOnlineStatus) {
    System.out.println("send online code!");
    }
    However idk why you wish to do this as this would be quite a spam for a player. Also it already tells you when someone logs in throw the friend list packet.
    If you are really sure you still want this, make it check the player that log in through the player load and have it only show to people that has the player on his / hers friendlist.
    I don't want all that spam lol that's the whole problem. Also happens when you add a new friend.
    Reply With Quote  
     

  9. #9  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Quote Originally Posted by Temperature View Post
    I don't want all that spam lol that's the whole problem. Also happens when you add a new friend.
    Please explain how it is less spam, in my book it is equal as much spam.


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    Reply With Quote  
     

  10. #10  
    Jake from State Farm

    FKN Jake's Avatar
    Join Date
    Nov 2013
    Posts
    675
    Thanks given
    45
    Thanks received
    58
    Rep Power
    153
    Quote Originally Posted by arch337 View Post
    Please explain how it is less spam, in my book it is equal as much spam.
    All I'm saying is it shouldn't do this:

    https://gyazo.com/dabf5dc26f0f445e954c3df2007e16ad
    Reply With Quote  
     

Page 1 of 2 12 LastLast

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: 10
    Last Post: 04-01-2012, 05:32 AM
  2. [Pi] Player has Logged in Help
    By Rockstar Jax in forum Help
    Replies: 0
    Last Post: 05-21-2011, 06:58 PM
  3. Player Has Logged In
    By Defeat__ in forum Help
    Replies: 7
    Last Post: 05-20-2011, 12:46 AM
  4. Owner/Admin/Mod/Player Has Logged In! Snippet
    By Lation in forum Snippets
    Replies: 25
    Last Post: 05-22-2010, 08:11 PM
  5. Player has logged in in .cmd box!
    By Assassin2 in forum Configuration
    Replies: 10
    Last Post: 12-29-2008, 09:25 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •