From 7465480d1ef228b429150d5350c1c67fa5532db4 Mon Sep 17 00:00:00 2001 From: Beny Date: Sat, 4 May 2019 05:37:29 +0100 Subject: [PATCH] SupportUserAlertedReason added to SupportUserAlertedEvent --- .../habbohotel/modtool/ModToolManager.java | 30 +++++++++---------- .../com/eu/habbo/messages/PacketManager.java | 2 +- .../AmbassadorAlertCommandEvent.java | 30 ++++++++++++------- .../incoming/modtool/ModToolAlertEvent.java | 7 ++++- .../incoming/modtool/ModToolWarnEvent.java | 26 ++++++++++++++++ .../support/SupportUserAlertedEvent.java | 5 ++-- .../support/SupportUserAlertedReason.java | 24 +++++++++++++++ 7 files changed, 95 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java index 1908d77d..c97df979 100644 --- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolManager.java @@ -467,23 +467,23 @@ public class ModToolManager public void alert(Habbo moderator, Habbo target, String message) { - if(moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) - { - SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(moderator, target, message); - if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled()) - { - return; - } + alert(moderator, target, message, SupportUserAlertedReason.ALERT); + } - if(target != null) - { - alertedEvent.target.getClient().sendResponse(new ModToolIssueHandledComposer(alertedEvent.message)); - } - } - else - { + public void alert(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) + { + if(!moderator.hasPermission(Permission.ACC_SUPPORTTOOL)) { Emulator.getGameEnvironment().getModToolManager().quickTicket(moderator, "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", moderator.getHabboInfo().getUsername()).replace("%message%", message)); + return; } + + SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(moderator, target, message, reason); + + if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled()) + return; + + if(target != null) + alertedEvent.target.getClient().sendResponse(new ModToolIssueHandledComposer(alertedEvent.message)); } public void kick(Habbo moderator, Habbo target, String message) @@ -494,7 +494,7 @@ public class ModToolManager { Emulator.getGameEnvironment().getRoomManager().leaveRoom(target, target.getHabboInfo().getCurrentRoom()); } - this.alert(moderator, target, message); + this.alert(moderator, target, message, SupportUserAlertedReason.KICKED); } } diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java index fae18c43..7ebcfb5d 100644 --- a/src/main/java/com/eu/habbo/messages/PacketManager.java +++ b/src/main/java/com/eu/habbo/messages/PacketManager.java @@ -465,7 +465,7 @@ public class PacketManager this.registerHandler(Incoming.ModToolCloseTicketEvent, ModToolCloseTicketEvent.class); this.registerHandler(Incoming.ModToolReleaseTicketEvent, ModToolReleaseTicketEvent.class); this.registerHandler(Incoming.ModToolAlertEvent, ModToolAlertEvent.class); - this.registerHandler(Incoming.ModToolWarnEvent, ModToolAlertEvent.class); + this.registerHandler(Incoming.ModToolWarnEvent, ModToolWarnEvent.class); this.registerHandler(Incoming.ModToolKickEvent, ModToolKickEvent.class); this.registerHandler(Incoming.ModToolRoomAlertEvent, ModToolRoomAlertEvent.class); this.registerHandler(Incoming.ModToolChangeRoomSettingsEvent, ModToolChangeRoomSettingsEvent.class); diff --git a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java index 3ed0a873..838c4f82 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/ambassadors/AmbassadorAlertCommandEvent.java @@ -1,24 +1,34 @@ package com.eu.habbo.messages.incoming.ambassadors; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; +import com.eu.habbo.plugin.events.support.SupportUserAlertedEvent; +import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; public class AmbassadorAlertCommandEvent extends MessageHandler { @Override public void handle() throws Exception { - if(this.client.getHabbo().hasPermission("acc_ambassador")) - { - int userId = this.packet.readInt(); - - Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); - - if(habbo != null) - { - habbo.getClient().sendResponse(new BubbleAlertComposer("ambassador.alert.warning")); - } + if(!this.client.getHabbo().hasPermission("acc_ambassador")) { + Emulator.getGameEnvironment().getModToolManager().quickTicket(client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.alert").replace("%username%", client.getHabbo().getHabboInfo().getUsername()).replace("%message%", "${notification.ambassador.alert.warning.message}")); + return; } + + int userId = this.packet.readInt(); + + Habbo habbo = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); + + if(habbo == null) + return; + + SupportUserAlertedEvent alertedEvent = new SupportUserAlertedEvent(client.getHabbo(), habbo, "${notification.ambassador.alert.warning.message}", SupportUserAlertedReason.AMBASSADOR); + + if (Emulator.getPluginManager().fireEvent(alertedEvent).isCancelled()) + return; + + habbo.getClient().sendResponse(new BubbleAlertComposer("ambassador.alert.warning")); } } diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java index 70b37df3..26097f2f 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolAlertEvent.java @@ -2,7 +2,9 @@ package com.eu.habbo.messages.incoming.modtool; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; public class ModToolAlertEvent extends MessageHandler { @@ -11,7 +13,10 @@ public class ModToolAlertEvent extends MessageHandler { if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { - Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()), this.packet.readString()); + Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); + + if(alertedUser != null) + Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.ALERT); } else { diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java new file mode 100644 index 00000000..92eafdd7 --- /dev/null +++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolWarnEvent.java @@ -0,0 +1,26 @@ +package com.eu.habbo.messages.incoming.modtool; + +import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.users.Habbo; +import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.plugin.events.support.SupportUserAlertedReason; + +public class ModToolWarnEvent extends MessageHandler +{ + @Override + public void handle() throws Exception + { + if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) + { + Habbo alertedUser = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.packet.readInt()); + + if(alertedUser != null) + Emulator.getGameEnvironment().getModToolManager().alert(this.client.getHabbo(), alertedUser, this.packet.readString(), SupportUserAlertedReason.CAUTION); + } + else + { + Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.modtools.kick").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername())); + } + } +} diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java index 62b83c72..efba63be 100644 --- a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedEvent.java @@ -7,15 +7,16 @@ public class SupportUserAlertedEvent extends SupportEvent public Habbo target; - public String message; + public SupportUserAlertedReason reason; - public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message) + public SupportUserAlertedEvent(Habbo moderator, Habbo target, String message, SupportUserAlertedReason reason) { super(moderator); this.message = message; this.target = target; + this.reason = reason; } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java new file mode 100644 index 00000000..552d2b90 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/support/SupportUserAlertedReason.java @@ -0,0 +1,24 @@ +package com.eu.habbo.plugin.events.support; + +public enum SupportUserAlertedReason { + + ALERT(0), + + CAUTION(1), + + KICKED(2), + + AMBASSADOR(3); + + private final int code; + + SupportUserAlertedReason(int code) + { + this.code = code; + } + + public int getCode() + { + return this.code; + } +}