User can no longer ignore staffs

This commit is contained in:
Swirny 2020-05-19 14:26:45 +02:00 committed by Mike
parent 1afca5c0a0
commit 60a63e4832
2 changed files with 22 additions and 11 deletions

View File

@ -8,4 +8,8 @@ INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('flood.with.rights', '0
ALTER TABLE `permissions` ADD `cmd_softkick` ENUM('0', '1') NOT NULL DEFAULT '0' AFTER `cmd_kickall`;
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_softkick', 'softkick');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_not_found', '%user% not found');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!');
-- Rank ignoring
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.error.higher_rank', 'You can\'t ignore this user.');
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.ignore.staffs', '0');

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.users;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.achievements.TalentTrackType;
@ -602,17 +603,23 @@ public class HabboStats implements Runnable {
return 0;
}
public void ignoreUser(int userId) {
if (!this.userIgnored(userId)) {
this.ignoredUsers.add(userId);
public void ignoreUser(GameClient gameClient, int userId) {
Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (target.getHabboInfo().getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.error.higher_rank"), RoomChatMessageBubbles.ALERT);
}
else {
if (!this.userIgnored(userId)) {
this.ignoredUsers.add(userId);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
statement.setInt(1, this.habboInfo.getId());
statement.setInt(2, userId);
statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
statement.setInt(1, this.habboInfo.getId());
statement.setInt(2, userId);
statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
}
}