Merge branch '625-ignore-staff' into 'dev'

Resolve "User can ignore Habbo Staffs"

See merge request morningstar/Arcturus-Community!172
This commit is contained in:
Mike 2020-06-02 22:28:10 -04:00
commit c19ef29cf9
5 changed files with 38 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.ignore_higher_rank', 'You can\'t ignore this user.');
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staffs', '1');

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,7 +603,26 @@ public class HabboStats implements Runnable {
return 0;
}
public void ignoreUser(int userId) {
/**
* Ignore an user.
*
* @param gameClient The client to which this HabboStats instance belongs.
* @param userId The user to ignore.
* @return true if successfully ignored, false otherwise.
*/
public boolean ignoreUser(GameClient gameClient, int userId) {
final Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (!Emulator.getConfig().getBoolean("hotel.allow.ignore.staffs")) {
final int ownRank = gameClient.getHabbo().getHabboInfo().getRank().getId();
final int targetRank = target.getHabboInfo().getRank().getId();
if (targetRank >= ownRank) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.error.ignore_higher_rank"), RoomChatMessageBubbles.ALERT);
return false;
}
}
if (!this.userIgnored(userId)) {
this.ignoredUsers.add(userId);
@ -615,6 +635,8 @@ public class HabboStats implements Runnable {
LOGGER.error("Caught SQL exception", e);
}
}
return true;
}
public void unignoreUser(int userId) {

View File

@ -73,8 +73,9 @@ public class ReportEvent extends MessageHandler {
Emulator.getThreading().run(() -> {
if (issue.state == ModToolTicketState.OPEN) {
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(reported.getHabboInfo().getId());
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
if (ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(ReportEvent.this.client, reported.getHabboInfo().getId())) {
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
}
}
ReportEvent.this.client.sendResponse(new ModToolIssueHandledComposer(cfhTopic.reply).compose());
@ -99,10 +100,11 @@ public class ReportEvent extends MessageHandler {
Emulator.getThreading().run(() -> {
if (issue.state == ModToolTicketState.OPEN) {
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(issue.reportedId);
Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId);
if (reported != null) {
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
if (ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(ReportEvent.this.client, issue.reportedId)) {
Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId);
if (reported != null) {
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
}
}
}

View File

@ -21,8 +21,7 @@ public class IgnoreRoomUserEvent extends MessageHandler {
if (habbo == this.client.getHabbo())
return;
{
this.client.getHabbo().getHabboStats().ignoreUser(habbo.getHabboInfo().getId());
if (this.client.getHabbo().getHabboStats().ignoreUser(this.client, habbo.getHabboInfo().getId())) {
this.client.sendResponse(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.IGNORED));
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModIgnoreSeen"));
}

View File

@ -22,7 +22,7 @@ public class IgnoreUser extends RCONMessage<IgnoreUser.JSONIgnoreUser> {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id);
if (habbo != null) {
habbo.getHabboStats().ignoreUser(object.target_id);
habbo.getHabboStats().ignoreUser(habbo.getClient(), object.target_id);
} else {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {