Modify HabboAddedToRoomEvent

This commit is contained in:
Alejandro 2019-12-27 14:38:45 +02:00
parent 906a0c880c
commit 7bd31aed7b
2 changed files with 20 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.core.RoomUserPetComposer; import com.eu.habbo.core.RoomUserPetComposer;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.games.football.FootballGame; import com.eu.habbo.habbohotel.games.football.FootballGame;
@ -40,6 +41,7 @@ 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.promotions.RoomPromotionMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.rooms.users.*;
import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent; import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent;
import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent; import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent;
@ -710,9 +712,20 @@ public class RoomManager {
List<Habbo> habbos = new ArrayList<>(); List<Habbo> habbos = new ArrayList<>();
if (!room.getCurrentHabbos().isEmpty()) { if (!room.getCurrentHabbos().isEmpty()) {
Collection<Habbo> habbosToSendEnter = room.getCurrentHabbos().values();
room.sendComposer(new RoomUsersComposer(habbo).compose()); if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
room.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter));
habbosToSendEnter = event.habbosToSendEnter;
}
for (Habbo habboToSendEnter : habbosToSendEnter) {
GameClient client = habboToSendEnter.getClient();
if (client != null) {
client.sendResponse(new RoomUsersComposer(habbo).compose());
habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
}
}
for (Habbo h : room.getHabbos()) { for (Habbo h : room.getHabbos()) {
if (!h.getRoomUnit().isInvisible()) { if (!h.getRoomUnit().isInvisible()) {
@ -890,10 +903,6 @@ public class RoomManager {
if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) { if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) {
UserNuxEvent.handle(habbo); UserNuxEvent.handle(habbo);
} }
if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room));
}
} }
void logEnter(Habbo habbo, Room room) { void logEnter(Habbo habbo, Room room) {

View File

@ -3,14 +3,18 @@ package com.eu.habbo.plugin.events.users;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import java.util.Collection;
public class HabboAddedToRoomEvent extends UserEvent { public class HabboAddedToRoomEvent extends UserEvent {
public final Room room; public final Room room;
public final Collection<Habbo> habbosToSendEnter;
public HabboAddedToRoomEvent(Habbo habbo, Room room) { public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection<Habbo> habbosToSendEnter) {
super(habbo); super(habbo);
this.room = room; this.room = room;
this.habbosToSendEnter = habbosToSendEnter;
} }
} }