From 49e7847051ff6a6decb9d1f420ba6fe6d5bb1918 Mon Sep 17 00:00:00 2001 From: brenoepic <59066707+brenoepics@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:32:19 -0300 Subject: [PATCH] Refactor ModAlert --- .../incoming/modtool/ModAlertEvent.java | 54 ++++++++++--------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java index 9704f8f6..911ab462 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModAlertEvent.java @@ -18,33 +18,35 @@ public class ModAlertEvent extends MessageHandler { String message = this.packet.readString(); int cfhTopic = this.packet.readInt(); - if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { - Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); + if (!this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) return; + Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); - if (habbo != null) { - ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); - - if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { - THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); - ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); - - 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); - } - } else { - habbo.alert(message); - } - } else { - this.client.sendResponse(new IssueCloseNotificationMessageComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name")))); - } + 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(); + + if (!Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { + habbo.alert(message); + return; + } + THashMap> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId()); + ArrayList modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId()); + + if (modToolSanctionItems == null || modToolSanctionItems.isEmpty()) { + 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 { + modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0); + } + + } } \ No newline at end of file