Refactor ModAlert

This commit is contained in:
brenoepic 2022-04-29 19:32:19 -03:00
parent 8d5069501f
commit 49e7847051

View File

@ -18,33 +18,35 @@ public class ModAlertEvent extends MessageHandler {
String message = this.packet.readString(); String message = this.packet.readString();
int cfhTopic = this.packet.readInt(); int cfhTopic = this.packet.readInt();
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { if (!this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) return;
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) { if (habbo == null) {
this.client.sendResponse(new IssueCloseNotificationMessageComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
return;
}
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { if (!Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
habbo.alert(message);
return;
}
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { if (modToolSanctionItems == null || modToolSanctionItems.isEmpty()) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
if (item != null && item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
} else {
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
}
} else {
modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0); modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
return;
} }
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
if (item == null) return;
if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
} else { } else {
habbo.alert(message); modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
}
} else {
this.client.sendResponse(new IssueCloseNotificationMessageComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
}
} }
} }
} }