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:
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.