Prevent adding yourself as a friend

This commit is contained in:
Alejandro 2020-06-07 15:21:29 +03:00
parent e40d8c4f99
commit 21c87145ea
2 changed files with 11 additions and 1 deletions

View File

@ -214,7 +214,13 @@ public class Messenger {
try (ResultSet set = statement.executeQuery()) { try (ResultSet set = statement.executeQuery()) {
while (set.next()) { while (set.next()) {
this.friends.putIfAbsent(set.getInt("id"), new MessengerBuddy(set)); MessengerBuddy buddy = new MessengerBuddy(set);
if (buddy.getId() == habbo.getHabboInfo().getId()) {
continue;
}
this.friends.putIfAbsent(set.getInt("id"), buddy);
} }
} }
} catch (SQLException e) { } catch (SQLException e) {

View File

@ -25,6 +25,10 @@ public class FriendRequestEvent extends MessageHandler {
String username = this.packet.readString(); String username = this.packet.readString();
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(username);
if (habbo.getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getId()) {
return;
}
if (Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, habbo)).isCancelled()) { if (Emulator.getPluginManager().fireEvent(new UserRequestFriendshipEvent(this.client.getHabbo(), username, habbo)).isCancelled()) {
this.client.sendResponse(new FriendRequestErrorComposer(2)); this.client.sendResponse(new FriendRequestErrorComposer(2));
return; return;