From ecf04c488d58026d5bb801da3d3635525095f31c Mon Sep 17 00:00:00 2001 From: Beny Date: Mon, 20 May 2019 18:35:20 +0100 Subject: [PATCH] Added two new plugin events - UserRespectedEvent and HabboAddedToRoomEvent --- .../eu/habbo/habbohotel/rooms/RoomManager.java | 7 +++++++ .../rooms/users/RoomUserGiveRespectEvent.java | 7 +++++++ .../events/users/HabboAddedToRoomEvent.java | 18 ++++++++++++++++++ .../events/users/UserRespectedEvent.java | 15 +++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java create mode 100644 src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index c2fd8b37..b785c1e0 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -41,8 +41,10 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer; import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer; import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; +import com.eu.habbo.plugin.PluginManager; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; +import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent; import gnu.trove.iterator.TIntObjectIterator; @@ -50,6 +52,7 @@ import gnu.trove.map.hash.THashMap; import gnu.trove.procedure.TIntProcedure; import gnu.trove.procedure.TObjectProcedure; import gnu.trove.set.hash.THashSet; +import sun.plugin2.main.server.Plugin; import java.sql.*; import java.util.*; @@ -1072,6 +1075,10 @@ public class RoomManager { UserNuxEvent.handle(habbo); } + + if(Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) { + Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room)); + } } void logEnter(Habbo habbo, Room room) diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java index cea256a4..4ec51ba3 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserGiveRespectEvent.java @@ -1,7 +1,9 @@ package com.eu.habbo.messages.incoming.rooms.users; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.plugin.events.users.UserRespectedEvent; public class RoomUserGiveRespectEvent extends MessageHandler { @@ -14,6 +16,11 @@ public class RoomUserGiveRespectEvent extends MessageHandler { Habbo target = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(userId); + if(Emulator.getPluginManager().isRegistered(UserRespectedEvent.class, false)) { + if(Emulator.getPluginManager().fireEvent(new UserRespectedEvent(target, this.client.getHabbo())).isCancelled()) + return; + } + this.client.getHabbo().respect(target); } } diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java new file mode 100644 index 00000000..3980cfcc --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java @@ -0,0 +1,18 @@ +package com.eu.habbo.plugin.events.users; + +import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.users.Habbo; + +public class HabboAddedToRoomEvent extends UserEvent +{ + + public final Room room; + + + public HabboAddedToRoomEvent(Habbo habbo, Room room) + { + super(habbo); + + this.room = room; + } +} diff --git a/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java new file mode 100644 index 00000000..c161c6b3 --- /dev/null +++ b/src/main/java/com/eu/habbo/plugin/events/users/UserRespectedEvent.java @@ -0,0 +1,15 @@ +package com.eu.habbo.plugin.events.users; + +import com.eu.habbo.habbohotel.users.Habbo; + +public class UserRespectedEvent extends UserEvent +{ + public final Habbo from; + + public UserRespectedEvent(Habbo habbo, Habbo from) + { + super(habbo); + + this.from = from; + } +}