Arcturus-Community/src/main/java/com/eu/habbo/messages/incoming/rooms/RoomStaffPickEvent.java

46 lines
1.9 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.messages.incoming.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
2019-03-18 02:22:00 +01:00
import com.eu.habbo.habbohotel.navigation.NavigatorPublicCategory;
2020-06-05 10:12:49 +02:00
import com.eu.habbo.habbohotel.permissions.Permission;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer;
2019-05-26 20:14:53 +02:00
public class RoomStaffPickEvent extends MessageHandler {
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public void handle() throws Exception {
2020-06-05 10:12:49 +02:00
if (this.client.getHabbo().hasPermission(Permission.ACC_STAFF_PICK)) {
2018-07-06 15:30:00 +02:00
int roomId = this.packet.readInt();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
2019-05-26 20:14:53 +02:00
if (room != null) {
2018-07-06 15:30:00 +02:00
room.setStaffPromotedRoom(!room.isStaffPromotedRoom());
room.setNeedsUpdate(true);
2019-03-18 02:22:00 +01:00
NavigatorPublicCategory publicCategory = Emulator.getGameEnvironment().getNavigatorManager().publicCategories.get(Emulator.getConfig().getInt("hotel.navigator.staffpicks.categoryid"));
2019-05-26 20:14:53 +02:00
if (room.isStaffPromotedRoom()) {
2018-07-06 15:30:00 +02:00
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(room.getOwnerId());
2019-05-26 20:14:53 +02:00
if (habbo != null) {
2018-07-06 15:30:00 +02:00
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("Spr"));
}
2019-03-18 02:22:00 +01:00
2019-05-26 20:14:53 +02:00
if (publicCategory != null) {
2019-03-18 02:22:00 +01:00
publicCategory.addRoom(room);
}
2019-05-26 20:14:53 +02:00
} else {
if (publicCategory != null) {
2019-03-18 02:22:00 +01:00
publicCategory.removeRoom(room);
}
2018-07-06 15:30:00 +02:00
}
2019-03-18 02:22:00 +01:00
this.client.sendResponse(new RoomDataComposer(room, this.client.getHabbo(), true, false));
2018-07-06 15:30:00 +02:00
}
}
}
}