small refactor

This commit is contained in:
Dominic Bridge 2023-12-08 13:02:29 +00:00
parent 3bb8ce1624
commit c4865f8fbd
53 changed files with 785 additions and 558 deletions

View File

@ -105,7 +105,7 @@ public class BotManager {
if (room != null && bot != null && habbo != null) {
if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasRight(Permission.ACC_ANYROOMOWNER) || habbo.hasRight(Permission.ACC_PLACEFURNI)) {
if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS)) {
if (room.getCurrentBots().size() >= RoomConfiguration.MAXIMUM_BOTS && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS)) {
habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
return;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.users.Habbo;
import java.sql.ResultSet;
@ -43,4 +44,9 @@ public class InteractionBlackHole extends InteractionGate {
super.onPlace(room);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.users.Habbo;
@ -241,4 +242,9 @@ public class InteractionBuildArea extends InteractionCustomValues {
public boolean isBuilder(String Username) {
return Arrays.asList(this.values.get("builders").split(";")).contains(Username);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,10 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
@ -138,4 +135,9 @@ public class InteractionFireworks extends InteractionDefault {
room.updateItemState(this);
}, explodeDuration);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -63,7 +64,10 @@ public class InteractionJukeBox extends HabboItem {
this.setExtradata("0");
room.getTraxManager().removeTraxOnRoom(this);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public void onPlace(Room room) {
super.onPlace(room);

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomMoodlightData;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -58,7 +59,10 @@ public class InteractionMoodLight extends HabboItem {
super.onPlace(room);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public boolean isUsable() {
return true;

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -83,4 +84,9 @@ public class InteractionMusicDisc extends HabboItem {
room.getTraxManager().sendUpdatedSongList();
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -144,4 +145,9 @@ public class InteractionMuteArea extends InteractionCustomValues {
}, 3000);
}
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -43,7 +44,10 @@ public class InteractionPyramid extends InteractionGate {
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public boolean isUsable() {
return false;

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -84,4 +85,9 @@ public class InteractionRoller extends HabboItem {
return true;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addRoller(this);
}
}

View File

@ -4,10 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.set.hash.THashSet;
@ -84,4 +81,8 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
}
}
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -13,4 +14,9 @@ public class InteractionStickyPole extends InteractionDefault {
public InteractionStickyPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -13,4 +14,9 @@ public class InteractionTalkingFurniture extends InteractionDefault {
public InteractionTalkingFurniture(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -20,4 +21,9 @@ public class InteractionTent extends InteractionDefault {
public void onClick(GameClient client, Room room, Object[] objects) {
// do nothing
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -301,4 +301,8 @@ public class InteractionWater extends InteractionDefault {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.set.hash.THashSet;
@ -84,7 +85,10 @@ public class InteractionWaterItem extends InteractionMultiHeight {
room.updateItemState(this);
}
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public boolean allowWiredResetState() {
return false;

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -48,5 +49,8 @@ public abstract class InteractionWiredCondition extends InteractionWired {
public WiredConditionOperator operator() {
return WiredConditionOperator.AND;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addCondition(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
@ -59,4 +60,9 @@ public abstract class InteractionWiredEffect extends InteractionWired {
public boolean requiresTriggeringUser() {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addEffect(this);
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import java.sql.ResultSet;
@ -35,4 +36,9 @@ public abstract class InteractionWiredExtra extends InteractionWired {
public boolean isWalkable() {
return true;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addExtra(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -151,4 +152,8 @@ public class InteractionWiredHighscore extends HabboItem {
public void reloadData() {
this.data = Emulator.getGameEnvironment().getItemManager().getHighscoreManager().getHighscoreRowsForItem(this.getId(), this.clearType, this.scoreType);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer;
@ -58,4 +59,8 @@ public abstract class InteractionWiredTrigger extends InteractionWired {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addTrigger(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.messages.ServerMessage;
@ -52,4 +53,9 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem {
this.setExtradata(memberCount + "");
game.getRoom().updateItem(this);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addGameGate(this);
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.games;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
@ -31,4 +32,8 @@ public abstract class InteractionGameScoreboard extends InteractionGameTeamItem
public void onPickUp(Room room) {
this.setExtradata("0");
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addGameScoreboard(this);
}
}

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -334,4 +335,8 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
this.timeNow--;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addGameTimer(this);
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -41,4 +42,9 @@ public class InteractionBattleBanzaiSphere extends HabboItem {
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) {
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -73,4 +74,9 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addBanzaiTeleporter(this);
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -47,4 +48,9 @@ public class InteractionFreezeExitTile extends HabboItem {
super.serializeExtradata(serverMessage);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addFreezeExitTile(this);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.tag.TagGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -71,7 +72,10 @@ public abstract class InteractionTagField extends HabboItem {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -40,7 +41,10 @@ public class InteractionTagPole extends HabboItem {
super.serializeExtradata(serverMessage);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
@Override
public void onPickUp(Room room) {
this.setExtradata("0");

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -82,4 +83,9 @@ public class InteractionNest extends HabboItem {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addNest(this);
}
}

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -165,4 +166,8 @@ public class InteractionPetBreedingNest extends HabboItem {
}, 2000);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -121,4 +121,9 @@ public class InteractionPetDrink extends InteractionDefault {
room.updateItemState(this);
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addPetDrink(this);
}
}

View File

@ -5,10 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import com.eu.habbo.threading.runnables.PetEatAction;
@ -54,4 +51,8 @@ public class InteractionPetFood extends InteractionDefault {
public boolean allowWiredResetState() {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addPetFood(this);
}
}

View File

@ -101,4 +101,9 @@ public class InteractionPetToy extends InteractionDefault {
public boolean allowWiredResetState() {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addPetToy(this);
}
}

View File

@ -98,4 +98,8 @@ public class InteractionPetTrampoline extends InteractionDefault {
public boolean allowWiredResetState() {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -97,4 +97,9 @@ public class InteractionPetTree extends InteractionDefault {
public boolean allowWiredResetState() {
return false;
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -116,4 +117,9 @@ public class WiredBlob extends InteractionDefault {
this.RESETS_WITH_GAME = params[1].equalsIgnoreCase("true");
}
@Override
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes) {
roomSpecialTypes.addUndefined(this);
}
}

View File

@ -27,6 +27,9 @@ import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.rooms.utils.HabboItemGetter;
import com.eu.habbo.habbohotel.rooms.utils.IHabboItemGetter;
import com.eu.habbo.habbohotel.rooms.utils.RoomLoader;
import com.eu.habbo.habbohotel.users.*;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -83,28 +86,14 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
import static com.eu.habbo.habbohotel.rooms.RoomConfiguration.*;
import static com.eu.habbo.habbohotel.rooms.utils.RoomLoader.*;
@Slf4j
public class Room implements Comparable<Room>, ISerialize, Runnable {
private static final String CAUGHT_EXCEPTION = "Caught exception";
private static final TIntObjectHashMap<RoomMoodlightData> defaultMoodData = new TIntObjectHashMap<>();
public static final Comparator<Room> SORT_SCORE = (o1, o2) -> o2.getScore() - o1.getScore();
public static final Comparator<Room> SORT_ID = (o1, o2) -> o2.getId() - o1.getId();
private static final TIntObjectHashMap<RoomMoodlightData> defaultMoodData = new TIntObjectHashMap<>();
//Configuration. Loaded from database & updated accordingly.
public static boolean HABBO_CHAT_DELAY = false;
public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10;
public static int MAXIMUM_FURNI = 2500;
public static int MAXIMUM_POSTITNOTES = 200;
public static int HAND_ITEM_TIME = 10;
public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480;
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
public static boolean MUTEAREA_CAN_WHISPER = false;
public static final double MAXIMUM_FURNI_HEIGHT = 40d;
static {
for (int i = 1; i <= 3; i++) {
@ -116,7 +105,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public final Object roomUnitLock = new Object();
public final ConcurrentHashMap<RoomTile, THashSet<HabboItem>> tileCache = new ConcurrentHashMap<>();
public final List<Integer> userVotes;
public List<Integer> userVotes;
@Getter
private final ConcurrentHashMap<Integer, Habbo> currentHabbos = new ConcurrentHashMap<>(3);
@Getter
@ -125,22 +114,22 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private final TIntObjectMap<Bot> currentBots = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
@Getter
private final TIntObjectMap<Pet> currentPets = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
private final THashSet<RoomTrade> activeTrades;
private THashSet<RoomTrade> activeTrades;
@Getter
private final TIntArrayList rights;
private final TIntIntHashMap mutedHabbos;
private final TIntObjectHashMap<RoomBan> bannedHabbos;
private TIntArrayList rights;
private TIntIntHashMap mutedHabbos;
private TIntObjectHashMap<RoomBan> bannedHabbos;
@Getter
private final ConcurrentSet<Game> games;
private ConcurrentSet<Game> games;
@Getter
private final TIntObjectMap<String> furniOwnerNames;
private TIntObjectMap<String> furniOwnerNames;
@Getter
private final TIntIntMap furniOwnerCount;
private TIntIntMap furniOwnerCount;
@Getter
private final TIntObjectMap<RoomMoodlightData> moodlightData;
private TIntObjectMap<RoomMoodlightData> moodlightData;
@Getter
private final THashSet<String> wordFilterWords;
private final TIntObjectMap<HabboItem> roomItems;
private THashSet<String> wordFilterWords;
private TIntObjectMap<HabboItem> roomItems;
private final Object loadLock = new Object();
//Use appropriately. Could potentially cause memory leaks when used incorrectly.
public volatile boolean preventUnloading = false;
@ -157,7 +146,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private int wordQuizEnd = 0;
public ScheduledFuture<?> roomCycleTask;
@Getter
private final int id;
private int id;
@Getter
@Setter
private int ownerId;
@ -172,7 +161,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
@Setter
private RoomLayout layout;
private boolean overrideModel;
private final String layoutName;
private String layoutName;
@Getter
private String password;
@Getter
@ -296,7 +285,35 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
@Getter
private long cycleTimestamp;
private final HabboItemGetter habboItemGetter = new HabboItemGetter();
public Room(ResultSet set) throws SQLException {
loadRoomProperties(set);
loadPromotion(set);
loadBans();
initializeCollections(set);
}
private void loadPromotion(ResultSet set) throws SQLException {
this.promoted = set.getString("promoted").equals("1");
if (this.promoted) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement(
"SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) {
statement.setInt(1, this.id);
statement.setInt(2, Emulator.getIntUnixTimestamp());
this.promoted = false;
try (ResultSet promotionSet = statement.executeQuery()) {
if (promotionSet.next()) {
this.promoted = true;
this.promotion = new RoomPromotion(this, promotionSet);
}
}
}
}
}
private void loadRoomProperties(ResultSet set) throws SQLException {
this.id = set.getInt("id");
this.ownerId = set.getInt("owner_id");
this.ownerName = set.getString("owner_name");
@ -333,51 +350,28 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.rollerSpeed = set.getInt("roller_speed");
this.overrideModel = set.getString("override_model").equals("1");
this.layoutName = set.getString("model");
this.promoted = set.getString("promoted").equals("1");
this.jukeboxActive = set.getString("jukebox_active").equals("1");
this.hideWired = set.getString("hidewired").equals("1");
}
this.bannedHabbos = new TIntObjectHashMap<>();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_promotions WHERE room_id = ? AND end_timestamp > ? LIMIT 1")) {
if (this.promoted) {
statement.setInt(1, this.id);
statement.setInt(2, Emulator.getIntUnixTimestamp());
try (ResultSet promotionSet = statement.executeQuery()) {
this.promoted = false;
if (promotionSet.next()) {
this.promoted = true;
this.promotion = new RoomPromotion(this, promotionSet);
}
}
}
this.loadBans(connection);
private void loadBans() {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
this.bannedHabbos = RoomLoader.loadBans(connection, id);
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
}
}
this.tradeMode = set.getInt("trade_mode");
this.moveDiagonally = set.getString("move_diagonally").equals("1");
this.preLoaded = true;
this.allowBotsWalk = true;
this.allowEffects = true;
private void initializeCollections(ResultSet set) throws SQLException {
this.furniOwnerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
this.furniOwnerCount = TCollections.synchronizedMap(new TIntIntHashMap(0));
this.roomItems = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
this.bannedHabbos = new TIntObjectHashMap<>();
this.wordFilterWords = new THashSet<>(0);
this.moodlightData = new TIntObjectHashMap<>(defaultMoodData);
for (String s : set.getString("moodlight_data").split(";")) {
RoomMoodlightData data = RoomMoodlightData.fromString(s);
this.moodlightData.put(data.getId(), data);
}
Arrays.stream(set.getString("moodlight_data").split(";"))
.map(RoomMoodlightData::fromString)
.forEach(data -> this.moodlightData.put(data.getId(), data));
this.mutedHabbos = new TIntIntHashMap();
this.games = new ConcurrentSet<>();
this.activeTrades = new THashSet<>(0);
this.rights = new TIntArrayList();
this.userVotes = new ArrayList<>();
@ -401,13 +395,17 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.roomSpecialTypes = new RoomSpecialTypes();
this.loadLayout();
this.loadRights(connection);
this.loadItems(connection);
this.loadHeightmap();
this.loadBots(connection);
this.loadPets(connection);
this.loadWordFilter(connection);
this.loadWiredData(connection);
this.rights = loadRights(connection, this.id);
this.roomItems.clear();
loadItems(connection, id, this);
if (this.itemCount() > RoomConfiguration.MAXIMUM_FURNI) {
log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), RoomConfiguration.MAXIMUM_FURNI);
}
loadHeightmap(this, id);
loadBots(connection, id, this);
loadPets(connection, id, this);
loadWordFilter(connection, id, wordFilterWords);
loadWiredData(connection, id, this);
this.idleCycles = 0;
this.loaded = true;
@ -448,161 +446,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
private synchronized void loadHeightmap() {
try {
if (this.layout != null) {
for (short x = 0; x < this.layout.getMapSizeX(); x++) {
for (short y = 0; y < this.layout.getMapSizeY(); y++) {
RoomTile tile = this.layout.getTile(x, y);
if (tile != null) {
this.updateTile(tile);
}
}
}
} else {
log.error("Unknown Room Layout for Room (ID: {})", this.id);
}
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
private synchronized void loadItems(Connection connection) {
this.roomItems.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
this.addHabboItem(Emulator.getGameEnvironment().getItemManager().loadHabboItem(set));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
if (this.itemCount() > Room.MAXIMUM_FURNI) {
log.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI);
}
}
private synchronized void loadWiredData(Connection connection) {
try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
try {
HabboItem item = this.getHabboItem(set.getInt("id"));
if (item instanceof InteractionWired interactionWired) {
interactionWired.loadWiredData(set, this);
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
private synchronized void loadBots(Connection connection) {
this.currentBots.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Bot b = Emulator.getGameEnvironment().getBotManager().loadBot(set);
if (b != null) {
b.setRoom(this);
b.setRoomUnit(new RoomUnit());
b.getRoomUnit().setPathFinderRoom(this);
b.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) {
b.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight());
b.getRoomUnit().setLocation(this.getLayout().getDoorTile());
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
} else {
b.getRoomUnit().setZ(set.getDouble("z"));
b.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
}
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
b.getRoomUnit().setInRoom(true);
this.giveEffect(b.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
this.addBot(b);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
private synchronized void loadPets(Connection connection) {
this.currentPets.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Pet pet = PetManager.loadPet(set);
pet.setRoom(this);
pet.setRoomUnit(new RoomUnit());
pet.getRoomUnit().setPathFinderRoom(this);
pet.getRoomUnit().setLocation(this.layout.getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) {
pet.getRoomUnit().setZ(this.getLayout().getDoorTile().getStackHeight());
pet.getRoomUnit().setLocation(this.getLayout().getDoorTile());
pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
} else {
pet.getRoomUnit().setZ(set.getDouble("z"));
pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
}
pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET);
pet.getRoomUnit().setCanWalk(true);
this.addPet(pet);
this.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name"));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
private synchronized void loadWordFilter(Connection connection) {
this.wordFilterWords.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
this.wordFilterWords.add(set.getString("word"));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public void updateTile(RoomTile tile) {
if (tile != null) {
tile.setStackHeight(this.getStackHeight(tile.getX(), tile.getY(), false));
@ -613,8 +456,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public void updateTiles(THashSet<RoomTile> tiles) {
for (RoomTile tile : tiles) {
this.tileCache.remove(tile);
tile.setStackHeight(this.getStackHeight(tile.getX(), tile.getY(), false));
tile.setState(this.calculateTileState(tile));
updateTile(tile);
}
this.sendComposer(new HeightMapUpdateMessageComposer(this, tiles).compose());
@ -738,15 +580,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
Emulator.getThreading().run(item);
}
public void updateHabbosAt(Rectangle rectangle) {
for (short i = (short) rectangle.x; i < rectangle.x + rectangle.width; i++) {
for (short j = (short) rectangle.y; j < rectangle.y + rectangle.height; j++) {
this.updateHabbosAt(i, j);
}
}
}
public void updateHabbo(Habbo habbo) {
this.updateRoomUnit(habbo.getRoomUnit());
}
@ -779,6 +612,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.sendComposer(new UserUpdateComposer(roomUnit).compose());
}
public void updateHabbosAt(Rectangle rectangle) {
for (short i = (short) rectangle.x; i < rectangle.x + rectangle.width; i++) {
for (short j = (short) rectangle.y; j < rectangle.y + rectangle.height; j++) {
this.updateHabbosAt(i, j);
}
}
}
public void updateHabbosAt(short x, short y) {
this.updateHabbosAt(x, y, this.getHabbosAt(x, y));
@ -1241,7 +1081,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} else {
habbo.getRoomUnit().increaseIdleTimer();
if (!this.isOwner(habbo) && habbo.getRoomUnit().getIdleTimer() >= Room.IDLE_CYCLES_KICK) {
if (!this.isOwner(habbo) && habbo.getRoomUnit().getIdleTimer() >= RoomConfiguration.IDLE_CYCLES_KICK) {
UserExitRoomEvent event = new UserExitRoomEvent(habbo, UserExitRoomEvent.UserExitRoomReason.KICKED_IDLE);
Emulator.getPluginManager().fireEvent(event);
@ -1464,7 +1304,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
for (RoomUnit unit : unitsOnTile) {
if (rolledUnitIds.contains(unit.getId())) continue;
if (usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break;
if (usersRolledThisTile.size() >= RoomConfiguration.ROLLERS_MAXIMUM_ROLL_AVATARS) break;
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
@ -1995,80 +1835,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.roomSpecialTypes.addCycleTask((ICycleable) item);
}
if (item instanceof InteractionWiredTrigger interactionWiredTrigger) {
this.roomSpecialTypes.addTrigger(interactionWiredTrigger);
} else if (item instanceof InteractionWiredEffect interactionWiredEffect) {
this.roomSpecialTypes.addEffect(interactionWiredEffect);
} else if (item instanceof InteractionWiredCondition interactionWiredCondition) {
this.roomSpecialTypes.addCondition(interactionWiredCondition);
} else if (item instanceof InteractionWiredExtra interactionWiredExtra) {
this.roomSpecialTypes.addExtra(interactionWiredExtra);
} else if (item instanceof InteractionBattleBanzaiTeleporter interactionBattleBanzaiTeleporter) {
this.roomSpecialTypes.addBanzaiTeleporter(interactionBattleBanzaiTeleporter);
} else if (item instanceof InteractionRoller interactionRoller) {
this.roomSpecialTypes.addRoller(interactionRoller);
} else if (item instanceof InteractionGameScoreboard interactionGameScoreboard) {
this.roomSpecialTypes.addGameScoreboard(interactionGameScoreboard);
} else if (item instanceof InteractionGameGate interactionGameGate) {
this.roomSpecialTypes.addGameGate(interactionGameGate);
} else if (item instanceof InteractionGameTimer interactionGameTimer) {
this.roomSpecialTypes.addGameTimer(interactionGameTimer);
} else if (item instanceof InteractionFreezeExitTile interactionFreezeExitTile) {
this.roomSpecialTypes.addFreezeExitTile(interactionFreezeExitTile);
} else if (item instanceof InteractionNest interactionNest) {
this.roomSpecialTypes.addNest(interactionNest);
} else if (item instanceof InteractionPetDrink interactionPetDrink) {
this.roomSpecialTypes.addPetDrink(interactionPetDrink);
} else if (item instanceof InteractionPetFood interactionPetFood) {
this.roomSpecialTypes.addPetFood(interactionPetFood);
} else if (item instanceof InteractionPetToy interactionPetToy) {
this.roomSpecialTypes.addPetToy(interactionPetToy);
} else if (item instanceof InteractionPetTree) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionPetTrampoline) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionMoodLight) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionPyramid) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionMusicDisc) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionBattleBanzaiSphere) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionTalkingFurniture) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionWater) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionWaterItem) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionMuteArea) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionBuildArea) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionTagPole) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionTagField) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionJukeBox) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionPetBreedingNest) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionBlackHole) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionWiredHighscore) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionStickyPole) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof WiredBlob) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionTent) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionFireworks) {
this.roomSpecialTypes.addUndefined(item);
}
item.addToSpecialRoomTypes(roomSpecialTypes);
}
}
@ -2081,41 +1848,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
item = this.roomItems.get(id);
}
if (item == null)
item = this.roomSpecialTypes.getBanzaiTeleporter(id);
if (item == null)
item = this.roomSpecialTypes.getTrigger(id);
if (item == null)
item = this.roomSpecialTypes.getEffect(id);
if (item == null)
item = this.roomSpecialTypes.getCondition(id);
if (item == null)
item = this.roomSpecialTypes.getGameGate(id);
if (item == null)
item = this.roomSpecialTypes.getGameScorebord(id);
if (item == null)
item = this.roomSpecialTypes.getGameTimer(id);
if (item == null)
item = this.roomSpecialTypes.getFreezeExitTiles().get(id);
if (item == null)
item = this.roomSpecialTypes.getRoller(id);
if (item == null)
item = this.roomSpecialTypes.getNest(id);
if (item == null)
item = this.roomSpecialTypes.getPetDrink(id);
if (item == null)
item = this.roomSpecialTypes.getPetFood(id);
if (item == null) {
for (IHabboItemGetter itemGetter : habboItemGetter.getItemGetters()) {
item = itemGetter.get(id, roomSpecialTypes);
if (item != null) {
break;
}
}
}
return item;
}
@ -2126,102 +1866,103 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public void removeHabboItem(HabboItem item) {
if (item != null) {
if (item == null) {
return;
}
HabboItem i;
synchronized (this.roomItems) {
i = this.roomItems.remove(item.getId());
}
HabboItem i;
synchronized (this.roomItems) {
i = this.roomItems.remove(item.getId());
}
if (i != null) {
synchronized (this.furniOwnerCount) {
synchronized (this.furniOwnerNames) {
int count = this.furniOwnerCount.get(i.getUserId());
if (i != null) {
synchronized (this.furniOwnerCount) {
synchronized (this.furniOwnerNames) {
int count = this.furniOwnerCount.get(i.getUserId());
if (count > 1)
this.furniOwnerCount.put(i.getUserId(), count - 1);
else {
this.furniOwnerCount.remove(i.getUserId());
this.furniOwnerNames.remove(i.getUserId());
}
if (count > 1)
this.furniOwnerCount.put(i.getUserId(), count - 1);
else {
this.furniOwnerCount.remove(i.getUserId());
this.furniOwnerNames.remove(i.getUserId());
}
}
}
if (item instanceof ICycleable) {
this.roomSpecialTypes.removeCycleTask((ICycleable) item);
}
if (item instanceof ICycleable) {
this.roomSpecialTypes.removeCycleTask((ICycleable) item);
}
if (item instanceof InteractionBattleBanzaiTeleporter) {
this.roomSpecialTypes.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item);
} else if (item instanceof InteractionWiredTrigger) {
this.roomSpecialTypes.removeTrigger((InteractionWiredTrigger) item);
} else if (item instanceof InteractionWiredEffect) {
this.roomSpecialTypes.removeEffect((InteractionWiredEffect) item);
} else if (item instanceof InteractionWiredCondition) {
this.roomSpecialTypes.removeCondition((InteractionWiredCondition) item);
} else if (item instanceof InteractionWiredExtra) {
this.roomSpecialTypes.removeExtra((InteractionWiredExtra) item);
} else if (item instanceof InteractionRoller) {
this.roomSpecialTypes.removeRoller((InteractionRoller) item);
} else if (item instanceof InteractionGameScoreboard) {
this.roomSpecialTypes.removeScoreboard((InteractionGameScoreboard) item);
} else if (item instanceof InteractionGameGate) {
this.roomSpecialTypes.removeGameGate((InteractionGameGate) item);
} else if (item instanceof InteractionGameTimer) {
this.roomSpecialTypes.removeGameTimer((InteractionGameTimer) item);
} else if (item instanceof InteractionFreezeExitTile) {
this.roomSpecialTypes.removeFreezeExitTile((InteractionFreezeExitTile) item);
} else if (item instanceof InteractionNest) {
this.roomSpecialTypes.removeNest((InteractionNest) item);
} else if (item instanceof InteractionPetDrink) {
this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item);
} else if (item instanceof InteractionPetFood) {
this.roomSpecialTypes.removePetFood((InteractionPetFood) item);
} else if (item instanceof InteractionPetToy) {
this.roomSpecialTypes.removePetToy((InteractionPetToy) item);
} else if (item instanceof InteractionPetTree) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPetTrampoline) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMoodLight) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPyramid) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMusicDisc) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBattleBanzaiSphere) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTalkingFurniture) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWaterItem) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWater) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMuteArea) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTagPole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTagField) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionJukeBox) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPetBreedingNest) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBlackHole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWiredHighscore) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionStickyPole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof WiredBlob) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTent) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBuildArea) {
this.roomSpecialTypes.removeUndefined(item);
}
if (item instanceof InteractionBattleBanzaiTeleporter) {
this.roomSpecialTypes.removeBanzaiTeleporter((InteractionBattleBanzaiTeleporter) item);
} else if (item instanceof InteractionWiredTrigger) {
this.roomSpecialTypes.removeTrigger((InteractionWiredTrigger) item);
} else if (item instanceof InteractionWiredEffect) {
this.roomSpecialTypes.removeEffect((InteractionWiredEffect) item);
} else if (item instanceof InteractionWiredCondition) {
this.roomSpecialTypes.removeCondition((InteractionWiredCondition) item);
} else if (item instanceof InteractionWiredExtra) {
this.roomSpecialTypes.removeExtra((InteractionWiredExtra) item);
} else if (item instanceof InteractionRoller) {
this.roomSpecialTypes.removeRoller((InteractionRoller) item);
} else if (item instanceof InteractionGameScoreboard) {
this.roomSpecialTypes.removeScoreboard((InteractionGameScoreboard) item);
} else if (item instanceof InteractionGameGate) {
this.roomSpecialTypes.removeGameGate((InteractionGameGate) item);
} else if (item instanceof InteractionGameTimer) {
this.roomSpecialTypes.removeGameTimer((InteractionGameTimer) item);
} else if (item instanceof InteractionFreezeExitTile) {
this.roomSpecialTypes.removeFreezeExitTile((InteractionFreezeExitTile) item);
} else if (item instanceof InteractionNest) {
this.roomSpecialTypes.removeNest((InteractionNest) item);
} else if (item instanceof InteractionPetDrink) {
this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item);
} else if (item instanceof InteractionPetFood) {
this.roomSpecialTypes.removePetFood((InteractionPetFood) item);
} else if (item instanceof InteractionPetToy) {
this.roomSpecialTypes.removePetToy((InteractionPetToy) item);
} else if (item instanceof InteractionPetTree) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPetTrampoline) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMoodLight) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPyramid) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMusicDisc) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBattleBanzaiSphere) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTalkingFurniture) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWaterItem) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWater) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionMuteArea) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTagPole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTagField) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionJukeBox) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionPetBreedingNest) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBlackHole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionWiredHighscore) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionStickyPole) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof WiredBlob) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionTent) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.roomSpecialTypes.removeUndefined(item);
} else if (item instanceof InteractionBuildArea) {
this.roomSpecialTypes.removeUndefined(item);
}
}
}
@ -3320,47 +3061,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
for (Habbo habbo : this.getHabbos()) {
if (habbo == null) { return ; }
if (habbo == null) {
return;
}
if (!habbo.getHabboStats().isIgnoreBots())
habbo.getClient().sendResponse(message);
}
}
private void loadRights(Connection connection) {
this.rights.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
this.rights.add(set.getInt(DatabaseConstants.USER_ID));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
private void loadBans(Connection connection) {
this.bannedHabbos.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) {
statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.setInt(2, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
if (this.bannedHabbos.containsKey(set.getInt(DatabaseConstants.USER_ID)))
continue;
this.bannedHabbos.put(set.getInt(DatabaseConstants.USER_ID), new RoomBan(set));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
}
}
public RoomRightLevels getGuildRightLevel(Habbo habbo) {
if (this.guildId > 0 && habbo.getHabboStats().hasGuild(this.guildId)) {
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(this.guildId);
@ -3609,17 +3317,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
Habbo habbo = roomUnit.getRoom().getHabbo(roomUnit);
if (roomUnit.getRoomUnitType() == RoomUnitType.USER && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) { return; }
if (duration == -1 || duration == Integer.MAX_VALUE) {
duration = Integer.MAX_VALUE;
} else {
duration += Emulator.getIntUnixTimestamp();
}
if (roomUnit.getRoomUnitType() == RoomUnitType.USER && (habbo == null || habbo.getHabboInfo().isInGame() && !ignoreChecks)) {
return;
}
if (duration == -1 || duration == Integer.MAX_VALUE) {
duration = Integer.MAX_VALUE;
} else {
duration += Emulator.getIntUnixTimestamp();
}
if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming()) {
roomUnit.setEffectId(effectId, duration);
this.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose());
}
if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming()) {
roomUnit.setEffectId(effectId, duration);
this.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose());
}
}
public void giveHandItem(Habbo habbo, int handItem) {
@ -3951,7 +3661,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) {
if (this.itemCount() >= Room.MAXIMUM_FURNI) {
if (this.itemCount() >= RoomConfiguration.MAXIMUM_FURNI) {
return FurnitureMovementError.MAX_ITEMS;
}

View File

@ -0,0 +1,21 @@
package com.eu.habbo.habbohotel.rooms;
import gnu.trove.map.hash.TIntObjectHashMap;
public class RoomConfiguration {
//Configuration. Loaded from database & updated accordingly.
public static boolean HABBO_CHAT_DELAY = false;
public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10;
public static int MAXIMUM_FURNI = 2500;
public static int MAXIMUM_POSTITNOTES = 200;
public static int HAND_ITEM_TIME = 10;
public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480;
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
public static boolean MUTEAREA_CAN_WHISPER = false;
public static final double MAXIMUM_FURNI_HEIGHT = 40d;
public static final String CAUGHT_EXCEPTION = "Caught exception";
}

View File

@ -1,12 +1,12 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.set.hash.THashSet;
import lombok.extern.slf4j.Slf4j;
import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.List;
@ -229,6 +229,9 @@ public class RoomLayout {
return this.roomTiles[x][y].relativeHeight();
}
public RoomTile getTile(HabboItem tile){
return getTile(tile.getX(), tile.getY());
}
public RoomTile getTile(short x, short y) {
if (this.tileExists(x, y)) {
return this.roomTiles[x][y];
@ -382,7 +385,7 @@ public class RoomLayout {
if (this.canWalkOn(temp, unit)) {
if (temp.getState() != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
temp.isDiagonally(false);
adj.add(temp);
adj.add(temp);
}
}
}
@ -589,9 +592,9 @@ public class RoomLayout {
}
public RoomTile getRandomWalkableTilesAround(RoomUnit roomUnit, RoomTile tile, Room room, int radius) {
if(!this.tileExists(tile.getX(), tile.getY())) {
tile = this.getTile(roomUnit.getX(), roomUnit.getY());
room.getBot(roomUnit).needsUpdate(true);
if (!this.tileExists(tile.getX(), tile.getY())) {
tile = this.getTile(roomUnit.getX(), roomUnit.getY());
room.getBot(roomUnit).needsUpdate(true);
}
List<RoomTile> newTiles = new ArrayList<>();
@ -645,37 +648,37 @@ public class RoomLayout {
return true;
}
public THashSet<RoomTile> getTilesAt(RoomTile tile, HabboItem item) {
return getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
}
public THashSet<RoomTile> getTilesAt(RoomTile tile, int width, int length, int rotation) {
THashSet<RoomTile> pointList = new THashSet<>(width * length, 0.1f);
if (tile != null) {
if (rotation == 0 || rotation == 4) {
for (short i = tile.getX(); i <= (tile.getX() + (width - 1)); i++) {
for (short j = tile.getY(); j <= (tile.getY() + (length - 1)); j++) {
RoomTile t = this.getTile(i, j);
short x = tile.getX();
short y = tile.getY();
short addWidth = (short) (x + (width - 1));
short addLength = (short) (y + (length - 1));
if (t != null) {
pointList.add(t);
}
}
}
} else if (rotation == 2 || rotation == 6) {
for (short i = tile.getX(); i <= (tile.getX() + (length - 1)); i++) {
for (short j = tile.getY(); j <= (tile.getY() + (width - 1)); j++) {
RoomTile t = this.getTile(i, j);
if (t != null) {
pointList.add(t);
}
}
}
} else if (rotation == 1 || rotation == 3 || rotation == 5 || rotation == 7) {
RoomTile t = this.getTile(tile.getX(), tile.getY());
if (t != null) {
switch (rotation) {
case 0, 4 -> addRoomTilesToPointsList(x, addWidth, y, addLength, pointList);
case 2, 6 -> addRoomTilesToPointsList(x, addLength, y, addWidth, pointList);
default -> {
RoomTile t = this.getTile(x, y);
if (t != null)
pointList.add(t);
}
}
}
return pointList;
}
private void addRoomTilesToPointsList (short minX, short maxX, short minY, short maxY, THashSet<RoomTile> pointList){
for (short i = minX; i <= maxX; i++) {
for (short j = minY; j <= maxY; j++) {
RoomTile t = this.getTile(i, j);
if (t != null)
pointList.add(t);
}
}
}
}

View File

@ -670,10 +670,9 @@ public class RoomSpecialTypes {
public THashSet<HabboItem> getItemsOfType(Class<? extends HabboItem> type) {
THashSet<HabboItem> items = new THashSet<>();
synchronized (this.undefined) {
for (HabboItem item : this.undefined.values()) {
if (item.getClass() == type)
items.add(item);
}
this.undefined.values().stream()
.filter(item -> item.getClass() == type)
.forEach(items::add);
}
return items;

View File

@ -635,7 +635,7 @@ public class RoomUnit {
}
public boolean isIdle() {
return this.idleTimer > Room.IDLE_CYCLES; //Amount of room cycles / 2 = seconds.
return this.idleTimer > RoomConfiguration.IDLE_CYCLES; //Amount of room cycles / 2 = seconds.
}
public int getIdleTimer() {
@ -647,7 +647,7 @@ public class RoomUnit {
}
public void setIdle() {
this.idleTimer = Room.IDLE_CYCLES + 1;
this.idleTimer = RoomConfiguration.IDLE_CYCLES + 1;
}
public void lookAtPoint(RoomTile location) {

View File

@ -0,0 +1,15 @@
package com.eu.habbo.habbohotel.rooms.utils;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
@Getter
public class HabboItemGetter {
List<IHabboItemGetter> itemGetters;
public HabboItemGetter() {
itemGetters = Arrays.asList(new BanzaiTeleporterGetter(), new TriggerGetter(), new EffectGetter(), new ConditionGetter(), new GameGateGetter(), new GameScoreboardGetter(), new GameTimerGetter(), new FreezeExitTilesGetter(), new RollerGetter(), new NestGetter(), new PetDrinkGetter(), new PetFoodGetter());
}
}

View File

@ -0,0 +1,82 @@
package com.eu.habbo.habbohotel.rooms.utils;
import com.eu.habbo.habbohotel.rooms.RoomSpecialTypes;
import com.eu.habbo.habbohotel.users.HabboItem;
public interface IHabboItemGetter {
HabboItem get(int id, RoomSpecialTypes roomSpecialTypes);
}
class BanzaiTeleporterGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getBanzaiTeleporter(id);
}
}
class TriggerGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getTrigger(id);
}
}
class EffectGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getEffect(id);
}
}
class ConditionGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getCondition(id);
}
}
class GameGateGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getGameGate(id);
}
}
class GameScoreboardGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getGameScorebord(id);
}
}
class GameTimerGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getGameTimer(id);
}
}
class FreezeExitTilesGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getFreezeExitTiles().get(id);
}
}
class RollerGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getRoller(id);
}
}
class NestGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getNest(id);
}
}
class PetDrinkGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getPetDrink(id);
}
}
class PetFoodGetter implements IHabboItemGetter {
public HabboItem get(int id, RoomSpecialTypes roomSpecialTypes) {
return roomSpecialTypes.getPetFood(id);
}
}

View File

@ -0,0 +1,213 @@
package com.eu.habbo.habbohotel.rooms.utils;
import com.eu.habbo.Emulator;
import com.eu.habbo.database.DatabaseConstants;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
import static com.eu.habbo.habbohotel.rooms.RoomConfiguration.CAUGHT_EXCEPTION;
@Slf4j
public class RoomLoader {
public static TIntArrayList loadRights(Connection connection, int id) {
TIntArrayList rights = new TIntArrayList();
try (PreparedStatement statement = connection.prepareStatement("SELECT user_id FROM room_rights WHERE room_id = ?")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
rights.add(set.getInt(DatabaseConstants.USER_ID));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
return rights;
}
public static TIntObjectHashMap<RoomBan> loadBans(Connection connection, int id) {
TIntObjectHashMap<RoomBan> bannedHabbos = new TIntObjectHashMap<>();
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username, users.id, room_bans.* FROM room_bans INNER JOIN users ON room_bans.user_id = users.id WHERE ends > ? AND room_bans.room_id = ?")) {
statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.setInt(2, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
if (bannedHabbos.containsKey(set.getInt(DatabaseConstants.USER_ID)))
continue;
bannedHabbos.put(set.getInt(DatabaseConstants.USER_ID), new RoomBan(set));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
}
return bannedHabbos;
}
public static synchronized void loadBots(Connection connection, int id, Room room) {
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots INNER JOIN users ON bots.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Bot b = Emulator.getGameEnvironment().getBotManager().loadBot(set);
if (b != null) {
b.setRoom(room);
b.setRoomUnit(new RoomUnit());
b.getRoomUnit().setPathFinderRoom(room);
b.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (b.getRoomUnit().getCurrentLocation() == null || b.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) {
b.getRoomUnit().setZ(room.getLayout().getDoorTile().getStackHeight());
b.getRoomUnit().setLocation(room.getLayout().getDoorTile());
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(room.getLayout().getDoorDirection()));
} else {
b.getRoomUnit().setZ(set.getDouble("z"));
b.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
}
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
b.getRoomUnit().setInRoom(true);
room.giveEffect(b.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
room.addBot(b);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public static synchronized void loadPets(Connection connection, int id, Room room) {
try (PreparedStatement statement = connection.prepareStatement("SELECT users.username as pet_owner_name, users_pets.* FROM users_pets INNER JOIN users ON users_pets.user_id = users.id WHERE room_id = ?")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
Pet pet = PetManager.loadPet(set);
pet.setRoom(room);
pet.setRoomUnit(new RoomUnit());
pet.getRoomUnit().setPathFinderRoom(room);
pet.getRoomUnit().setLocation(room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
if (pet.getRoomUnit().getCurrentLocation() == null || pet.getRoomUnit().getCurrentLocation().getState() == RoomTileState.INVALID) {
pet.getRoomUnit().setZ(room.getLayout().getDoorTile().getStackHeight());
pet.getRoomUnit().setLocation(room.getLayout().getDoorTile());
pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(room.getLayout().getDoorDirection()));
} else {
pet.getRoomUnit().setZ(set.getDouble("z"));
pet.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
}
pet.getRoomUnit().setRoomUnitType(RoomUnitType.PET);
pet.getRoomUnit().setCanWalk(true);
room.addPet(pet);
room.getFurniOwnerNames().put(pet.getUserId(), set.getString("pet_owner_name"));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public static synchronized void loadWordFilter(Connection connection, int id, THashSet<String> wordFilterWords) {
wordFilterWords.clear();
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM room_wordfilter WHERE room_id = ?")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
wordFilterWords.add(set.getString("word"));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public static synchronized void loadHeightmap(Room room, int id) {
try {
if (room.getLayout() != null) {
for (short x = 0; x < room.getLayout().getMapSizeX(); x++) {
for (short y = 0; y < room.getLayout().getMapSizeY(); y++) {
RoomTile tile = room.getLayout().getTile(x, y);
if (tile != null) {
room.updateTile(tile);
}
}
}
} else {
log.error("Unknown Room Layout for Room (ID: {})", id);
}
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public static synchronized void loadItems(Connection connection,int id, Room room) {
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE room_id = ?")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
room.addHabboItem(Emulator.getGameEnvironment().getItemManager().loadHabboItem(set));
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
public static synchronized void loadWiredData(Connection connection, int id, Room room) {
try (PreparedStatement statement = connection.prepareStatement("SELECT id, wired_data FROM items WHERE room_id = ? AND wired_data<>''")) {
statement.setInt(1, id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
try {
HabboItem item = room.getHabboItem(set.getInt("id"));
if (item instanceof InteractionWired interactionWired) {
interactionWired.loadWiredData(set, room);
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
}
}
}
} catch (SQLException e) {
log.error(CAUGHT_SQL_EXCEPTION, e);
} catch (Exception e) {
log.error(CAUGHT_EXCEPTION, e);
}
}
}

View File

@ -505,4 +505,6 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
this.getBaseItem().getLength() + (marginY * 2),
this.getRotation());
}
public void addToSpecialRoomTypes(RoomSpecialTypes roomSpecialTypes){}
}

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt;
import com.eu.habbo.habbohotel.items.interactions.InteractionStickyPole;
import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomConfiguration;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
@ -26,7 +27,7 @@ public class PlacePostItEvent extends MessageHandler {
HabboItem item = this.client.getHabbo().getInventory().getItemsComponent().getHabboItem(itemId);
if (item instanceof InteractionPostIt) {
if (room.getPostItNotes().size() < Room.MAXIMUM_POSTITNOTES) {
if (room.getPostItNotes().size() < RoomConfiguration.MAXIMUM_POSTITNOTES) {
room.addHabboItem(item);
item.setExtradata("FFFF33");
item.setRoomId(this.client.getHabbo().getHabboInfo().getCurrentRoom().getId());

View File

@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items;
import com.eu.habbo.habbohotel.items.interactions.InteractionStackHelper;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomConfiguration;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
@ -34,7 +35,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler {
}
}
} else {
stackerHeight = Math.min(Math.max(stackerHeight, itemTile.getZ() * 100.0), Room.MAXIMUM_FURNI_HEIGHT * 100);
stackerHeight = Math.min(Math.max(stackerHeight, itemTile.getZ() * 100.0), RoomConfiguration.MAXIMUM_FURNI_HEIGHT * 100);
}
double height = 0;

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
import com.eu.habbo.habbohotel.items.interactions.pets.InteractionMonsterPlantSeed;
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomConfiguration;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
@ -50,7 +51,7 @@ public class UseFurnitureEvent extends MessageHandler {
if (handleMonsterPlantSeed(room, item)) return;
if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase()) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) {
if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase()) && room.getCurrentPets().size() < RoomConfiguration.MAXIMUM_PETS) {
this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item));
return;
}

View File

@ -29,7 +29,7 @@ public class PlacePetEvent extends MessageHandler {
if (pet == null) {
return;
}
if (room.getCurrentPets().size() >= Room.MAXIMUM_PETS && !this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS)) {
if (room.getCurrentPets().size() >= RoomConfiguration.MAXIMUM_PETS && !this.client.getHabbo().hasRight(Permission.ACC_UNLIMITED_PETS)) {
this.client.sendResponse(new PetPlacingErrorComposer(PetPlacingErrorComposer.ROOM_ERROR_MAX_PETS));
return;
}

View File

@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.rooms.items;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
@ -49,8 +50,9 @@ public class FloorItemOnRollerComposer extends MessageComposer {
this.response.appendString(Double.toString(this.oldLocation != null ? this.newZ : (this.item.getZ() + this.heightOffset)));
this.response.appendInt(this.roller != null ? this.roller.getId() : -1);
if(this.oldLocation == null) {
this.item.onMove(this.room, this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.newLocation);
if (this.oldLocation == null) {
RoomLayout roomLayout = this.room.getLayout();
this.item.onMove(this.room, roomLayout.getTile(this.item.getX(), this.item.getY()), this.newLocation);
this.item.setX(this.newLocation.getX());
this.item.setY(this.newLocation.getY());
this.item.setZ(this.item.getZ() + this.heightOffset);
@ -58,8 +60,8 @@ public class FloorItemOnRollerComposer extends MessageComposer {
//TODO This is bad
//
THashSet<RoomTile> tiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(oldX, oldY), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation());
tiles.addAll(this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation()));
THashSet<RoomTile> tiles = roomLayout.getTilesAt(roomLayout.getTile(oldX, oldY), this.item);
tiles.addAll(roomLayout.getTilesAt(roomLayout.getTile(this.item), this.item));
this.room.updateTiles(tiles);
//this.room.sendComposer(new UpdateStackHeightComposer(oldX, oldY, this.room.getStackHeight(oldX, oldY, true)).compose());
//

View File

@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.rooms.users;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomConfiguration;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
@ -21,7 +22,7 @@ public class UserNameChangedMessageComposer extends MessageComposer {
public UserNameChangedMessageComposer(Habbo habbo, boolean includePrefix) {
this.userId = habbo.getHabboInfo().getId();
this.roomId = habbo.getRoomUnit().getId();
this.name = (includePrefix ? Room.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getPermissionGroup().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getPermissionGroup().getPrefix()) : "") + habbo.getHabboInfo().getUsername();
this.name = (includePrefix ? RoomConfiguration.PREFIX_FORMAT.replace("%color%", habbo.getHabboInfo().getPermissionGroup().getPrefixColor()).replace("%prefix%", habbo.getHabboInfo().getPermissionGroup().getPrefix()) : "") + habbo.getHabboInfo().getUsername();
}
@Override

View File

@ -76,8 +76,8 @@ public class PluginManager {
Messenger.SAVE_PRIVATE_CHATS = Emulator.getConfig().getBoolean("save.private.chats", false);
PacketManager.DEBUG_SHOW_PACKETS = Emulator.getConfig().getBoolean("debug.show.packets");
PacketManager.MULTI_THREADED_PACKET_HANDLING = Emulator.getConfig().getBoolean("io.client.multithreaded.handler");
Room.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false);
Room.MUTEAREA_CAN_WHISPER = Emulator.getConfig().getBoolean("room.chat.mutearea.allow_whisper", false);
RoomConfiguration.HABBO_CHAT_DELAY = Emulator.getConfig().getBoolean("room.chat.delay", false);
RoomConfiguration.MUTEAREA_CAN_WHISPER = Emulator.getConfig().getBoolean("room.chat.mutearea.allow_whisper", false);
RoomChatMessage.SAVE_ROOM_CHATS = Emulator.getConfig().getBoolean("save.room.chats", false);
RoomLayout.MAXIMUM_STEP_HEIGHT = Emulator.getConfig().getDouble("pathfinder.step.maximum.height", 1.1);
RoomLayout.ALLOW_FALLING = Emulator.getConfig().getBoolean("pathfinder.step.allow.falling", true);
@ -99,14 +99,14 @@ public class PluginManager {
HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items");
Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.users.max.friends", 300);
Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.users.max.friends.hc", 1100);
Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room");
Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room");
Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500);
Room.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200);
Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240);
Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480);
Room.ROLLERS_MAXIMUM_ROLL_AVATARS = Emulator.getConfig().getInt("hotel.room.rollers.roll_avatars.max", 1);
RoomConfiguration.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room");
RoomConfiguration.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room");
RoomConfiguration.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500);
RoomConfiguration.MAXIMUM_POSTITNOTES = Emulator.getConfig().getInt("hotel.room.stickies.max", 200);
RoomConfiguration.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
RoomConfiguration.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240);
RoomConfiguration.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480);
RoomConfiguration.ROLLERS_MAXIMUM_ROLL_AVATARS = Emulator.getConfig().getInt("hotel.room.rollers.roll_avatars.max", 1);
RoomManager.MAXIMUM_ROOMS_USER = Emulator.getConfig().getInt("hotel.users.max.rooms", 50);
RoomManager.MAXIMUM_ROOMS_HC = Emulator.getConfig().getInt("hotel.users.max.rooms.hc", 75);
RoomManager.HOME_ROOM_ID = Emulator.getConfig().getInt("hotel.home.room");
@ -129,7 +129,7 @@ public class PluginManager {
}
HabboManager.WELCOME_MESSAGE = Emulator.getConfig().getValue("hotel.welcome.alert.message").replace("<br>", "<br/>").replace("<br />", "<br/>").replace("\\r", "\r").replace("\\n", "\n").replace("\\t", "\t");
Room.PREFIX_FORMAT = Emulator.getConfig().getValue("room.chat.prefix.format");
RoomConfiguration.PREFIX_FORMAT = Emulator.getConfig().getValue("room.chat.prefix.format");
UpdateFloorPropertiesEvent.MAXIMUM_FLOORPLAN_WIDTH_LENGTH = Emulator.getConfig().getInt("hotel.floorplan.max.widthlength");
UpdateFloorPropertiesEvent.MAXIMUM_FLOORPLAN_SIZE = Emulator.getConfig().getInt("hotel.floorplan.max.totalarea");