mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-22 23:10:52 +01:00
Clean up code, fix bug showing it succeeded while it didn't
This commit is contained in:
parent
d2d3dcc78c
commit
5b52ece5e3
@ -11,5 +11,5 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softki
|
||||
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');
|
||||
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');
|
@ -603,40 +603,42 @@ public class HabboStats implements Runnable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void ignoreUser(GameClient gameClient, int userId) {
|
||||
Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
if (!Emulator.getConfig().getBoolean("hotel.ignore.staffs")) {
|
||||
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);
|
||||
/**
|
||||
* 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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void unignoreUser(int userId) {
|
||||
if (this.userIgnored(userId)) {
|
||||
this.ignoredUsers.remove(userId);
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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 (?, ?)")) {
|
||||
|
Loading…
Reference in New Issue
Block a user