mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40: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!');
|
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_softkick_error_self', 'You can not softkick yourself!');
|
||||||
|
|
||||||
-- Rank ignoring
|
-- Rank ignoring
|
||||||
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.error.higher_rank', 'You can\'t ignore this user.');
|
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.ignore.staffs', '0');
|
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.allow.ignore.staffs', '1');
|
@ -603,26 +603,27 @@ public class HabboStats implements Runnable {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ignoreUser(GameClient gameClient, int userId) {
|
/**
|
||||||
Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
* Ignore an user.
|
||||||
if (!Emulator.getConfig().getBoolean("hotel.ignore.staffs")) {
|
*
|
||||||
if (target.getHabboInfo().getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
|
* @param gameClient The client to which this HabboStats instance belongs.
|
||||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.error.higher_rank"), RoomChatMessageBubbles.ALERT);
|
* @param userId The user to ignore.
|
||||||
} else if (!this.userIgnored(userId)) {
|
* @return true if successfully ignored, false otherwise.
|
||||||
this.ignoredUsers.add(userId);
|
*/
|
||||||
|
public boolean ignoreUser(GameClient gameClient, int userId) {
|
||||||
|
final Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
if (!Emulator.getConfig().getBoolean("hotel.allow.ignore.staffs")) {
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
|
final int ownRank = gameClient.getHabbo().getHabboInfo().getRank().getId();
|
||||||
statement.setInt(1, this.habboInfo.getId());
|
final int targetRank = target.getHabboInfo().getRank().getId();
|
||||||
statement.setInt(2, userId);
|
|
||||||
statement.execute();
|
if (targetRank >= ownRank) {
|
||||||
} catch (SQLException e) {
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.error.ignore_higher_rank"), RoomChatMessageBubbles.ALERT);
|
||||||
LOGGER.error("Caught SQL exception", e);
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!this.userIgnored(userId)) {
|
if (!this.userIgnored(userId)) {
|
||||||
this.ignoredUsers.add(userId);
|
this.ignoredUsers.add(userId);
|
||||||
|
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
@ -635,6 +636,7 @@ public class HabboStats implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unignoreUser(int userId) {
|
public void unignoreUser(int userId) {
|
||||||
|
@ -73,9 +73,10 @@ public class ReportEvent extends MessageHandler {
|
|||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
if (issue.state == ModToolTicketState.OPEN) {
|
if (issue.state == ModToolTicketState.OPEN) {
|
||||||
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
|
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
|
||||||
ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(reported.getHabboInfo().getId());
|
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 RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReportEvent.this.client.sendResponse(new ModToolIssueHandledComposer(cfhTopic.reply).compose());
|
ReportEvent.this.client.sendResponse(new ModToolIssueHandledComposer(cfhTopic.reply).compose());
|
||||||
Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null);
|
Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null);
|
||||||
@ -99,12 +100,13 @@ public class ReportEvent extends MessageHandler {
|
|||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
if (issue.state == ModToolTicketState.OPEN) {
|
if (issue.state == ModToolTicketState.OPEN) {
|
||||||
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
|
if (cfhTopic.action == CfhActionType.AUTO_IGNORE) {
|
||||||
ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(issue.reportedId);
|
if (ReportEvent.this.client.getHabbo().getHabboStats().ignoreUser(ReportEvent.this.client, issue.reportedId)) {
|
||||||
Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId);
|
Habbo reported = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.reportedId);
|
||||||
if (reported != null) {
|
if (reported != null) {
|
||||||
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
|
ReportEvent.this.client.sendResponse(new RoomUserIgnoredComposer(reported, RoomUserIgnoredComposer.IGNORED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ReportEvent.this.client.sendResponse(new ModToolIssueHandledComposer(cfhTopic.reply).compose());
|
ReportEvent.this.client.sendResponse(new ModToolIssueHandledComposer(cfhTopic.reply).compose());
|
||||||
Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null);
|
Emulator.getGameEnvironment().getModToolManager().closeTicketAsHandled(issue, null);
|
||||||
|
@ -21,8 +21,7 @@ public class IgnoreRoomUserEvent extends MessageHandler {
|
|||||||
if (habbo == this.client.getHabbo())
|
if (habbo == this.client.getHabbo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
if (this.client.getHabbo().getHabboStats().ignoreUser(this.client, habbo.getHabboInfo().getId())) {
|
||||||
this.client.getHabbo().getHabboStats().ignoreUser(habbo.getHabboInfo().getId());
|
|
||||||
this.client.sendResponse(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.IGNORED));
|
this.client.sendResponse(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.IGNORED));
|
||||||
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("SelfModIgnoreSeen"));
|
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);
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(object.user_id);
|
||||||
|
|
||||||
if (habbo != null) {
|
if (habbo != null) {
|
||||||
habbo.getHabboStats().ignoreUser(object.target_id);
|
habbo.getHabboStats().ignoreUser(habbo.getClient(), object.target_id);
|
||||||
} else {
|
} else {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||||
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
|
PreparedStatement statement = connection.prepareStatement("INSERT INTO users_ignored (user_id, target_id) VALUES (?, ?)")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user