diff --git a/featurelist.md b/featurelist.md
index 7f494997..3a63b5ab 100644
--- a/featurelist.md
+++ b/featurelist.md
@@ -132,7 +132,7 @@ If you wish to contribute to this list, features are laid out in the following f
> [`Habbo.getHabboStats()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L94)
> [`Habbo.getRoomUnit()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java#L102)
> [`HabboManager`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java)
-> [`HabboManager.getOfflineHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L47)
+> [`Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L47)
> [`HabboManager.getCloneAccounts()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L203)
> [`HabboManager.setRank()`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java#L243)
> [`HabboInfo`](https://git.krews.org/morningstar/Arcturus-Community/-/blob/dev/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java)
diff --git a/pom.xml b/pom.xml
index 4f2ad716..ef4c1a5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -104,6 +104,25 @@
2.8.9
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.15.2
+
+
+
+ com.fasterxml.jackson.core
+ jackson-annotations
+ 2.15.2
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.15.2
+
+
mysql
diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
index 2c691133..62e2cffd 100644
--- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
@@ -45,7 +45,7 @@ public class CreditsScheduler extends Scheduler {
try {
if (habbo != null) {
- if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
+ if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
diff --git a/src/main/java/com/eu/habbo/core/Easter.java b/src/main/java/com/eu/habbo/core/Easter.java
index 40b57a6c..0c0007bf 100644
--- a/src/main/java/com/eu/habbo/core/Easter.java
+++ b/src/main/java/com/eu/habbo/core/Easter.java
@@ -15,7 +15,7 @@ public class Easter {
if (Emulator.getConfig().getBoolean("easter_eggs.enabled") && event.getNewMotto().equalsIgnoreCase("crickey!")) {
event.habbo.getClient().sendResponse(new WhisperMessageComposer(new RoomChatMessage(event.getNewMotto(), event.habbo, event.habbo, RoomChatMessageBubbles.ALERT)));
- Room room = event.habbo.getHabboInfo().getCurrentRoom();
+ Room room = event.habbo.getRoomUnit().getRoom();
room.sendComposer(new UserRemoveMessageComposer(event.habbo.getRoomUnit()).compose());
room.sendComposer(new RoomUserPetComposer(2, 1, "FFFFFF", event.habbo).compose());
diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
index 8b19429c..66c70e8b 100644
--- a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
@@ -45,7 +45,7 @@ public class GotwPointsScheduler extends Scheduler {
try {
if (habbo != null) {
- if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
+ if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java
index ac36ec14..0bd440bf 100644
--- a/src/main/java/com/eu/habbo/core/PixelScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java
@@ -40,7 +40,7 @@ public class PixelScheduler extends Scheduler {
habbo = map.getValue();
try {
if (habbo != null) {
- if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
+ if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java
index 1fce2860..664026f3 100644
--- a/src/main/java/com/eu/habbo/core/PointsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java
@@ -44,7 +44,7 @@ public class PointsScheduler extends Scheduler {
try {
if (habbo != null) {
- if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
+ if (habbo.getRoomUnit().getRoom() == null && IGNORE_HOTEL_VIEW)
continue;
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
diff --git a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
index 515334d5..0b6926e5 100644
--- a/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
+++ b/src/main/java/com/eu/habbo/core/RoomUserPetComposer.java
@@ -22,10 +22,10 @@ public class RoomUserPetComposer extends MessageComposer {
this.response.appendString(this.habbo.getHabboInfo().getUsername());
this.response.appendString("");
this.response.appendString(this.petType + " " + this.race + " " + this.color + " 2 2 -1 0 3 -1 0");
- this.response.appendInt(this.habbo.getRoomUnit().getId());
- this.response.appendInt(this.habbo.getRoomUnit().getX());
- this.response.appendInt(this.habbo.getRoomUnit().getY());
- this.response.appendString(this.habbo.getRoomUnit().getZ() + "");
+ this.response.appendInt(this.habbo.getRoomUnit().getVirtualId());
+ this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getX());
+ this.response.appendInt(this.habbo.getRoomUnit().getCurrentPosition().getY());
+ this.response.appendString(this.habbo.getRoomUnit().getCurrentZ() + "");
this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue());
this.response.appendInt(2);
this.response.appendInt(this.petType);
diff --git a/src/main/java/com/eu/habbo/database/DatabaseConstants.java b/src/main/java/com/eu/habbo/database/DatabaseConstants.java
index 5b4a706f..4a55cb3f 100644
--- a/src/main/java/com/eu/habbo/database/DatabaseConstants.java
+++ b/src/main/java/com/eu/habbo/database/DatabaseConstants.java
@@ -4,4 +4,4 @@ public class DatabaseConstants {
public static final String CAUGHT_SQL_EXCEPTION = "Caught SQL exception";
public final static String USER_ID = "user_id";
-}
+}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
index a7c23ace..37e1e048 100644
--- a/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
@@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.achievements;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.achievements.AchievementComposer;
import com.eu.habbo.messages.outgoing.achievements.AchievementUnlockedComposer;
import com.eu.habbo.messages.outgoing.achievements.talenttrack.TalentLevelUpComposer;
@@ -17,7 +17,6 @@ import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.users.achievements.UserAchievementLeveledEvent;
import com.eu.habbo.plugin.events.users.achievements.UserAchievementProgressEvent;
import gnu.trove.map.hash.THashMap;
-import gnu.trove.procedure.TObjectIntProcedure;
import lombok.extern.slf4j.Slf4j;
import java.sql.*;
@@ -155,8 +154,8 @@ public class AchievementManager {
Emulator.getThreading().run(badge);
- if (badge.getSlot() > 0 && habbo.getHabboInfo().getCurrentRoom() != null) {
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose());
+ if (badge.getSlot() > 0 && habbo.getRoomUnit().getRoom() != null) {
+ habbo.getRoomUnit().getRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose());
}
habbo.getClient().sendResponse(new UnseenItemsComposer(badge.getId(), UnseenItemsComposer.AddHabboItemCategory.BADGE));
@@ -167,8 +166,8 @@ public class AchievementManager {
habbo.givePoints(newLevel.getRewardType(), newLevel.getRewardAmount());
}
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose());
+ if (habbo.getRoomUnit().getRoom() != null) {
+ habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose());
}
}
}
@@ -339,7 +338,7 @@ public class AchievementManager {
if (level != null) {
if (level.items != null && !level.items.isEmpty()) {
for (Item item : level.items) {
- HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
+ RoomItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
habbo.getInventory().getItemsComponent().addItem(rewardItem);
habbo.getClient().sendResponse(new UnseenItemsComposer(rewardItem));
habbo.getClient().sendResponse(new FurniListInvalidateComposer());
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
index b10086cf..c888aacb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
@@ -1,18 +1,26 @@
package com.eu.habbo.habbohotel.bots;
import com.eu.habbo.Emulator;
-import com.eu.habbo.database.DatabaseConstants;
-import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.rooms.RoomUserAction;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
+import com.eu.habbo.habbohotel.units.type.Avatar;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
+import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.*;
import com.eu.habbo.plugin.events.bots.BotChatEvent;
import com.eu.habbo.plugin.events.bots.BotShoutEvent;
import com.eu.habbo.plugin.events.bots.BotTalkEvent;
import com.eu.habbo.plugin.events.bots.BotWhisperEvent;
-import com.eu.habbo.threading.runnables.BotFollowHabbo;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
@@ -21,14 +29,14 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.List;
+
+import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
@Slf4j
-public class Bot implements Runnable {
- public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
- public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
-
- private final ArrayList chatLines;
+@Getter
+@Setter
+@Accessors(chain = true)
+public class Bot extends Avatar implements Runnable {
private transient int id;
private String name;
private String motto;
@@ -36,45 +44,24 @@ public class Bot implements Runnable {
private HabboGender gender;
private int ownerId;
private String ownerName;
- private Room room;
- private RoomUnit roomUnit;
+
+ private HabboInfo ownerInfo;
+
private boolean chatAuto;
private boolean chatRandom;
private short chatDelay;
private int chatTimeOut;
private int chatTimestamp;
private short lastChatIndex;
- private final int bubble;
-
-
+ private final int bubbleId;
private final String type;
-
-
private int effect;
-
- private transient boolean canWalk = true;
-
- private boolean needsUpdate;
-
-
+ private boolean sqlUpdateNeeded;
private transient int followingHabboId;
-
- public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) {
- this.id = id;
- this.name = name;
- this.motto = motto;
- this.figure = figure;
- this.gender = gender;
- this.ownerId = ownerId;
- this.ownerName = ownerName;
- this.chatAuto = false;
- this.chatRandom = false;
- this.chatDelay = 1000;
- this.chatLines = new ArrayList<>();
- this.type = "generic_bot";
- this.room = null;
- this.bubble = RoomChatMessageBubbles.BOT_RENTABLE.getType();
- }
+ protected final RoomBot roomUnit;
+ public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
+ public static String[] PLACEMENT_MESSAGES = "Yo!;Hello I'm a real party animal!;Hello!".split(";");
+ private final ArrayList chatLines;
public Bot(ResultSet set) throws SQLException {
this.id = set.getInt("id");
@@ -82,69 +69,46 @@ public class Bot implements Runnable {
this.motto = set.getString("motto");
this.figure = set.getString("figure");
this.gender = HabboGender.valueOf(set.getString("gender"));
- this.ownerId = set.getInt(DatabaseConstants.USER_ID);
+
+ //@Deprecated
+ this.ownerId = set.getInt("owner_id");
this.ownerName = set.getString("owner_name");
+
+ this.ownerInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(set.getInt("owner_id"));
+
this.chatAuto = set.getString("chat_auto").equals("1");
this.chatRandom = set.getString("chat_random").equals("1");
this.chatDelay = set.getShort("chat_delay");
this.chatLines = new ArrayList<>(Arrays.asList(set.getString("chat_lines").split("\r")));
this.type = set.getString("type");
this.effect = set.getInt("effect");
- this.canWalk = set.getString("freeroam").equals("1");
- this.room = null;
- this.roomUnit = null;
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
- this.needsUpdate = false;
- this.bubble = set.getInt("bubble_id");
+ this.sqlUpdateNeeded = false;
+ this.bubbleId = set.getInt("bubble_id");
+
+ this.roomUnit = new RoomBot();
+ this.roomUnit.setUnit(this);
+
+ this.roomUnit.setCanWalk(set.getString("freeroam").equals("1"));
}
- public Bot(Bot bot) {
- this.name = bot.getName();
- this.motto = bot.getMotto();
- this.figure = bot.getFigure();
- this.gender = bot.getGender();
- this.ownerId = bot.getOwnerId();
- this.ownerName = bot.getOwnerName();
- this.chatAuto = true;
- this.chatRandom = false;
- this.chatDelay = 10;
- this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
- this.chatLines = new ArrayList<>(List.of("Default Message :D"));
- this.type = bot.getType();
- this.effect = bot.getEffect();
- this.bubble = bot.getBubbleId();
- this.needsUpdate = false;
- }
+ public static void initialise() {}
- public static void initialise() {
-
- }
-
- public static void dispose() {
-
- }
-
- public void needsUpdate(boolean needsUpdate) {
- this.needsUpdate = needsUpdate;
- }
-
- public boolean needsUpdate() {
- return this.needsUpdate;
- }
+ public static void dispose() {}
@Override
public void run() {
- if (this.needsUpdate) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) {
+ if (this.sqlUpdateNeeded) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, owner_id = ?, room_id = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ?, x = ?, y = ?, z = ? WHERE id = ?")) {
statement.setString(1, this.name);
statement.setString(2, this.motto);
statement.setString(3, this.figure);
statement.setString(4, this.gender.toString());
- statement.setInt(5, this.ownerId);
- statement.setInt(6, this.room == null ? 0 : this.room.getId());
- statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue());
- statement.setInt(8, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType());
- statement.setString(9, this.canWalk ? "1" : "0");
+ statement.setInt(5, this.ownerInfo.getId());
+ statement.setInt(6, this.roomUnit.getRoom() == null ? 0 : this.roomUnit.getRoom().getRoomInfo().getId());
+ statement.setInt(7, this.roomUnit.getBodyRotation().getValue());
+ statement.setInt(8, this.roomUnit.getDanceType().getType());
+ statement.setString(9, this.roomUnit.isCanWalk() ? "1" : "0");
StringBuilder text = new StringBuilder();
for (String s : this.chatLines) {
text.append(s).append("\r");
@@ -154,90 +118,51 @@ public class Bot implements Runnable {
statement.setString(12, this.chatRandom ? "1" : "0");
statement.setInt(13, this.chatDelay);
statement.setInt(14, this.effect);
- statement.setInt(15, this.bubble);
- statement.setInt(16, this.id);
+ statement.setInt(15, this.bubbleId);
+ statement.setInt(16, this.roomUnit.getSpawnTile() == null ? 0 : this.roomUnit.getSpawnTile().getX());
+ statement.setInt(17, this.roomUnit.getSpawnTile() == null ? 0 : this.roomUnit.getSpawnTile().getY());
+ statement.setDouble(18, this.roomUnit.getSpawnHeight());
+ statement.setInt(19, this.id);
statement.execute();
- this.needsUpdate = false;
+ this.sqlUpdateNeeded = false;
} catch (SQLException e) {
- log.error("Caught SQL exception", e);
- }
- }
- }
-
- public void cycle(boolean allowBotsWalk) {
- if (this.roomUnit != null) {
- if (allowBotsWalk && this.canWalk) {
- if (!this.roomUnit.isWalking()) {
- if (this.roomUnit.getWalkTimeOut() < Emulator.getIntUnixTimestamp() && this.followingHabboId == 0) {
- this.roomUnit.setGoalLocation(Emulator.getConfig().getBoolean("hotel.bot.limit.walking.distance", true) ? this.room.getLayout().getRandomWalkableTilesAround(this.roomUnit, this.room.getLayout().getTile(this.roomUnit.getBotStartLocation().getX(), this.roomUnit.getBotStartLocation().getY()), this.room, Emulator.getConfig().getInt("hotel.bot.limit.walking.distance.radius", 5)) : this.room.getRandomWalkableTile());
-
- int timeOut = Emulator.getRandom().nextInt(20) * 2;
- this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp());
- }
- }/* else {
- for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) {
- WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
- }
- }*/
- }
-
- if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) {
- if (this.room != null) {
- this.lastChatIndex = (this.chatRandom ? (short) Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++));
-
- if (this.lastChatIndex >= this.chatLines.size()) {
- this.lastChatIndex = 0;
- }
-
- String message = this.chatLines.get(this.lastChatIndex)
- .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), this.room.getOwnerName())
- .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), this.room.itemCount() + "")
- .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.name)
- .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), this.room.getName())
- .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), this.room.getUserCount() + "");
-
- if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{ message })) {
- this.talk(message);
- }
-
- this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
- }
+ log.error(CAUGHT_SQL_EXCEPTION, e);
}
}
}
public void talk(String message) {
- if (this.room != null) {
+ if (this.roomUnit.getRoom() != null) {
BotChatEvent event = new BotTalkEvent(this, message);
if (Emulator.getPluginManager().fireEvent(event).isCancelled())
return;
this.chatTimestamp = Emulator.getIntUnixTimestamp();
- this.room.botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
+ this.roomUnit.getRoom().botChat(new ChatMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
if (message.equals("o/") || message.equals("_o/")) {
- this.room.sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose());
+ this.roomUnit.getRoom().sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose());
}
}
}
public void shout(String message) {
- if (this.room != null) {
+ if (this.roomUnit.getRoom() != null) {
BotChatEvent event = new BotShoutEvent(this, message);
if (Emulator.getPluginManager().fireEvent(event).isCancelled())
return;
this.chatTimestamp = Emulator.getIntUnixTimestamp();
- this.room.botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
+ this.roomUnit.getRoom().botChat(new ShoutMessageComposer(new RoomChatMessage(event.getMessage(), this.roomUnit, RoomChatMessageBubbles.getBubble(this.getBubbleId()))).compose());
if (message.equals("o/") || message.equals("_o/")) {
- this.room.sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose());
+ this.roomUnit.getRoom().sendComposer(new ExpressionMessageComposer(this.roomUnit, RoomUserAction.WAVE).compose());
}
}
}
public void whisper(String message, Habbo habbo) {
- if (this.room != null && habbo != null) {
+ if (this.roomUnit.getRoom() != null && habbo != null) {
BotWhisperEvent event = new BotWhisperEvent(this, message, habbo);
if (Emulator.getPluginManager().fireEvent(event).isCancelled())
return;
@@ -249,266 +174,147 @@ public class Bot implements Runnable {
public void onPlace(Habbo habbo, Room room) {
if (this.roomUnit != null) {
- room.giveEffect(this.roomUnit, this.effect, -1);
+ this.roomUnit.giveEffect(this.effect, -1);
}
if(PLACEMENT_MESSAGES.length > 0) {
String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)];
- if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) {
+ if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, room, new Object[]{message})) {
this.talk(message);
}
}
}
- public void onPickUp(Habbo habbo, Room room) {
+ public void onPickUp(Habbo habbo, Room room) {}
- }
-
- public void onUserSay(final RoomChatMessage message) {
-
- }
-
- public int getId() {
- return this.id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return this.name;
- }
-
- public int getBubbleId() {
- return bubble;
- }
+ public void onUserSay(final RoomChatMessage message) {}
public void setName(String name) {
this.name = name;
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
//if(this.room != null)
- //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose());
- }
-
- public String getMotto() {
- return this.motto;
+ //this.roomUnit.getRoom().sendComposer(new ChangeNameUpdatedComposer(this.roomUnit, this.getName()).compose());
}
public void setMotto(String motto) {
this.motto = motto;
- this.needsUpdate = true;
- }
-
- public String getFigure() {
- return this.figure;
+ this.sqlUpdateNeeded = true;
}
public void setFigure(String figure) {
this.figure = figure;
- this.needsUpdate = true;
-
- if (this.room != null)
- this.room.sendComposer(new RoomUsersComposer(this).compose());
- }
-
- public HabboGender getGender() {
- return this.gender;
+ this.sqlUpdateNeeded = true;
+ this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose());
}
public void setGender(HabboGender gender) {
this.gender = gender;
- this.needsUpdate = true;
-
- if (this.room != null)
- this.room.sendComposer(new RoomUsersComposer(this).compose());
- }
-
- public int getOwnerId() {
- return this.ownerId;
+ this.sqlUpdateNeeded = true;
+ this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose());
}
public void setOwnerId(int ownerId) {
this.ownerId = ownerId;
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
- if (this.room != null)
- this.room.sendComposer(new RoomUsersComposer(this).compose());
- }
-
- public String getOwnerName() {
- return this.ownerName;
+ if(this.roomUnit.getRoom() != null) {
+ this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose());
+ }
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
- if (this.room != null)
- this.room.sendComposer(new RoomUsersComposer(this).compose());
- }
-
- public Room getRoom() {
- return this.room;
- }
-
- public void setRoom(Room room) {
- this.room = room;
- }
-
- public RoomUnit getRoomUnit() {
- return this.roomUnit;
- }
-
- public void setRoomUnit(RoomUnit roomUnit) {
- this.roomUnit = roomUnit;
- }
-
- public boolean isChatAuto() {
- return this.chatAuto;
+ if(this.roomUnit.getRoom() != null) {
+ this.roomUnit.getRoom().sendComposer(new RoomUsersComposer(this).compose());
+ }
}
public void setChatAuto(boolean chatAuto) {
this.chatAuto = chatAuto;
- this.needsUpdate = true;
- }
-
- public boolean isChatRandom() {
- return this.chatRandom;
+ this.sqlUpdateNeeded = true;
}
public void setChatRandom(boolean chatRandom) {
this.chatRandom = chatRandom;
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
}
public boolean hasChat() {
return !this.chatLines.isEmpty();
}
- public int getChatDelay() {
- return this.chatDelay;
- }
-
public void setChatDelay(short chatDelay) {
this.chatDelay = (short) Math.min(Math.max(chatDelay, BotManager.MINIMUM_CHAT_SPEED), BotManager.MAXIMUM_CHAT_SPEED);
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
}
- public int getChatTimestamp() {
- return this.chatTimestamp;
- }
-
public void clearChat() {
synchronized (this.chatLines) {
this.chatLines.clear();
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
}
}
- public String getType() {
- return this.type;
- }
-
- public int getEffect() {
- return this.effect;
- }
-
public void setEffect(int effect, int duration) {
this.effect = effect;
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
- if (this.roomUnit != null) {
- if (this.room != null) {
- this.room.giveEffect(this.roomUnit, this.effect, duration);
- }
+ if (this.roomUnit.getRoom() != null) {
+ this.roomUnit.giveEffect(this.effect, duration);
}
}
public void addChatLines(ArrayList chatLines) {
synchronized (this.chatLines) {
this.chatLines.addAll(chatLines);
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
}
}
public void addChatLine(String chatLine) {
synchronized (this.chatLines) {
this.chatLines.add(chatLine);
- this.needsUpdate = true;
+ this.sqlUpdateNeeded = true;
}
}
- public ArrayList getChatLines() {
- return this.chatLines;
+ public void incrementLastChatIndex() {
+ this.lastChatIndex++;
}
- public int getFollowingHabboId() {
- return this.followingHabboId;
+ public void resetLastChatIndex() {
+ this.lastChatIndex = 0;
}
- public void startFollowingHabbo(Habbo habbo) {
- this.followingHabboId = habbo.getHabboInfo().getId();
-
- Emulator.getThreading().run(new BotFollowHabbo(this, habbo, habbo.getHabboInfo().getCurrentRoom()));
+ @Override
+ public void serialize(ServerMessage message) {
+ message.appendInt(-this.id);
+ message.appendString(this.name);
+ message.appendString(this.motto);
+ message.appendString(this.figure);
+ message.appendInt(this.roomUnit.getVirtualId());
+ message.appendInt(this.roomUnit.getCurrentPosition() == null ? 0 : this.roomUnit.getCurrentPosition().getX());
+ message.appendInt(this.roomUnit.getCurrentPosition() == null ? 0 : this.roomUnit.getCurrentPosition().getY());
+ message.appendString(String.valueOf(this.roomUnit.getCurrentZ()));
+ message.appendInt(this.roomUnit.getBodyRotation().getValue());
+ message.appendInt(4);
+ message.appendString(this.gender.name().toUpperCase());
+ message.appendInt(this.ownerId);
+ message.appendString(this.ownerName);
+ message.appendInt(10);
+ message.appendShort(0);
+ message.appendShort(1);
+ message.appendShort(2);
+ message.appendShort(3);
+ message.appendShort(4);
+ message.appendShort(5);
+ message.appendShort(6);
+ message.appendShort(7);
+ message.appendShort(8);
+ message.appendShort(9);
}
-
- public void stopFollowingHabbo() {
- this.followingHabboId = 0;
- }
-
- public boolean canWalk() {
- return this.canWalk;
- }
-
- public void setCanWalk(boolean canWalk) {
- this.canWalk = canWalk;
- }
-
- public void lookAt(Habbo habbo) {
- this.lookAt(habbo.getRoomUnit().getCurrentLocation());
- }
-
- public void lookAt(RoomUnit roomUnit) {
- this.lookAt(roomUnit.getCurrentLocation());
- }
-
- public void lookAt(RoomTile tile) {
- this.roomUnit.lookAtPoint(tile);
- this.roomUnit.statusUpdate(true);
- }
-
- public void onPlaceUpdate() {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ?, bubble_id = ? WHERE id = ?")) {
- statement.setString(1, this.name);
- statement.setString(2, this.motto);
- statement.setString(3, this.figure);
- statement.setString(4, this.gender.toString());
- statement.setInt(5, this.ownerId);
- statement.setInt(6, this.room == null ? 0 : this.room.getId());
- statement.setInt(7, this.roomUnit == null ? 0 : this.roomUnit.getX());
- statement.setInt(8, this.roomUnit == null ? 0 : this.roomUnit.getY());
- statement.setDouble(9, this.roomUnit == null ? 0 : this.roomUnit.getZ());
- statement.setInt(10, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue());
- statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType());
- statement.setString(12, this.canWalk ? "1" : "0");
- StringBuilder text = new StringBuilder();
- for (String s : this.chatLines) {
- text.append(s).append("\r");
- }
- statement.setString(13, text.toString());
- statement.setString(14, this.chatAuto ? "1" : "0");
- statement.setString(15, this.chatRandom ? "1" : "0");
- statement.setInt(16, this.chatDelay);
- statement.setInt(17, this.effect);
- statement.setInt(18, this.bubble);
- statement.setInt(19, this.id);
- statement.execute();
- } catch (SQLException e) {
- log.error("Caught SQL exception", e);
- }
- }
-
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
index 2d5e03b8..f14b26f6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java
@@ -2,25 +2,18 @@ package com.eu.habbo.habbohotel.bots;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Permission;
-import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
-import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
-import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
import com.eu.habbo.messages.outgoing.inventory.BotAddedToInventoryComposer;
-import com.eu.habbo.messages.outgoing.inventory.BotRemovedFromInventoryComposer;
-import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
-import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import com.eu.habbo.plugin.events.bots.BotPickUpEvent;
-import com.eu.habbo.plugin.events.bots.BotPlacedEvent;
import gnu.trove.map.hash.THashMap;
import lombok.extern.slf4j.Slf4j;
import java.lang.reflect.Method;
import java.sql.*;
import java.util.Map;
+
@Slf4j
public class BotManager {
@@ -68,7 +61,7 @@ public class BotManager {
public Bot createBot(THashMap data, String type) {
Bot bot = null;
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, type) VALUES (0, 0, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, data.get("name"));
statement.setString(2, data.get("motto"));
statement.setString(3, data.get("figure"));
@@ -77,7 +70,7 @@ public class BotManager {
statement.execute();
try (ResultSet set = statement.getGeneratedKeys()) {
if (set.next()) {
- try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.user_id = users.id WHERE bots.id = ? LIMIT 1")) {
+ try (PreparedStatement stmt = connection.prepareStatement("SELECT users.username AS owner_name, bots.* FROM bots LEFT JOIN users ON bots.owner_id = users.id WHERE bots.id = ? LIMIT 1")) {
stmt.setInt(1, set.getInt(1));
try (ResultSet resultSet = stmt.executeQuery()) {
if (resultSet.next()) {
@@ -96,75 +89,9 @@ public class BotManager {
return bot;
}
- public void placeBot(Bot bot, Habbo habbo, Room room, RoomTile location) {
- BotPlacedEvent event = new BotPlacedEvent(bot, location, habbo);
- Emulator.getPluginManager().fireEvent(event);
+ public void pickUpBot(Bot bot, Habbo habbo, Room room) {
+ HabboInfo botOwnerInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo();
- if (event.isCancelled())
- return;
-
- 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)) {
- habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS));
- return;
- }
-
- if (room.hasHabbosAt(location.getX(), location.getY()) || (!location.isWalkable() && location.getState() != RoomTileState.SIT && location.getState() != RoomTileState.LAY))
- return;
-
- if (room.hasBotsAt(location.getX(), location.getY())) {
- habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE));
- return;
- }
-
- RoomUnit roomUnit = new RoomUnit();
- roomUnit.setRotation(RoomUserRotation.SOUTH);
- roomUnit.setLocation(location);
-
- double stackHeight = room.getTopHeightAt(location.getX(), location.getY());
- roomUnit.setPreviousLocationZ(stackHeight);
- roomUnit.setZ(stackHeight);
-
- roomUnit.setPathFinderRoom(room);
- roomUnit.setRoomUnitType(RoomUnitType.BOT);
- roomUnit.setCanWalk(room.isAllowBotsWalk());
- bot.setRoomUnit(roomUnit);
- bot.setRoom(room);
- bot.onPlaceUpdate();
- room.addBot(bot);
- Emulator.getThreading().run(bot);
- room.sendComposer(new RoomUsersComposer(bot).compose());
- room.sendComposer(new UserUpdateComposer(bot.getRoomUnit()).compose());
- habbo.getInventory().getBotsComponent().removeBot(bot);
- habbo.getClient().sendResponse(new BotRemovedFromInventoryComposer(bot));
- bot.onPlace(habbo, room);
-
- HabboItem topItem = room.getTopItemAt(location.getX(), location.getY());
-
- if (topItem != null) {
- try {
- topItem.onWalkOn(bot.getRoomUnit(), room, null);
- } catch (Exception e) {
- log.error("Caught exception", e);
- }
- }
-
- bot.cycle(false);
- } else {
- habbo.getClient().sendResponse(new NotificationDialogMessageComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.getKey(), FurnitureMovementError.NO_RIGHTS.getErrorCode()));
- }
- }
- }
-
- public void pickUpBot(int botId, Habbo habbo) {
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- this.pickUpBot(habbo.getHabboInfo().getCurrentRoom().getBot(Math.abs(botId)), habbo);
- }
- }
-
- public void pickUpBot(Bot bot, Habbo habbo) {
- HabboInfo receiverInfo = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabboInfo(bot.getOwnerId()) : habbo.getHabboInfo();
if (bot != null) {
BotPickUpEvent pickedUpEvent = new BotPickUpEvent(bot, habbo);
@@ -173,21 +100,21 @@ public class BotManager {
if (pickedUpEvent.isCancelled())
return;
- if (habbo == null || (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasRight(Permission.ACC_ANYROOMOWNER))) {
- if (habbo != null && !habbo.hasRight(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
+ if (habbo == null || (bot.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermissionRight(Permission.ACC_ANYROOMOWNER))) {
+ if (habbo != null && !habbo.hasPermissionRight(Permission.ACC_UNLIMITED_BOTS) && habbo.getInventory().getBotsComponent().getBots().size() >= BotManager.MAXIMUM_BOT_INVENTORY_SIZE) {
habbo.alert(Emulator.getTexts().getValue("error.bots.max.inventory").replace("%amount%", BotManager.MAXIMUM_BOT_INVENTORY_SIZE + ""));
return;
}
- bot.onPickUp(habbo, receiverInfo.getCurrentRoom());
- receiverInfo.getCurrentRoom().removeBot(bot);
- bot.stopFollowingHabbo();
- bot.setOwnerId(receiverInfo.getId());
- bot.setOwnerName(receiverInfo.getUsername());
- bot.needsUpdate(true);
+ bot.onPickUp(habbo, room);
+ room.getRoomUnitManager().removeBot(bot);
+ bot.setFollowingHabboId(0);
+ bot.setOwnerId(botOwnerInfo.getId());
+ bot.setOwnerName(botOwnerInfo.getUsername());
+ bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
- Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(receiverInfo.getId()) : habbo;
+ Habbo receiver = habbo == null ? Emulator.getGameEnvironment().getHabboManager().getHabbo(botOwnerInfo.getId()) : habbo;
if (receiver != null) {
receiver.getInventory().getBotsComponent().addBot(bot);
receiver.getClient().sendResponse(new BotAddedToInventoryComposer(bot));
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
index b3e992aa..c07261cc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/ButlerBot.java
@@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
+import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer;
import com.eu.habbo.plugin.events.bots.BotServerItemEvent;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToRoomUnit;
@@ -29,10 +30,6 @@ public class ButlerBot extends Bot {
super(set);
}
- public ButlerBot(Bot bot) {
- super(bot);
- }
-
public static void initialise() {
if (serveItems == null)
serveItems = new THashMap<>();
@@ -57,11 +54,11 @@ public class ButlerBot extends Bot {
@Override
public void onUserSay(final RoomChatMessage message) {
- if (this.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || this.getRoom() == null) {
+ if (this.roomUnit.hasStatus(RoomUnitStatus.MOVE) || this.roomUnit.getRoom() == null) {
return;
}
- double distanceBetweenBotAndHabbo = this.getRoomUnit().getCurrentLocation().distance(message.getHabbo().getRoomUnit().getCurrentLocation());
+ double distanceBetweenBotAndHabbo = this.roomUnit.getCurrentPosition().distance(message.getHabbo().getRoomUnit().getCurrentPosition());
if (distanceBetweenBotAndHabbo <= Emulator.getConfig().getInt("hotel.bot.butler.commanddistance")) {
@@ -80,26 +77,26 @@ public class ButlerBot extends Bot {
}
// Start give handitem process
- if (this.getRoomUnit().canWalk()) {
+ if (this.roomUnit.isCanWalk()) {
final String key = keyword;
final Bot bot = this;
// Step 1: Look at Habbo
- bot.lookAt(serveEvent.getHabbo());
+ bot.getRoomUnit().lookAtPoint(serveEvent.getHabbo().getRoomUnit().getCurrentPosition());
// Step 2: Prepare tasks for when the Bot (carrying the handitem) reaches the Habbo
final List tasks = new ArrayList<>();
- tasks.add(new RoomUnitGiveHanditem(serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), serveEvent.getItemId()));
- tasks.add(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), 0));
+ tasks.add(new RoomUnitGiveHanditem(serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId()));
+ tasks.add(new RoomUnitGiveHanditem(this.roomUnit, serveEvent.getHabbo().getRoomUnit().getRoom(), 0));
tasks.add(() -> {
- if (this.getRoom() != null) {
+ if (this.roomUnit.getRoom() != null) {
String botMessage = Emulator.getTexts()
.getValue("bots.butler.given")
.replace("%key%", key)
.replace("%username%", serveEvent.getHabbo().getHabboInfo().getUsername());
- if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{botMessage})) {
+ if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, this.roomUnit.getRoom(), new Object[]{botMessage})) {
bot.talk(botMessage);
}
}
@@ -115,19 +112,20 @@ public class ButlerBot extends Bot {
});
// Give bot the handitem that it's going to give the Habbo
- Emulator.getThreading().run(new RoomUnitGiveHanditem(this.getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), serveEvent.getItemId()));
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(this.roomUnit, serveEvent.getHabbo().getRoomUnit().getRoom(), serveEvent.getItemId()));
if (distanceBetweenBotAndHabbo > Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)) {
- Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.getRoomUnit(), serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getHabboInfo().getCurrentRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)));
+ Emulator.getThreading().run(new RoomUnitWalkToRoomUnit(this.roomUnit, serveEvent.getHabbo().getRoomUnit(), serveEvent.getHabbo().getRoomUnit().getRoom(), tasks, failedReached, Emulator.getConfig().getInt("hotel.bot.butler.reachdistance", 3)));
} else {
Emulator.getThreading().run(failedReached.get(0), 1000);
}
} else {
- if (this.getRoom() != null) {
- this.getRoom().giveHandItem(serveEvent.getHabbo(), serveEvent.getItemId());
+ if (this.roomUnit.getRoom() != null) {
+ serveEvent.getHabbo().getRoomUnit().setHandItem(serveEvent.getItemId());
+ this.roomUnit.getRoom().sendComposer(new CarryObjectMessageComposer(serveEvent.getHabbo().getRoomUnit()).compose());
String msg = Emulator.getTexts().getValue("bots.butler.given").replace("%key%", keyword).replace("%username%", serveEvent.getHabbo().getHabboInfo().getUsername());
- if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), this.getRoom(), new Object[]{msg})) {
+ if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.roomUnit, this.roomUnit.getRoom(), new Object[]{msg})) {
this.talk(msg);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
index 130ff3b1..bcca553e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/VisitorBot.java
@@ -20,10 +20,6 @@ public class VisitorBot extends Bot {
super(set);
}
- public VisitorBot(Bot bot) {
- super(bot);
- }
-
public static void initialise() {
DATE_FORMAT = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat"));
}
@@ -55,8 +51,8 @@ public class VisitorBot extends Bot {
public void onUserEnter(Habbo habbo) {
if (!this.showedLog) {
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getHabboInfo().getCurrentRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp(), habbo.getHabboInfo().getCurrentRoom().getOwnerName());
+ if (habbo.getRoomUnit().getRoom() != null) {
+ this.visits = Emulator.getGameEnvironment().getModToolManager().getVisitsForRoom(habbo.getRoomUnit().getRoom(), 10, true, habbo.getHabboInfo().getLastOnline(), Emulator.getIntUnixTimestamp(), habbo.getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getUsername());
if (this.visits.isEmpty()) {
this.talk(Emulator.getTexts().getValue("bots.visitor.no_visits"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java
index 39e8d5e3..149edffa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarManager.java
@@ -122,7 +122,7 @@ public class CalendarManager {
if (object == null) return;
long daysBetween = ChronoUnit.DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
- if (((daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) && (((daysBetween - day <= 2 || !campaign.getLockExpired()) && daysBetween - day >= 0)) || (force && habbo.hasRight(Permission.ACC_CALENDAR_FORCE)))) {
+ if (((daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) && (((daysBetween - day <= 2 || !campaign.getLockExpired()) && daysBetween - day >= 0)) || (force && habbo.hasPermissionRight(Permission.ACC_CALENDAR_FORCE)))) {
if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) {
return;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java
index d8b74fa3..e2832ab5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java
+++ b/src/main/java/com/eu/habbo/habbohotel/campaign/CalendarRewardObject.java
@@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.campaign;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
@@ -71,14 +71,14 @@ public class CalendarRewardObject {
Item item = getItem();
if (item != null) {
- HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(
+ RoomItem roomItem = Emulator.getGameEnvironment().getItemManager().createItem(
habbo.getHabboInfo().getId(),
item,
0,
0,
"");
- habbo.getInventory().getItemsComponent().addItem(habboItem);
- habbo.getClient().sendResponse(new UnseenItemsComposer(habboItem));
+ habbo.getInventory().getItemsComponent().addItem(roomItem);
+ habbo.getClient().sendResponse(new UnseenItemsComposer(roomItem));
habbo.getClient().sendResponse(new FurniListInvalidateComposer());
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
index babec10e..a29ef6d6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
@@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@@ -53,7 +53,7 @@ public class CatalogLimitedConfiguration implements Runnable {
}
}
- public void limitedSold(int catalogItemId, Habbo habbo, HabboItem item) {
+ public void limitedSold(int catalogItemId, Habbo habbo, RoomItem item) {
synchronized (lock) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE catalog_items_limited SET user_id = ?, timestamp = ?, item_id = ? WHERE catalog_item_id = ? AND number = ? AND user_id = 0 LIMIT 1")) {
statement.setInt(1, habbo.getHabboInfo().getId());
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
index 33fb7916..ba31a4f3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
@@ -14,10 +14,10 @@ import com.eu.habbo.habbohotel.items.interactions.*;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.catalog.*;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
@@ -846,7 +846,7 @@ public class CatalogManager {
}
}
- THashSet itemsList = new THashSet<>();
+ HashSet itemsList = new HashSet<>();
if (amount > 1 && !CatalogItem.haveOffer(item)) {
@@ -900,9 +900,13 @@ public class CatalogManager {
Bot bot = Emulator.getGameEnvironment().getBotManager().createBot(data, type);
if (bot != null) {
+ //TODO @Deprecated
bot.setOwnerId(habbo.getClient().getHabbo().getHabboInfo().getId());
bot.setOwnerName(habbo.getClient().getHabbo().getHabboInfo().getUsername());
- bot.needsUpdate(true);
+
+ bot.setOwnerInfo(habbo.getHabboInfo());
+
+ bot.setSqlUpdateNeeded(true);
Emulator.getThreading().run(bot);
habbo.getClient().getHabbo().getInventory().getBotsComponent().addBot(bot);
habbo.getClient().sendResponse(new BotAddedToInventoryComposer(bot));
@@ -980,13 +984,13 @@ public class CatalogManager {
}
if (InteractionTeleport.class.isAssignableFrom(baseItem.getInteractionType().getType())) {
- HabboItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
- HabboItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
+ RoomItem teleportOne = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
+ RoomItem teleportTwo = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
Emulator.getGameEnvironment().getItemManager().insertTeleportPair(teleportOne.getId(), teleportTwo.getId());
itemsList.add(teleportOne);
itemsList.add(teleportTwo);
} else if (baseItem.getInteractionType().getType() == InteractionHopper.class) {
- HabboItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
+ RoomItem hopper = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
Emulator.getGameEnvironment().getItemManager().insertHopper(hopper);
@@ -1005,8 +1009,8 @@ public class CatalogManager {
if (guild != null && Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo) != null) {
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
- habboItem.setExtradata("");
- habboItem.needsUpdate(true);
+ habboItem.setExtraData("");
+ habboItem.setSqlUpdateNeeded(true);
Emulator.getThreading().run(habboItem);
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
@@ -1027,15 +1031,15 @@ public class CatalogManager {
}
InteractionMusicDisc habboItem = (InteractionMusicDisc) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, habbo.getClient().getHabbo().getHabboInfo().getUsername() + "\n" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "\n" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "\n" + Calendar.getInstance().get(Calendar.YEAR) + "\n" + track.getLength() + "\n" + track.getName() + "\n" + track.getId());
- habboItem.needsUpdate(true);
+ habboItem.setSqlUpdateNeeded(true);
Emulator.getThreading().run(habboItem);
itemsList.add(habboItem);
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicCollector"));
} else {
- HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
- itemsList.add(habboItem);
+ RoomItem roomItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
+ itemsList.add(roomItem);
}
}
}
@@ -1050,24 +1054,24 @@ public class CatalogManager {
UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges);
Emulator.getPluginManager().fireEvent(purchasedEvent);
- if (!free && !habbo.getClient().getHabbo().hasRight(Permission.ACC_INFINITE_CREDITS) && purchasedEvent.getTotalCredits() > 0) {
+ if (!free && !habbo.getClient().getHabbo().hasPermissionRight(Permission.ACC_INFINITE_CREDITS) && purchasedEvent.getTotalCredits() > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.getTotalCredits());
habbo.getClient().sendResponse(new CreditBalanceComposer(habbo.getClient().getHabbo()));
}
- if (!free && !habbo.getClient().getHabbo().hasRight(Permission.ACC_INFINITE_POINTS) && purchasedEvent.getTotalPoints() > 0) {
+ if (!free && !habbo.getClient().getHabbo().hasPermissionRight(Permission.ACC_INFINITE_POINTS) && purchasedEvent.getTotalPoints() > 0) {
habbo.getClient().getHabbo().getHabboInfo().addCurrencyAmount(item.getPointsType(), -purchasedEvent.getTotalPoints());
habbo.getClient().sendResponse(new HabboActivityPointNotificationMessageComposer(habbo.getClient().getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()), -purchasedEvent.getTotalPoints(), item.getPointsType()));
}
if (purchasedEvent.itemsList != null && !purchasedEvent.itemsList.isEmpty()) {
habbo.getClient().getHabbo().getInventory().getItemsComponent().addItems(purchasedEvent.itemsList);
- unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(HabboItem::getId).toList());
+ unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(RoomItem::getId).toList());
Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList));
if (limitedConfiguration != null) {
- for (HabboItem itm : purchasedEvent.itemsList) {
+ for (RoomItem itm : purchasedEvent.itemsList) {
limitedConfiguration.limitedSold(item.getId(), habbo, itm);
}
}
@@ -1098,7 +1102,7 @@ public class CatalogManager {
THashSet itemIds = new THashSet<>();
- for (HabboItem ix : purchasedEvent.itemsList) {
+ for (RoomItem ix : purchasedEvent.itemsList) {
itemIds.add(ix.getId() + "");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
index de366cad..289e3940 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RoomBundleLayout.java
@@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.catalog.CatalogItem;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomManager;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
import com.eu.habbo.messages.outgoing.navigator.CanCreateRoomComposer;
@@ -40,7 +40,7 @@ public class RoomBundleLayout extends SingleBundle {
if (this.room == null) {
if (this.roomId > 0) {
- this.room = Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId);
+ this.room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.roomId);
if (this.room != null)
this.room.preventUnloading = true;
@@ -73,7 +73,7 @@ public class RoomBundleLayout extends SingleBundle {
THashMap- items = new THashMap<>();
- for (HabboItem i : this.room.getFloorItems()) {
+ for (RoomItem i : this.room.getRoomItemManager().getFloorItems().values()) {
if (!items.contains(i.getBaseItem())) {
items.put(i.getBaseItem(), 0);
}
@@ -81,7 +81,7 @@ public class RoomBundleLayout extends SingleBundle {
items.put(i.getBaseItem(), items.get(i.getBaseItem()) + 1);
}
- for (HabboItem i : this.room.getWallItems()) {
+ for (RoomItem i : this.room.getRoomItemManager().getWallItems().values()) {
if (!items.contains(i.getBaseItem())) {
items.put(i.getBaseItem(), 0);
}
@@ -123,7 +123,7 @@ public class RoomBundleLayout extends SingleBundle {
public void buyRoom(Habbo habbo, int userId, String userName) {
if (!this.loaded) {
- this.loadItems(Emulator.getGameEnvironment().getRoomManager().loadRoom(this.roomId));
+ this.loadItems(Emulator.getGameEnvironment().getRoomManager().getRoom(this.roomId));
}
if (habbo != null) {
@@ -141,11 +141,11 @@ public class RoomBundleLayout extends SingleBundle {
this.room.save();
- for (HabboItem item : this.room.getFloorItems()) {
+ for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) {
item.run();
}
- for (HabboItem item : this.room.getWallItems()) {
+ for (RoomItem item : this.room.getRoomItemManager().getWallItems().values()) {
item.run();
}
@@ -156,7 +156,7 @@ public class RoomBundleLayout extends SingleBundle {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model) (SELECT ?, ?, name, description, model, password, state, users_max, category, paper_floor, paper_wall, paper_landscape, thickness_wall, thickness_floor, moodlight_data, override_model FROM rooms WHERE id = ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, userId);
statement.setString(2, userName);
- statement.setInt(3, this.room.getId());
+ statement.setInt(3, this.room.getRoomInfo().getId());
statement.execute();
try (ResultSet set = statement.getGeneratedKeys()) {
if (set.next()) {
@@ -173,15 +173,15 @@ public class RoomBundleLayout extends SingleBundle {
statement.setInt(2, roomId);
statement.setString(3, "0:0");
statement.setInt(4, 0);
- statement.setInt(5, this.room.getId());
+ statement.setInt(5, this.room.getRoomInfo().getId());
statement.execute();
}
- if (this.room.hasCustomLayout()) {
+ if (this.room.getRoomInfo().isModelOverridden()) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO room_models_custom (id, name, door_x, door_y, door_dir, heightmap) (SELECT ?, ?, door_x, door_y, door_dir, heightmap FROM room_models_custom WHERE id = ? LIMIT 1)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, roomId);
statement.setString(2, "custom_" + roomId);
- statement.setInt(3, this.room.getId());
+ statement.setInt(3, this.room.getRoomInfo().getId());
statement.execute();
} catch (SQLException e) {
log.error("Caught SQL exception", e);
@@ -189,18 +189,18 @@ public class RoomBundleLayout extends SingleBundle {
}
if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) {
- try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
- synchronized (this.room.getCurrentBots()) {
+ try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
+ synchronized (this.room.getRoomUnitManager().getCurrentBots()) {
statement.setInt(1, userId);
statement.setInt(2, roomId);
- for (Bot bot : this.room.getCurrentBots().valueCollection()) {
+ for (Bot bot : this.room.getRoomUnitManager().getCurrentBots().values()) {
statement.setString(3, bot.getName());
statement.setString(4, bot.getMotto());
statement.setString(5, bot.getFigure());
statement.setString(6, bot.getGender().name());
- statement.setInt(7, bot.getRoomUnit().getX());
- statement.setInt(8, bot.getRoomUnit().getY());
- statement.setDouble(9, bot.getRoomUnit().getZ());
+ statement.setInt(7, bot.getRoomUnit().getCurrentPosition().getX());
+ statement.setInt(8, bot.getRoomUnit().getCurrentPosition().getY());
+ statement.setDouble(9, bot.getRoomUnit().getCurrentZ());
StringBuilder text = new StringBuilder();
for (String s : bot.getChatLines()) {
text.append(s).append("\r");
@@ -221,17 +221,17 @@ public class RoomBundleLayout extends SingleBundle {
log.error("Caught SQL exception", e);
}
- Room r = Emulator.getGameEnvironment().getRoomManager().loadRoom(roomId);
- r.setWallHeight(this.room.getWallHeight());
- r.setFloorSize(this.room.getFloorSize());
- r.setWallPaint(this.room.getWallPaint());
- r.setFloorPaint(this.room.getFloorPaint());
- r.setScore(0);
+ Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
+ r.getRoomInfo().setWallHeight(this.room.getRoomInfo().getWallHeight());
+ r.getRoomInfo().setFloorThickness(this.room.getRoomInfo().getFloorThickness());
+ r.getRoomInfo().setWallPaint(this.room.getRoomInfo().getWallPaint());
+ r.getRoomInfo().setFloorPaint(this.room.getRoomInfo().getFloorPaint());
+ r.getRoomInfo().setScore(0);
r.setNeedsUpdate(true);
THashMap keys = new THashMap<>();
- keys.put("ROOMNAME", r.getName());
- keys.put("ROOMID", r.getId() + "");
- keys.put("OWNER", r.getOwnerName());
+ keys.put("ROOMNAME", r.getRoomInfo().getName());
+ keys.put("ROOMID", r.getRoomInfo().getId() + "");
+ keys.put("OWNER", r.getRoomInfo().getOwnerInfo().getUsername());
keys.put("image", "${image.library.url}/notifications/room_bundle_" + this.getId() + ".png");
if (habbo != null) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
index e425f6ab..80668dee 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlace.java
@@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.catalog.marketplace;
import com.eu.habbo.Emulator;
import com.eu.habbo.database.DatabaseConstants;
import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.catalog.marketplace.GetMarketplaceOffersEvent;
import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceBuyOfferResultComposer;
@@ -97,7 +97,7 @@ public class MarketPlace {
selectItem.setInt(1, offer.getSoldItemId());
try (ResultSet set = selectItem.executeQuery()) {
while (set.next()) {
- HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set);
+ RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(set);
habbo.getInventory().getItemsComponent().addItem(item);
habbo.getClient().sendResponse(new MarketplaceCancelOfferResultComposer(offer, true));
habbo.getClient().sendResponse(new UnseenItemsComposer(item));
@@ -273,7 +273,7 @@ public class MarketPlace {
updateOffer.execute();
}
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(set.getInt(DatabaseConstants.USER_ID));
- HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet);
+ RoomItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet);
MarketPlaceItemSoldEvent event = new MarketPlaceItemSoldEvent(habbo, client.getHabbo(), item, set.getInt("price"));
if (Emulator.getPluginManager().fireEvent(event).isCancelled()) {
@@ -281,8 +281,8 @@ public class MarketPlace {
}
event.price = calculateCommision(event.price);
- item.setUserId(client.getHabbo().getHabboInfo().getId());
- item.needsUpdate(true);
+ item.setOwnerInfo(client.getHabbo().getHabboInfo());
+ item.setSqlUpdateNeeded(true);
Emulator.getThreading().run(item);
client.getHabbo().getInventory().getItemsComponent().addItem(item);
@@ -340,7 +340,7 @@ public class MarketPlace {
}
- public static boolean sellItem(GameClient client, HabboItem item, int price) {
+ public static boolean sellItem(GameClient client, RoomItem item, int price) {
if (item == null || client == null)
return false;
@@ -362,8 +362,8 @@ public class MarketPlace {
MarketPlaceOffer offer = new MarketPlaceOffer(event.getItem(), event.getPrice(), client.getHabbo());
client.getHabbo().getInventory().addMarketplaceOffer(offer);
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.getItem());
- item.setUserId(-1);
- item.needsUpdate(true);
+ item.setOwnerInfo(null);
+ item.setSqlUpdateNeeded(true);
Emulator.getThreading().run(item);
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
index cada0040..481a79a2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/marketplace/MarketPlaceOffer.java
@@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.FurnitureType;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@@ -60,7 +60,7 @@ public class MarketPlaceOffer implements Runnable {
}
}
- public MarketPlaceOffer(HabboItem item, int price, Habbo habbo) {
+ public MarketPlaceOffer(RoomItem item, int price, Habbo habbo) {
this.price = price;
this.baseItem = item.getBaseItem();
this.itemId = item.getId();
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java
index 160a354c..8d717d63 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandsManager.java
@@ -3,12 +3,25 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.CommandLog;
import com.eu.habbo.habbohotel.commands.list.*;
-import com.eu.habbo.habbohotel.commands.list.badge.*;
-import com.eu.habbo.habbohotel.commands.list.bans.*;
-import com.eu.habbo.habbohotel.commands.list.credits.*;
-import com.eu.habbo.habbohotel.commands.list.gift.*;
-import com.eu.habbo.habbohotel.commands.list.pixels.*;
-import com.eu.habbo.habbohotel.commands.list.points.*;
+import com.eu.habbo.habbohotel.commands.list.badge.BadgeCommand;
+import com.eu.habbo.habbohotel.commands.list.badge.MassBadgeCommand;
+import com.eu.habbo.habbohotel.commands.list.badge.RoomBadgeCommand;
+import com.eu.habbo.habbohotel.commands.list.badge.TakeBadgeCommand;
+import com.eu.habbo.habbohotel.commands.list.bans.BanCommand;
+import com.eu.habbo.habbohotel.commands.list.bans.IPBanCommand;
+import com.eu.habbo.habbohotel.commands.list.bans.MachineBanCommand;
+import com.eu.habbo.habbohotel.commands.list.bans.SuperbanCommand;
+import com.eu.habbo.habbohotel.commands.list.credits.CreditsCommand;
+import com.eu.habbo.habbohotel.commands.list.credits.MassCreditsCommand;
+import com.eu.habbo.habbohotel.commands.list.credits.RoomCreditsCommand;
+import com.eu.habbo.habbohotel.commands.list.gift.GiftCommand;
+import com.eu.habbo.habbohotel.commands.list.gift.MassGiftCommand;
+import com.eu.habbo.habbohotel.commands.list.pixels.MassPixelsCommand;
+import com.eu.habbo.habbohotel.commands.list.pixels.PixelCommand;
+import com.eu.habbo.habbohotel.commands.list.pixels.RoomPixelsCommand;
+import com.eu.habbo.habbohotel.commands.list.points.MassPointsCommand;
+import com.eu.habbo.habbohotel.commands.list.points.PointsCommand;
+import com.eu.habbo.habbohotel.commands.list.points.RoomPointsCommand;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.permissions.PermissionCommand;
@@ -73,14 +86,17 @@ public class CommandsManager {
}
String commandKey = parts[0];
- Room currentRoom = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
- boolean hasRights = currentRoom != null &&
- (currentRoom.hasRights(gameClient.getHabbo())) ||
- gameClient.getHabbo().hasRight(Permission.ACC_PLACEFURNI) ||
- currentRoom.getGuildId() > 0 && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS);
+ Room currentRoom = gameClient.getHabbo().getRoomUnit().getRoom();
+ if(currentRoom == null) {
+ return false;
+ }
- if (!gameClient.getHabbo().canExecuteCommand(commandKey, hasRights)) {
+ boolean hasRights = (currentRoom.getRoomRightsManager().hasRights(gameClient.getHabbo())) || gameClient.getHabbo().hasPermissionRight(Permission.ACC_PLACEFURNI) || (currentRoom.getRoomInfo().hasGuild() && currentRoom.getGuildRightLevel(gameClient.getHabbo()).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS));
+
+ boolean canExecuteCommand = gameClient.getHabbo().canExecuteCommand(commandKey, hasRights);
+
+ if (!canExecuteCommand) {
return false;
}
@@ -127,17 +143,17 @@ public class CommandsManager {
private boolean handlePetCommand(GameClient gameClient, String commandLine) {
String[] args = commandLine.split(" ");
- if (args.length <= 1 || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) {
+ if (args.length <= 1 || gameClient.getHabbo().getRoomUnit().getRoom() == null) {
return false;
}
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
- if (room.getCurrentPets().isEmpty()) {
+ if (room.getRoomUnitManager().getCurrentPets().isEmpty()) {
return false;
}
- for(Pet pet : room.getCurrentPets().valueCollection()) {
+ for(Pet pet : room.getRoomUnitManager().getCurrentPets().values()) {
if (pet != null && pet.getName().equalsIgnoreCase(args[0])) {
StringBuilder commandBuilder = new StringBuilder();
@@ -150,7 +166,7 @@ public class CommandsManager {
for (PetCommand command : pet.getPetData().getPetCommands()) {
if (command.getKey().equalsIgnoreCase(commandKey)) {
if (pet instanceof RideablePet rideablePet && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) {
- rideablePet.getRider().getHabboInfo().dismountPet();
+ rideablePet.getRider().getRoomUnit().dismountPet(false);
break;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java
index 6b3d8c94..d020247a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ArcturusCommand.java
@@ -11,7 +11,7 @@ public class ArcturusCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
gameClient.getHabbo().whisper("This hotel is powered by Arcturus Emulator! \r" +
"Cet hôtel est alimenté par Arcturus émulateur! \r" +
"Dit hotel draait op Arcturus Emulator! \r" +
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java
index e7163ca4..bd95efcf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BlockAlertCommand.java
@@ -11,7 +11,7 @@ public class BlockAlertCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
gameClient.getHabbo().getHabboStats().setBlockStaffAlerts(!gameClient.getHabbo().getHabboStats().isBlockStaffAlerts());
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_blockalert").replace("%state%", (gameClient.getHabbo().getHabboStats().isBlockStaffAlerts() ? getTextsValue("generic.on") : getTextsValue("generic.off"))), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java
index a5e8ac1d..494aab57 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/BotsCommand.java
@@ -12,12 +12,12 @@ public class BotsCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo()))
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null || !gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo()))
return false;
- StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values().length);
+ StringBuilder data = new StringBuilder(getTextsValue("total") + ": " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values().size());
- for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) {
+ for (Bot bot : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentBots().values()) {
data.append("\r");
data.append("");
data.append(Emulator.getTexts().getValue("generic.bot.name"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java
index d996bebc..ae2b119a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CalendarCommand.java
@@ -22,7 +22,7 @@ public class CalendarCommand extends Command {
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
String campaignName = Emulator.getConfig().getValue("hotel.calendar.default");
- if (params.length > 1 && gameClient.getHabbo().hasCommand("cmd_calendar_staff")) {
+ if (params.length > 1 && gameClient.getHabbo().canExecuteCommand("cmd_calendar_staff")) {
campaignName = params[1];
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java
index 95e25cef..5bca58a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ChatTypeCommand.java
@@ -33,7 +33,7 @@ public class ChatTypeCommand extends Command {
return true;
}
- if (!gameClient.getHabbo().hasRight(Permission.ACC_ANYCHATCOLOR)) {
+ if (!gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYCHATCOLOR)) {
for (String s : Emulator.getConfig().getValue("commands.cmd_chatcolor.banned_numbers").split(";")) {
if (Integer.parseInt(s) == chatColor) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_chatcolor.banned"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java
index 32a6727f..a6fe139a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CommandsCommand.java
@@ -1,11 +1,11 @@
package com.eu.habbo.habbohotel.commands.list;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.PermissionCommand;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
public class CommandsCommand extends Command {
@@ -17,13 +17,19 @@ public class CommandsCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) {
StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_commands.text"));
- List commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands();
+ List commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands();
- Collections.sort(commands, Comparator.comparing(PermissionCommand::getName));
+ Collections.sort(commands);
message.append("(").append(commands.size()).append("):\r\n");
- for(PermissionCommand command : commands) {
+ for(String commandName : commands) {
+ PermissionCommand command = Emulator.getGameEnvironment().getPermissionsManager().getCommand(commandName);
+
+ if(command == null) {
+ continue;
+ }
+
message.append(command.getDescription()).append("\r");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java
index 76442da4..537e80bc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ControlCommand.java
@@ -12,7 +12,7 @@ public class ControlCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
if (params.length == 2) {
Habbo target = getHabbo(params[1]);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java
index 0bbac1d8..09c043bd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/CoordsCommand.java
@@ -12,24 +12,24 @@ public class CoordsCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gameClient.getHabbo().getRoomUnit() == null || gameClient.getHabbo().getRoomUnit().getRoom() == null)
return false;
if (params.length == 1) {
gameClient.getHabbo().alert(getTextsValue("commands.generic.cmd_coords.title") + "\r\n" +
- "x: " + gameClient.getHabbo().getRoomUnit().getX() + "\r" +
- "y: " + gameClient.getHabbo().getRoomUnit().getY() + "\r" +
- "z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getZ()) + "\r" +
+ "x: " + gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX() + "\r" +
+ "y: " + gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY() + "\r" +
+ "z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getCurrentZ()) + "\r" +
getTextsValue("generic.rotation.head") + ": " + gameClient.getHabbo().getRoomUnit().getHeadRotation() + "-" + gameClient.getHabbo().getRoomUnit().getHeadRotation().getValue() + "\r" +
getTextsValue("generic.rotation.body") + ": " + gameClient.getHabbo().getRoomUnit().getBodyRotation() + "-" + gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() + "\r" +
getTextsValue("generic.sitting") + ": " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" +
- "Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getState().name() + "\r" +
- "Tile Walkable: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).isWalkable() + "\r" +
- "Tile relative height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).relativeHeight() + "\r" +
- "Tile stack height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getStackHeight());
-
+ "Tile State: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getState().name() + "\r" +
+ "Tile Walkable: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).isWalkable() + "\r" +
+ "Tile relative height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).relativeHeight() + "\r" +
+ "Tile stack height: " + gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX(), gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY()).getStackHeight() + "\r" +
+ "Tile has Furni: " + (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomItemManager().getItemsAt(gameClient.getHabbo().getRoomUnit().getCurrentPosition()).isEmpty()));
} else {
- RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2]));
+ RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTile(Short.parseShort(params[1]), Short.parseShort(params[2]));
if (tile != null) {
gameClient.getHabbo().alert(getTextsValue("commands.generic.cmd_coords.title") + "\r\n" +
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java
index 6b841eea..d49942e3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/DiagonalCommand.java
@@ -11,10 +11,10 @@ public class DiagonalCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally());
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) {
+ gameClient.getHabbo().getRoomUnit().getRoom().setDiagonalMoveEnabled(!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled());
- if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().moveDiagonally()) {
+ if (!gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().isDiagonalMoveEnabled()) {
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_diagonal.disabled"), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_diagonal.enabled"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java
index b68e8c12..01a05e9f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EjectAllCommand.java
@@ -12,11 +12,12 @@ public class EjectAllCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
- if (room != null && (room.isOwner(gameClient.getHabbo())
- || (room.hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN)))) {
- room.ejectAll(gameClient.getHabbo());
+ if (room != null) {
+ if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) {
+ room.getRoomItemManager().ejectAllFurni(gameClient.getHabbo());
+ }
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java
index 316c5421..f6be437c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyBotsInventoryCommand.java
@@ -19,8 +19,8 @@ public class EmptyBotsInventoryCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 1 || (params.length >= 2 && !params[1].equals(getTextsValue("generic.yes")))) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) {
gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", getTextsValue("generic.yes")));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT);
@@ -32,7 +32,7 @@ public class EmptyBotsInventoryCommand extends Command {
if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) {
- Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap bots = new TIntObjectHashMap<>();
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java
index 4298201e..9e77470c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyInventoryCommand.java
@@ -5,8 +5,8 @@ import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.inventory.FurniListComposer;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItems;
@@ -21,8 +21,8 @@ public class EmptyInventoryCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 1 || (params.length == 2 && !params[1].equals(getTextsValue("generic.yes")))) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) {
gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", getTextsValue("generic.yes")));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT);
@@ -34,10 +34,10 @@ public class EmptyInventoryCommand extends Command {
if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) {
- Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
- TIntObjectMap items = new TIntObjectHashMap<>();
+ TIntObjectMap items = new TIntObjectHashMap<>();
items.putAll(habbo.getInventory().getItemsComponent().getItems());
habbo.getInventory().getItemsComponent().getItems().clear();
Emulator.getThreading().run(new QueryDeleteHabboItems(items));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java
index d1679b9c..e35daa20 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EmptyPetsInventoryCommand.java
@@ -19,8 +19,8 @@ public class EmptyPetsInventoryCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 1 || (params.length >= 2 && !params[1].equals(getTextsValue("generic.yes")))) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabbosCount() > 10) {
gameClient.getHabbo().alert(getTextsValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", getTextsValue("generic.yes")));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", getTextsValue("generic.yes")), RoomChatMessageBubbles.ALERT);
@@ -32,7 +32,7 @@ public class EmptyPetsInventoryCommand extends Command {
if (params.length >= 2 && params[1].equalsIgnoreCase(getTextsValue("generic.yes"))) {
- Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
+ Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermissionRight(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap pets = new TIntObjectHashMap<>(habbo.getInventory().getPetsComponent().getPets());
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java
index d1ea3825..e1860133 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EnableCommand.java
@@ -31,15 +31,15 @@ public class EnableCommand extends Command {
if (target == null) {
return true;
}
- if (target == gameClient.getHabbo() || gameClient.getHabbo().hasRight(Permission.ACC_ENABLE_OTHERS)) {
+ if (target == gameClient.getHabbo() || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ENABLE_OTHERS)) {
try {
- if (target.getHabboInfo().getCurrentRoom() != null && target.getHabboInfo().getRiding() == null) {
+ if (target.getRoomUnit().getRoom() != null && !target.getRoomUnit().isRiding()) {
if (Emulator.getGameEnvironment().getPermissionsManager().isEffectBlocked(effectId, target.getHabboInfo().getPermissionGroup().getId())) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_enable.not_allowed"), RoomChatMessageBubbles.ALERT);
return true;
}
- target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1);
+ target.getRoomUnit().giveEffect(effectId, -1);
}
} catch (Exception e) {
log.error("Caught exception", e);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java
index 1ea5bf86..ed363e35 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/EventCommand.java
@@ -18,14 +18,14 @@ public class EventCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || params.length < 2) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null || params.length < 2) {
return false;
}
String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
THashMap codes = new THashMap<>();
- codes.put("ROOMNAME", gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName());
- codes.put("ROOMID", gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId() + "");
+ codes.put("ROOMNAME", gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getName());
+ codes.put("ROOMID", gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId() + "");
codes.put("USERNAME", gameClient.getHabbo().getHabboInfo().getUsername());
codes.put("LOOK", gameClient.getHabbo().getHabboInfo().getLook());
codes.put("TIME", Emulator.getDate().toString());
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java
index 88d9a95e..dbb4c7bd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FacelessCommand.java
@@ -13,7 +13,7 @@ public class FacelessCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null) {
return false;
}
@@ -34,7 +34,7 @@ public class FacelessCommand extends Command {
gameClient.getHabbo().getHabboInfo().setLook(gameClient.getHabbo().getHabboInfo().getLook().replace(part, newHead));
gameClient.sendResponse(new FigureUpdateComposer(gameClient.getHabbo()));
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose());
return true;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java
index fc790173..cc5dfd75 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FastwalkCommand.java
@@ -11,10 +11,12 @@ public class FastwalkCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
+
//TODO Make this an event plugin which fires that can be cancelled
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getRiding() != null)
+ if (gameClient.getHabbo().getRoomUnit().isRiding()) {
return true;
+ }
Habbo habbo = gameClient.getHabbo();
@@ -26,7 +28,8 @@ public class FastwalkCommand extends Command {
if (habbo == null)
return false;
}
- habbo.getRoomUnit().setFastWalk(!habbo.getRoomUnit().isFastWalk());
+
+ habbo.getRoomUnit().setCmdFastWalkEnabled(!habbo.getRoomUnit().isCmdFastWalkEnabled());
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java
index 3e579fa8..3737ee87 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeBotsCommand.java
@@ -12,14 +12,14 @@ public class FreezeBotsCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null) {
return false;
}
- if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId()
- || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().setAllowBotsWalk(!gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk());
- gameClient.getHabbo().whisper(gameClient.getHabbo().getHabboInfo().getCurrentRoom().isAllowBotsWalk() ? getTextsValue("commands.succes.cmd_freeze_bots.unfrozen") : getTextsValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT);
+ if (gameClient.getHabbo().getHabboInfo().getId() == gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getOwnerInfo().getId()
+ || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
+ gameClient.getHabbo().getRoomUnit().getRoom().setAllowBotsWalk(!gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk());
+ gameClient.getHabbo().whisper(gameClient.getHabbo().getRoomUnit().getRoom().isAllowBotsWalk() ? getTextsValue("commands.succes.cmd_freeze_bots.unfrozen") : getTextsValue("commands.succes.cmd_freeze_bots.frozen"), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(getTextsValue("generic.cannot_do_that"), RoomChatMessageBubbles.ALERT);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java
index de2ed0b0..ac9e3895 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/FreezeCommand.java
@@ -18,7 +18,7 @@ public class FreezeCommand extends Command {
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_freeze.not_found"), params[1]), RoomChatMessageBubbles.ALERT);
} else {
- if (habbo.getRoomUnit().canWalk()) {
+ if (habbo.getRoomUnit().isCanWalk()) {
habbo.getRoomUnit().setCanWalk(false);
habbo.whisper(getTextsValue("commands.succes.cmd_freeze.frozen"), RoomChatMessageBubbles.ALERT);
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_freeze.user_frozen"), params[1]), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java
index 3c832360..1e6dc93b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/GiveRankCommand.java
@@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.PermissionGroup;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import org.apache.commons.lang3.StringUtils;
public class GiveRankCommand extends Command {
@@ -40,7 +39,7 @@ public class GiveRankCommand extends Command {
return true;
}
- HabboInfo habbo = HabboManager.getOfflineHabboInfo(params[1]);
+ HabboInfo habbo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
if (habbo != null) {
if (habbo.getPermissionGroup().getId() > gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId()) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java
index 7c637fd4..b8e18ced 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HabnamCommand.java
@@ -10,8 +10,8 @@ public class HabnamCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), 140, 30);
+ if (gameClient.getHabbo().getHabboStats().hasActiveClub() && gameClient.getHabbo().getRoomUnit().getRoom() != null) {
+ gameClient.getHabbo().getRoomUnit().giveEffect(140, 30);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java
index c14fba16..a2cd6844 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HandItemCommand.java
@@ -13,10 +13,10 @@ public class HandItemCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 2) {
try {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
int effectId = Integer.parseInt(params[1]);
gameClient.getHabbo().getRoomUnit().setHandItem(effectId);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(gameClient.getHabbo().getRoomUnit()).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(gameClient.getHabbo().getRoomUnit()).compose());
}
} catch (Exception e) {
//Don't handle incorrect parse exceptions :P
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java
index a1a37ac0..b837f485 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/HideWiredCommand.java
@@ -11,14 +11,14 @@ public class HideWiredCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room == null) {
return true;
}
- if (room.isOwner(gameClient.getHabbo())) {
- room.setHideWired(!room.isHideWired());
- gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_hidewired." + (room.isHideWired() ? "hidden" : "shown")));
+ if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) {
+ room.getRoomItemManager().getWiredManager().setHideWired(!room.getRoomInfo().isHiddenWiredEnabled());
+ gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_hidewired." + (room.getRoomInfo().isHiddenWiredEnabled() ? "hidden" : "shown")));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.errors.cmd_hidewired.permission"));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java
index a89cf853..4e02621b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/InvisibleCommand.java
@@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.commands.list;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
@@ -25,8 +25,7 @@ public class InvisibleCommand extends Command {
new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().getX(), roomLayout.getDoorTile().getY(), roomLayout.getDoorTile().getZ(), 0).run();
- roomUnit.setInvisible(false)
- .setInRoom(true);
+ roomUnit.setInvisible(false);
roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose());
roomUnit.getRoom().sendComposer(new UserUpdateComposer(roomUnit).compose());
@@ -41,7 +40,7 @@ public class InvisibleCommand extends Command {
roomUnit.setInvisible(true);
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_invisible.updated"));
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserRemoveMessageComposer(roomUnit).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(roomUnit).compose());
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java
index 0961d2ba..164b7fbb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/LayCommand.java
@@ -4,7 +4,7 @@ import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
-import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import java.util.stream.IntStream;
@@ -19,24 +19,24 @@ public class LayCommand extends Command {
if (gameClient.getHabbo().getRoomUnit() == null || !gameClient.getHabbo().getRoomUnit().canForcePosture())
return true;
- gameClient.getHabbo().getRoomUnit().setCmdLay(true);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo());
- gameClient.getHabbo().getRoomUnit().setCmdSit(true);
- gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomUserRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]);
+ gameClient.getHabbo().getRoomUnit().setCmdLayEnabled(true);
+ gameClient.getHabbo().getRoomUnit().getRoom().updateRoomUnit(gameClient.getHabbo().getRoomUnit());
+ gameClient.getHabbo().getRoomUnit().setCmdSitEnabled(true);
+ gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]);
- RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation();
+ RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentPosition();
if (tile == null) {
return false;
}
if (IntStream.range(0, 3)
- .mapToObj(i -> gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(tile, gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue(), i))
+ .mapToObj(i -> gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(tile, gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue(), i))
.anyMatch(t -> t == null || !t.isWalkable())) {
return false;
}
- gameClient.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.LAY, 0.5 + "");
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserUpdateComposer(gameClient.getHabbo().getRoomUnit()).compose());
+ gameClient.getHabbo().getRoomUnit().addStatus(RoomUnitStatus.LAY, 0.5 + "");
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserUpdateComposer(gameClient.getHabbo().getRoomUnit()).compose());
return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java
index 91be1f99..f2053acd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MimicCommand.java
@@ -19,7 +19,7 @@ public class MimicCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 2) {
- Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
+ Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.not_found"), ""), RoomChatMessageBubbles.ALERT);
@@ -29,17 +29,17 @@ public class MimicCommand extends Command {
if (habbo == gameClient.getHabbo()) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_mimic.not_self"), RoomChatMessageBubbles.ALERT);
return true;
- } else if (habbo.hasRight(Permission.ACC_NOT_MIMICED) && !gameClient.getHabbo().hasRight(Permission.ACC_NOT_MIMICED)) {
+ } else if (habbo.hasPermissionRight(Permission.ACC_NOT_MIMICED) && !gameClient.getHabbo().hasPermissionRight(Permission.ACC_NOT_MIMICED)) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_mimic.blocked"), params[1]).replace("%gender_name%", getGenderName(habbo)), RoomChatMessageBubbles.ALERT);
return true;
- } else if (!habbo.hasRight(Permission.ACC_MIMIC_UNREDEEMED) && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) {
+ } else if (!habbo.hasPermissionRight(Permission.ACC_MIMIC_UNREDEEMED) && FigureUtil.hasBlacklistedClothing(habbo.getHabboInfo().getLook(), gameClient.getHabbo().getForbiddenClothing())) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_mimic.forbidden_clothing"), RoomChatMessageBubbles.ALERT);
return true;
} else {
gameClient.getHabbo().getHabboInfo().setLook(ClothingValidationManager.VALIDATE_ON_MIMIC ? ClothingValidationManager.validateLook(gameClient.getHabbo(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getGender().name()) : habbo.getHabboInfo().getLook());
gameClient.getHabbo().getHabboInfo().setGender(habbo.getHabboInfo().getGender());
gameClient.sendResponse(new UserObjectComposer(gameClient.getHabbo()));
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(gameClient.getHabbo()).compose());
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_mimic.copied"), params[1]).replace("%gender_name%", getGenderName(habbo)), RoomChatMessageBubbles.ALERT);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java
index 5c03d536..191ffd98 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MoonwalkCommand.java
@@ -10,12 +10,12 @@ public class MoonwalkCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) {
int effect = 136;
if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136)
effect = 0;
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), effect, -1);
+ gameClient.getHabbo().getRoomUnit().giveEffect(effect, -1);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java
index b92589b8..da3a6ab1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/MuteCommand.java
@@ -46,8 +46,8 @@ public class MuteCommand extends Command {
habbo.mute(duration, false);
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED
+ if (habbo.getRoomUnit().getRoom() != null) {
+ habbo.getRoomUnit().getRoom().sendComposer(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.MUTED).compose()); //: RoomUserIgnoredComposer.UNIGNORED
}
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_mute.muted"), params[1]), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java
index 5ffafb07..e93e7602 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PetInfoCommand.java
@@ -16,12 +16,12 @@ public class PetInfoCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pet_info.pet_not_found"), RoomChatMessageBubbles.ALERT);
return true;
}
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null)
return false;
String name = params[1];
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().forEachEntry((a, pet) -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentPets().forEach((a, pet) -> {
if (pet.getName().equalsIgnoreCase(name)) {
gameClient.getHabbo().alert("" +
getTextsValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" +
@@ -37,11 +37,9 @@ public class PetInfoCommand extends Command {
getTextsValue("generic.pet.level.thirst") + ": " + pet.levelThirst + "\r" +
getTextsValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" +
getTextsValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? getTextsValue("generic.nothing") : pet.getTask().name()) + "\r" +
- getTextsValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + ""
+ getTextsValue("generic.can.walk") + ": " + (pet.getRoomUnit().isCanWalk() ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + ""
);
}
-
- return true;
});
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java
index cd0d6887..f07f1bc1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PickallCommand.java
@@ -11,18 +11,18 @@ public class PickallCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room == null) {
return true;
}
- if (room.isOwner(gameClient.getHabbo())) {
- room.ejectAll();
+ if (room.getRoomInfo().isRoomOwner(gameClient.getHabbo())) {
+ room.getRoomItemManager().ejectAllFurni();
return true;
}
- room.ejectUserFurni(gameClient.getHabbo().getHabboInfo().getId());
+ room.getRoomItemManager().ejectUserFurni(gameClient.getHabbo().getHabboInfo().getId());
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java
index 3b78f9db..da1c4285 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PullCommand.java
@@ -17,7 +17,7 @@ public class PullCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
- Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
+ Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT);
@@ -27,22 +27,22 @@ public class PullCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT);
return true;
}
- int distanceX = habbo.getRoomUnit().getX() - gameClient.getHabbo().getRoomUnit().getX();
- int distanceY = habbo.getRoomUnit().getY() - gameClient.getHabbo().getRoomUnit().getY();
+ int distanceX = habbo.getRoomUnit().getCurrentPosition().getX() - gameClient.getHabbo().getRoomUnit().getCurrentPosition().getX();
+ int distanceY = habbo.getRoomUnit().getCurrentPosition().getY() - gameClient.getHabbo().getRoomUnit().getCurrentPosition().getY();
if (distanceX < -2 || distanceX > 2 || distanceY < -2 || distanceY > 2) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.cant_reach"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
- RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
+ RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
if (tile != null && tile.isWalkable()) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tile) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile() == tile) {
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]));
return true;
}
- habbo.getRoomUnit().setGoalLocation(tile);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
+ habbo.getRoomUnit().walkTo(tile);
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java
index e440af6f..a14768b6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/PushCommand.java
@@ -18,7 +18,7 @@ public class PushCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
- Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
+ Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_push.not_found"), params[1]), RoomChatMessageBubbles.ALERT);
@@ -29,19 +29,19 @@ public class PushCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_push.push_self"), RoomChatMessageBubbles.ALERT);
return true;
}
- RoomTile tFront = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
+ RoomTile tFront = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
if (tFront != null && tFront.isWalkable()) {
- if (tFront.getX() == habbo.getRoomUnit().getX() && tFront.getY() == habbo.getRoomUnit().getY()) {
- RoomTile tFrontTarget = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
+ if (tFront.getX() == habbo.getRoomUnit().getCurrentPosition().getX() && tFront.getY() == habbo.getRoomUnit().getCurrentPosition().getY()) {
+ RoomTile tFrontTarget = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(habbo.getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
if (tFrontTarget != null && tFrontTarget.isWalkable()) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile() == tFrontTarget) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile() == tFrontTarget) {
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_push.invalid"), params[1]));
return true;
}
- habbo.getRoomUnit().setGoalLocation(tFrontTarget);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(
+ habbo.getRoomUnit().walkTo(tFrontTarget);
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(
new ChatMessageComposer(
new RoomChatMessage(
replaceUser(getTextsValue("commands.succes.cmd_push.push"), params[1])
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java
index a0b32f1c..6a939ff7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RedeemCommand.java
@@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItems;
import gnu.trove.map.TIntIntMap;
@@ -20,17 +20,17 @@ public class RedeemCommand extends Command {
@Override
public boolean handle(final GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null)
+ if (gameClient.getHabbo().getRoomUnit().getRoom().getActiveTradeForHabbo(gameClient.getHabbo()) != null)
return false;
- ArrayList items = new ArrayList<>();
+ ArrayList items = new ArrayList<>();
int credits = 0;
int pixels = 0;
TIntIntMap points = new TIntIntHashMap();
- for (HabboItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) {
- if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getUserId() == gameClient.getHabbo().getHabboInfo().getId()) {
+ for (RoomItem item : gameClient.getHabbo().getInventory().getItemsComponent().getItemsAsValueCollection()) {
+ if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_") || item.getBaseItem().getName().startsWith("DF_") || item.getBaseItem().getName().startsWith("PF_")) && item.getOwnerInfo().getId() == gameClient.getHabbo().getHabboInfo().getId()) {
items.add(item);
if ((item.getBaseItem().getName().startsWith("CF_") || item.getBaseItem().getName().startsWith("CFC_")) && !item.getBaseItem().getName().contains("_diamond_")) {
try {
@@ -63,7 +63,7 @@ public class RedeemCommand extends Command {
}
}
- TIntObjectHashMap deleted = new TIntObjectHashMap<>();
+ TIntObjectHashMap deleted = new TIntObjectHashMap<>();
items.forEach(item -> {
gameClient.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
deleted.put(item.getId(), item);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java
index 0dbd9e8c..63c0947e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ReloadRoomCommand.java
@@ -19,12 +19,12 @@ public class ReloadRoomCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
Emulator.getThreading().run(() -> {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room != null) {
- Collection habbos = new ArrayList<>(room.getHabbos());
- Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
- room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
- ServerMessage message = new RoomForwardMessageComposer(room.getId()).compose();
+ Collection habbos = new ArrayList<>(room.getRoomUnitManager().getCurrentHabbos().values());
+ room.dispose();
+ room = Emulator.getGameEnvironment().getRoomManager().getRoom(room.getRoomInfo().getId());
+ ServerMessage message = new RoomForwardMessageComposer(room.getRoomInfo().getId()).compose();
habbos.forEach(habbo -> habbo.getClient().sendResponse(message));
}
}, 100);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java
index 70ad2b80..7c75c86e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RightsCommand.java
@@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.commands.list;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.PermissionRight;
@@ -15,11 +16,17 @@ public class RightsCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) throws Exception {
StringBuilder message = new StringBuilder(getTextsValue("commands.generic.cmd_rights.text"));
- Set rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights();
+ Set rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights();
message.append("(").append(rights.size()).append("):\r\n");
- for(PermissionRight right : rights) {
+ for(String rightName : rights) {
+ PermissionRight right = Emulator.getGameEnvironment().getPermissionsManager().getRight(rightName);
+
+ if(right == null) {
+ continue;
+ }
+
message.append(right.getName()).append(" - ").append(right.getDescription()).append("\r");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java
index 36fff7ee..5a542b86 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomAlertCommand.java
@@ -28,7 +28,7 @@ public class RoomAlertCommand extends Command {
return true;
}
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room != null) {
room.sendComposer(new IssueCloseNotificationMessageComposer(message).compose());
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java
index 958be816..f59d01c1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomBundleCommand.java
@@ -30,7 +30,7 @@ public class RoomBundleCommand extends Command {
return true;
}
- if (Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()) != null) {
+ if (Emulator.getGameEnvironment().getCatalogManager().getCatalogPage("room_bundle_" + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()) != null) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_bundle.duplicate"), RoomChatMessageBubbles.ALERT);
return true;
}
@@ -40,7 +40,7 @@ public class RoomBundleCommand extends Command {
points = Integer.parseInt(params[3]);
pointsType = Integer.parseInt(params[4]);
- CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getName(), "room_bundle_" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId(), parentId);
+ CatalogPage page = Emulator.getGameEnvironment().getCatalogManager().createCatalogPage("Room Bundle: " + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getName(), "room_bundle_" + gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), 0, CatalogPageLayouts.room_bundle, gameClient.getHabbo().getHabboInfo().getPermissionGroup().getId(), parentId);
if (page instanceof RoomBundleLayout roomBundleLayout) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items (page_id, item_ids, catalog_name, cost_credits, cost_points, points_type ) VALUES (?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
@@ -67,7 +67,7 @@ public class RoomBundleCommand extends Command {
} catch (SQLException e) {
log.error("Caught SQL exception", e);
}
- roomBundleLayout.loadItems(gameClient.getHabbo().getHabboInfo().getCurrentRoom());
+ roomBundleLayout.loadItems(gameClient.getHabbo().getRoomUnit().getRoom());
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_bundle").replace("%id%", roomBundleLayout.getId() + ""), RoomChatMessageBubbles.ALERT);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java
index bf39fef0..f2cad1cc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomDanceCommand.java
@@ -28,9 +28,9 @@ public class RoomDanceCommand extends Command {
return true;
}
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> {
habbo.getRoomUnit().setDanceType(DanceType.values()[danceId]);
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose());
+ habbo.getRoomUnit().getRoom().sendComposer(new DanceMessageComposer(habbo.getRoomUnit()).compose());
});
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_danceall.no_dance"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java
index d164a3a0..2ba5902c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomEffectCommand.java
@@ -21,8 +21,8 @@ public class RoomEffectCommand extends Command {
int effectId = Integer.parseInt(params[1]);
if (effectId >= 0) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
- room.getHabbos().forEach(habbo -> room.giveEffect(habbo, effectId, -1));
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
+ room.getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> habbo.getRoomUnit().giveEffect(effectId, -1));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_roomeffect.positive"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java
index 0fd9b203..e7f5670e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomItemCommand.java
@@ -29,9 +29,9 @@ public class RoomItemCommand extends Command {
}
}
- for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) {
+ for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) {
habbo.getRoomUnit().setHandItem(itemId);
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose());
+ habbo.getRoomUnit().getRoom().sendComposer(new CarryObjectMessageComposer(habbo.getRoomUnit()).compose());
}
if (itemId > 0) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java
index 6b0e8ae9..f7caa38b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomKickCommand.java
@@ -17,15 +17,15 @@ public class RoomKickCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ final Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room != null) {
if (params.length > 1) {
String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
room.sendComposer(new HabboBroadcastMessageComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose());
}
- for (Habbo habbo : room.getHabbos()) {
- if (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) {
+ for (Habbo habbo : room.getRoomUnitManager().getCurrentHabbos().values()) {
+ if (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo))) {
room.kickHabbo(habbo, true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java
index 3e97d0e6..d07c0bdc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomMuteCommand.java
@@ -13,7 +13,7 @@ public class RoomMuteCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
if (room != null) {
room.setMuted(!room.isMuted());
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java
index 0f375fbe..8071ffa5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/RoomSitCommand.java
@@ -11,13 +11,13 @@ public class RoomSitCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> {
if (habbo.getRoomUnit().isWalking()) {
habbo.getRoomUnit().stopWalking();
} else if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
return;
}
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(habbo);
+ gameClient.getHabbo().getRoomUnit().makeSit();
});
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java
index 262a6ee0..d4127436 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayAllCommand.java
@@ -21,7 +21,7 @@ public class SayAllCommand extends Command {
String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> habbo.talk(message));
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> habbo.talk(message));
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java
index 3320b9d3..70dbe876 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SayCommand.java
@@ -28,7 +28,7 @@ public class SayCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_say.user_not_found"), RoomChatMessageBubbles.ALERT);
return true;
} else {
- if (target.getHabboInfo().getCurrentRoom() == null) {
+ if (target.getRoomUnit().getRoom() == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_say.hotel_view"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
@@ -39,7 +39,7 @@ public class SayCommand extends Command {
message = IntStream.range(2, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
}
- target.getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose());
+ target.getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose());
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_say"), params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java
index c512e42d..2081a269 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetMaxCommand.java
@@ -20,7 +20,7 @@ public class SetMaxCommand extends Command {
}
if (max > 0 && max < 9999) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().setUsersMax(max);
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().setMaxUsers(max);
gameClient.getHabbo().whisper(getTextsValue("commands.success.cmd_setmax").replace("%value%", max + ""), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_setmax.invalid_number"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java
index 3682b784..cc2e030f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetPollCommand.java
@@ -17,7 +17,7 @@ public class SetPollCommand extends Command {
return true;
}
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null) {
int pollId = -1;
try {
pollId = Integer.parseInt(params[1]);
@@ -25,7 +25,7 @@ public class SetPollCommand extends Command {
if (pollId >= 0) {
if (Emulator.getGameEnvironment().getPollManager().getPoll(pollId) != null) {
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPollId(pollId);
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().setPollId(pollId);
gameClient.getHabbo().whisper(getTextsValue("commands.succes.cmd_set_poll"), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_set_poll.not_found"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java
index 9525c6fc..bf826518 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SetSpeedCommand.java
@@ -13,10 +13,10 @@ public class SetSpeedCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ if (gameClient.getHabbo().getRoomUnit().getRoom() != null && gameClient.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(gameClient.getHabbo())) {
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
- int oldSpeed = room.getRollerSpeed();
+ int oldSpeed = room.getRoomInfo().getRollerSpeed();
int newSpeed;
try {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java
index 128339ac..40d79756 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutAllCommand.java
@@ -22,7 +22,7 @@ public class ShoutAllCommand extends Command {
String message = IntStream.range(1, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
- for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) {
+ for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) {
habbo.shout(message);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java
index a19529e2..32bb8a85 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/ShoutCommand.java
@@ -29,7 +29,7 @@ public class ShoutCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_shout.user_not_found"), RoomChatMessageBubbles.ALERT);
return true;
} else {
- if (target.getHabboInfo().getCurrentRoom() == null) {
+ if (target.getRoomUnit().getRoom() == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_shout.hotel_view"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
@@ -40,7 +40,7 @@ public class ShoutCommand extends Command {
message = IntStream.range(2, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
}
- target.getHabboInfo().getCurrentRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose());
+ target.getRoomUnit().getRoom().sendComposer(new ShoutMessageComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose());
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_shout"), params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java
index 0e8703f0..66667785 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SitCommand.java
@@ -10,8 +10,8 @@ public class SitCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getRiding() == null) //TODO Make this an event plugin which fires that can be cancelled
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeSit(gameClient.getHabbo());
+ if (!gameClient.getHabbo().getRoomUnit().isRiding()) //TODO Make this an event plugin which fires that can be cancelled
+ gameClient.getHabbo().getRoomUnit().makeSit();
return true;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java
index 8bd98051..7e97d4c1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SoftKickCommand.java
@@ -15,7 +15,7 @@ public class SoftKickCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length != 2) return true;
- final Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
+ final Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.keys.cmd_softkick_error"), params[1]), RoomChatMessageBubbles.ALERT);
@@ -27,9 +27,9 @@ public class SoftKickCommand extends Command {
return true;
}
- final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ final Room room = gameClient.getHabbo().getRoomUnit().getRoom();
- if (room != null && (!(habbo.hasRight(Permission.ACC_UNKICKABLE) || habbo.hasRight(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo)))) {
+ if (room != null && (!(habbo.hasPermissionRight(Permission.ACC_UNKICKABLE) || habbo.hasPermissionRight(Permission.ACC_SUPPORTTOOL) || room.getRoomInfo().isRoomOwner(habbo)))) {
room.kickHabbo(habbo, false);
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java
index 928a1d55..e1b41502 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StalkCommand.java
@@ -13,7 +13,7 @@ public class StalkCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null)
return true;
if (params.length >= 2) {
@@ -24,7 +24,7 @@ public class StalkCommand extends Command {
return true;
}
- if (habbo.getHabboInfo().getCurrentRoom() == null) {
+ if (habbo.getRoomUnit().getRoom() == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_stalk.not_room"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
@@ -34,12 +34,12 @@ public class StalkCommand extends Command {
return true;
}
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == habbo.getRoomUnit().getRoom()) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.generic.cmd_stalk.same_room"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
- gameClient.sendResponse(new GetGuestRoomResultComposer(habbo.getHabboInfo().getCurrentRoom(), gameClient.getHabbo(), true, false));
+ gameClient.sendResponse(new GetGuestRoomResultComposer(habbo.getRoomUnit().getRoom(), gameClient.getHabbo(), true, false));
} else {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_stalk.forgot_username"), RoomChatMessageBubbles.ALERT);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java
index f14e36b6..9f65e5a0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/StandCommand.java
@@ -10,8 +10,10 @@ public class StandCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getRiding() == null)
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().makeStand(gameClient.getHabbo());
+ if (!gameClient.getHabbo().getRoomUnit().isRiding()) {
+ gameClient.getHabbo().getRoomUnit().makeStand();
+ }
+
return true;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java
index 70618942..bd1e8f85 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SubscriptionCommand.java
@@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.habbohotel.users.HabboStats;
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
@@ -45,7 +44,7 @@ public class SubscriptionCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_subscription.invalid_params", "Invalid command format"), RoomChatMessageBubbles.ALERT);
return true;
}
- HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]);
+ HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
if (info == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_subscription.user_not_found", "%user% was not found"), params[1]), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java
index f889259b..1c679c37 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonCommand.java
@@ -15,7 +15,7 @@ public class SummonCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == null)
return true;
if (params.length < 2) {
@@ -35,23 +35,23 @@ public class SummonCommand extends Command {
return true;
}
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() == habbo.getHabboInfo().getCurrentRoom()) {
+ if (gameClient.getHabbo().getRoomUnit().getRoom() == habbo.getRoomUnit().getRoom()) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.generic.cmd_summon.same_room"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
- Room room = habbo.getHabboInfo().getCurrentRoom();
+ Room room = habbo.getRoomUnit().getRoom();
+
+ //WHY? Why not just roomManager -> leaveRoom()
if (room != null) {
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
- room.removeHabbo(habbo, true);
-
- habbo.getHabboInfo().setCurrentRoom(null);
+ room.getRoomUnitManager().removeHabbo(habbo, true);
}
- Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
+ Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), "", true);
- habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
+ habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()));
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_summon.summoned"), params[1]), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java
index efc1ef4b..07e38c0b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SummonRankCommand.java
@@ -30,21 +30,19 @@ public class SummonRankCommand extends Command {
if (habbo == gameClient.getHabbo())
continue;
- if (habbo.getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom())
+ if (habbo.getRoomUnit().getRoom() == gameClient.getHabbo().getRoomUnit().getRoom())
continue;
- Room room = habbo.getHabboInfo().getCurrentRoom();
+ Room room = habbo.getRoomUnit().getRoom();
if (room != null) {
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
- room.removeHabbo(habbo, true);
-
- habbo.getHabboInfo().setCurrentRoom(null);
+ room.getRoomUnitManager().removeHabbo(habbo, true);
}
- Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
+ Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId(), "", true);
- habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
+ habbo.getClient().sendResponse(new RoomForwardMessageComposer(gameClient.getHabbo().getRoomUnit().getRoom().getRoomInfo().getId()));
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java
index a783adea..852230a9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/SuperPullCommand.java
@@ -20,7 +20,7 @@ public class SuperPullCommand extends Command {
return true;
}
- Habbo habbo = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(params[1]);
+ Habbo habbo = gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getRoomHabboByUsername(params[1]);
if (habbo == null) {
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.error.cmd_pull.not_found"), params[1]), RoomChatMessageBubbles.ALERT);
@@ -29,15 +29,15 @@ public class SuperPullCommand extends Command {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_pull.pull_self"), RoomChatMessageBubbles.ALERT);
return true;
} else {
- RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
+ RoomTile tile = gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentPosition(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
if (tile != null && tile.isWalkable()) {
- if (tile == gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getDoorTile()) {
+ if (tile == gameClient.getHabbo().getRoomUnit().getRoom().getLayout().getDoorTile()) {
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_pull.invalid"), params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
- habbo.getRoomUnit().setGoalLocation(tile);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
+ habbo.getRoomUnit().walkTo(tile);
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new ChatMessageComposer(new RoomChatMessage(replaceUser(getTextsValue("commands.succes.cmd_pull.pull"), params[1]).replace("%gender_name%", (gameClient.getHabbo().getHabboInfo().getGender().equals(HabboGender.M) ? getTextsValue("gender.him") : getTextsValue("gender.her"))), gameClient.getHabbo(), gameClient.getHabbo(), RoomChatMessageBubbles.NORMAL)).compose());
}
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java
index b39d024a..518b44fa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TeleportCommand.java
@@ -12,16 +12,16 @@ public class TeleportCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo().getHabboInfo().getRiding() != null){ //TODO Make this an event plugin which fires that can be cancelled
+ if (gameClient.getHabbo().getRoomUnit().isRiding()){ //TODO Make this an event plugin which fires that can be cancelled
return true;
}
- if (gameClient.getHabbo().getRoomUnit().isCmdTeleport()) {
- gameClient.getHabbo().getRoomUnit().setCmdTeleport(false);
+ if (gameClient.getHabbo().getRoomUnit().isCmdTeleportEnabled()) {
+ gameClient.getHabbo().getRoomUnit().setCmdTeleportEnabled(false);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.disabled"), RoomChatMessageBubbles.ALERT);
return true;
} else {
- gameClient.getHabbo().getRoomUnit().setCmdTeleport(true);
+ gameClient.getHabbo().getRoomUnit().setCmdTeleportEnabled(true);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.enabled"), RoomChatMessageBubbles.ALERT);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java
index 6647cc5e..a397ccbe 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TestCommand.java
@@ -1,10 +1,11 @@
package com.eu.habbo.habbohotel.commands.list;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.permissions.Permission;
-import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+
+import java.util.Map;
+import java.util.Set;
public class TestCommand extends Command {
public TestCommand() {
@@ -13,35 +14,17 @@ public class TestCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (gameClient.getHabbo() != null || !gameClient.getHabbo().hasRight(Permission.ACC_SUPPORTTOOL) || !Emulator.debugging)
- return false;
+ StringBuilder message = new StringBuilder("RoomUnit Statuses");
- int header = Integer.parseInt(params[1]);
+ Set> statuses = gameClient.getHabbo().getRoomUnit().getStatuses().entrySet();
- ServerMessage message = new ServerMessage(header);
+ message.append("(").append(statuses.size()).append("):\r\n");
- for (int i = 1; i < params.length; i++) {
- String[] data = params[i].split(":");
-
- if (data[0].equalsIgnoreCase("b")) {
- message.appendBoolean(data[1].equalsIgnoreCase("1"));
- } else if (data[0].equalsIgnoreCase("s")) {
- if (data.length > 1) {
- message.appendString(data[1]);
- } else {
- message.appendString("");
- }
- } else if (data[0].equals("i")) {
- message.appendInt(Integer.parseInt(data[1]));
- } else if (data[0].equalsIgnoreCase("by")) {
- message.appendByte(Integer.parseInt(data[1]));
- } else if (data[0].equalsIgnoreCase("sh")) {
- message.appendShort(Integer.parseInt(data[1]));
- }
+ for(Map.Entry status : statuses) {
+ message.append(status.getKey().toString()).append("\r");
}
- gameClient.sendResponse(message);
-
+ gameClient.getHabbo().alert(new String[]{message.toString()});
return true;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java
index f59c6498..5f6f0b8d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/TransformCommand.java
@@ -5,8 +5,8 @@ import com.eu.habbo.core.RoomUserPetComposer;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.pets.PetData;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.messages.outgoing.generic.alerts.MOTDNotificationComposer;
import com.eu.habbo.messages.outgoing.rooms.users.UserRemoveMessageComposer;
@@ -57,8 +57,8 @@ public class TransformCommand extends Command {
gameClient.getHabbo().getHabboStats().getCache().put("pet_type", petData);
gameClient.getHabbo().getHabboStats().getCache().put("pet_race", race);
gameClient.getHabbo().getHabboStats().getCache().put("pet_color", color);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UserRemoveMessageComposer(gameClient.getHabbo().getRoomUnit()).compose());
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new UserRemoveMessageComposer(gameClient.getHabbo().getRoomUnit()).compose());
+ gameClient.getHabbo().getRoomUnit().getRoom().sendComposer(new RoomUserPetComposer(petData.getType(), race, color, gameClient.getHabbo()).compose());
} else {
//Pet Not Found
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java
index 99c157f5..f8bb0e38 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnloadRoomCommand.java
@@ -13,9 +13,9 @@ public class UnloadRoomCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = gameClient.getHabbo().getRoomUnit().getRoom();
- if (room != null && (room.isOwner(gameClient.getHabbo()) || (room.hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)) {
+ if (room != null && (room.getRoomInfo().isRoomOwner(gameClient.getHabbo()) || (room.getRoomInfo().hasGuild() && room.getGuildRightLevel(gameClient.getHabbo()).equals(RoomRightLevels.GUILD_ADMIN))) || gameClient.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)) {
room.dispose();
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java
index 29b65f1d..cb0c4e42 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UnmuteCommand.java
@@ -25,13 +25,13 @@ public class UnmuteCommand extends Command {
return true;
}
- if (!habbo.getHabboStats().allowTalk() || (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo))) {
+ if (!habbo.getHabboStats().allowTalk() || (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo))) {
if (!habbo.getHabboStats().allowTalk()) {
habbo.unMute();
}
- if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) {
- habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1);
+ if (habbo.getRoomUnit().getRoom() != null && habbo.getRoomUnit().getRoom().isMuted(habbo)) {
+ habbo.getRoomUnit().getRoom().muteHabbo(habbo, 1);
}
gameClient.getHabbo().whisper(replaceUser(getTextsValue("commands.succes.cmd_unmute"), params[1]), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java
index ccfeae37..b2e1be1c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UpdateItemsCommand.java
@@ -19,7 +19,7 @@ public class UpdateItemsCommand extends Command {
synchronized (Emulator.getGameEnvironment().getRoomManager().getActiveRooms()) {
Emulator.getGameEnvironment().getRoomManager().getActiveRooms().stream()
- .filter(room -> room.isLoaded() && room.getUserCount() > 0 && room.getLayout() != null)
+ .filter(room -> room.isLoaded() && room.getRoomUnitManager().getRoomHabbosCount() > 0 && room.getLayout() != null)
.forEach(room -> room.sendComposer(new HeightMapComposer(room).compose()));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java
index 39cb7f8f..871be6ec 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/UserInfoCommand.java
@@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import gnu.trove.iterator.TIntIntIterator;
import java.text.SimpleDateFormat;
@@ -30,7 +29,7 @@ public class UserInfoCommand extends Command {
HabboInfo habbo = (onlineHabbo != null ? onlineHabbo.getHabboInfo() : null);
if (habbo == null) {
- habbo = HabboManager.getOfflineHabboInfo(params[1]);
+ habbo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
}
if (habbo == null) {
@@ -44,9 +43,9 @@ public class UserInfoCommand extends Command {
getTextsValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" +
getTextsValue("command.cmd_userinfo.rank") + ": " + habbo.getPermissionGroup().getName() + " (" + habbo.getPermissionGroup().getId() + ") \r" +
getTextsValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" +
- ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_MAIL, true)) ? "" : getTextsValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
- ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_IP, true)) ? "" : getTextsValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
- ((habbo.getPermissionGroup().hasRight(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : getTextsValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") +
+ ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_MAIL, true)) ? "" : getTextsValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
+ ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_IP, true)) ? "" : getTextsValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
+ ((habbo.getPermissionGroup().hasPermissionRight(Permission.ACC_HIDE_IP, true)) || onlineHabbo == null ? "" : getTextsValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getHabboInfo().getIpLogin() + "\r") +
(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().getAchievementScore() + "\r" : ""));
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
@@ -71,7 +70,7 @@ public class UserInfoCommand extends Command {
message.append(getTextsValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r");
}
- message.append("\r").append(onlineHabbo != null ? "" + getTextsValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().getRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().getPetRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().isBlockFollowing()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().isBlockFriendRequests()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "");
+ message.append("\r").append(onlineHabbo != null ? "" + getTextsValue("command.cmd_userinfo.current_activity") + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getRoomUnit().getRoom() != null ? onlineHabbo.getRoomUnit().getRoom().getRoomInfo().getName() + "(" + onlineHabbo.getRoomUnit().getRoom().getRoomInfo().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().getRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().getPetRespectPointsToGive() + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? getTextsValue("generic.yes") : getTextsValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().isBlockFollowing()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? getTextsValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().isBlockFriendRequests()) ? getTextsValue("generic.no") : getTextsValue("generic.yes")) + "\r" : "");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java
index 8c5b8508..f3954e0b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/WordQuizCommand.java
@@ -13,7 +13,7 @@ public class WordQuizCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) {
- if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) {
+ if (!gameClient.getHabbo().getRoomUnit().getRoom().hasActiveWordQuiz()) {
if(params.length == 1) {
gameClient.getHabbo().whisper(getTextsValue("commands.description.cmd_word_quiz"), RoomChatMessageBubbles.ALERT);
return true;
@@ -31,7 +31,7 @@ public class WordQuizCommand extends Command {
question.append(" ").append(params[i]);
}
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000);
+ gameClient.getHabbo().getRoomUnit().getRoom().startWordQuiz(question.toString(), duration * 1000);
}
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java
index 51a57aec..ae6e1f71 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/BadgeCommand.java
@@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
@@ -42,7 +41,7 @@ public class BadgeCommand extends BaseBadgeCommand {
return true;
} else {
- HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(params[1]);
+ HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
if (habboInfo == null) {
gameClient.getHabbo().whisper(getTextsValue("commands.error.cmd_badge.unknown_user"), RoomChatMessageBubbles.ALERT);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java
index 45b38c4b..62c777a9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/RoomBadgeCommand.java
@@ -20,7 +20,7 @@ public class RoomBadgeCommand extends BaseBadgeCommand {
if (!badge.isEmpty()) {
ServerMessage message = createServerMessage(badge);
- gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()
.forEach(habbo -> sendBadgeToClient(badge, message, habbo));
}
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java
index 9ed7ffe4..d27c0bbb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/badge/TakeBadgeCommand.java
@@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.outgoing.inventory.BadgesComposer;
import com.eu.habbo.messages.outgoing.users.UserBadgesComposer;
@@ -41,8 +40,8 @@ public class TakeBadgeCommand extends BaseBadgeCommand {
}
habbo.getClient().sendResponse(new BadgesComposer(habbo));
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose());
+ if (habbo.getRoomUnit().getRoom() != null) {
+ habbo.getRoomUnit().getRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose());
}
}
@@ -51,7 +50,7 @@ public class TakeBadgeCommand extends BaseBadgeCommand {
if (habbo != null)
userId = habbo.getHabboInfo().getId();
else {
- HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username);
+ HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(username);
if (habboInfo != null)
userId = habboInfo.getId();
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java
index 3215fb19..4839d98e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BanCommand.java
@@ -8,7 +8,6 @@ import com.eu.habbo.habbohotel.modtool.ModToolBanType;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -54,7 +53,7 @@ public class BanCommand extends Command {
if (t != null) {
target = t.getHabboInfo();
} else {
- target = HabboManager.getOfflineHabboInfo(params[1]);
+ target = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
}
if (target == null) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java
index a0073c31..4bd23179 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/bans/BaseBanCommand.java
@@ -1,10 +1,10 @@
package com.eu.habbo.habbohotel.commands.list.bans;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@@ -43,7 +43,7 @@ public abstract class BaseBanCommand extends Command {
if (h != null) {
return h.getHabboInfo();
} else {
- return HabboManager.getOfflineHabboInfo(params[1]);
+ return Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
}
}
return null;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java
index def03e2a..ecff906c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/CreditsCommand.java
@@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
public class CreditsCommand extends BaseCreditsCommand {
private static final String INVALID_AMOUNT = "commands.error.cmd_credits.invalid_amount";
@@ -17,7 +16,7 @@ public class CreditsCommand extends BaseCreditsCommand {
@Override
public boolean handle(GameClient gameClient, String[] params) {
if (params.length == 3) {
- HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]);
+ HabboInfo info = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(params[1]);
if (info != null) {
Habbo habbo = getHabbo(params[1]);
@@ -32,7 +31,7 @@ public class CreditsCommand extends BaseCreditsCommand {
if (habbo != null) {
if (credits != 0) {
habbo.giveCredits(credits);
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), params[2]), RoomChatMessageBubbles.ALERT);
else
habbo.alert(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), params[2]));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java
index 74f1ed68..7a68c283 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/MassCreditsCommand.java
@@ -32,7 +32,7 @@ public class MassCreditsCommand extends BaseCreditsCommand {
habbo.giveCredits(amount);
habbo.getClient().sendResponse(new CreditBalanceComposer(habbo));
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), amount + ""), RoomChatMessageBubbles.ALERT);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java
index cb895fbb..1296233d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/credits/RoomCreditsCommand.java
@@ -22,7 +22,7 @@ public class RoomCreditsCommand extends BaseCreditsCommand {
if (amount != 0) {
final String message = replaceAmount(getTextsValue("commands.generic.cmd_credits.received"), amount + "");
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> {
habbo.giveCredits(amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT);
});
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java
index efd07557..da9a9040 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/BaseGiftCommand.java
@@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import java.util.stream.Collectors;
@@ -49,7 +49,7 @@ public abstract class BaseGiftCommand extends Command {
}
protected void createGift(String finalMessage, Habbo habbo, String[] params) {
- HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, getBaseItem(params), 0, 0, "");
+ RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, getBaseItem(params), 0, 0, "");
Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java
index c360e3d6..c72b46ee 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/GiftCommand.java
@@ -4,10 +4,9 @@ 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.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
@@ -46,7 +45,7 @@ public class GiftCommand extends BaseGiftCommand {
return true;
}
- HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(username);
+ HabboInfo habboInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(username);
if (habboInfo == null) {
gameClient.getHabbo().whisper(replaceUsername(getTextsValue("commands.error.cmd_gift.user_not_found"), username), RoomChatMessageBubbles.ALERT);
@@ -55,7 +54,7 @@ public class GiftCommand extends BaseGiftCommand {
String message = params.length > 3 ? IntStream.range(3, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining()) : "";
- HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
+ RoomItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
String extraData = "1\t" + item.getId() + "\t0\t0\t0\t" + message + "\t0\t0";
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java
index f36f9886..edc30c8e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/gift/RoomGiftCommand.java
@@ -17,7 +17,7 @@ public class RoomGiftCommand extends BaseGiftCommand {
final String finalMessage = getFinalMessage(params);
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> {
createGift(finalMessage, habbo, params);
habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_ITEM));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java
index 447f8cea..fd9eb5f2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/MassPixelsCommand.java
@@ -30,7 +30,7 @@ public class MassPixelsCommand extends BasePixelsCommand {
habbo.givePixels(amount);
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), amount + ""), RoomChatMessageBubbles.ALERT);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java
index ec4c0a28..2cbc0f4f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/PixelCommand.java
@@ -21,7 +21,7 @@ public class PixelCommand extends BasePixelsCommand {
try {
if (Integer.parseInt(params[2]) != 0) {
habbo.givePixels(Integer.parseInt(params[2]));
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), params[2]), RoomChatMessageBubbles.ALERT);
else
habbo.alert(replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), params[2]));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java
index ef838f7f..b5ec0e96 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/pixels/RoomPixelsCommand.java
@@ -22,7 +22,7 @@ public class RoomPixelsCommand extends BasePixelsCommand {
if (amount != 0) {
final String message = replaceAmount(getTextsValue("commands.generic.cmd_duckets.received"), amount + "");
- gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos().forEach(habbo -> {
+ gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values().forEach(habbo -> {
habbo.givePixels(amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT);
});
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java
index c8890cdc..71ccb991 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/MassPointsCommand.java
@@ -58,7 +58,7 @@ public class MassPointsCommand extends BasePointsCommand {
for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) {
habbo.givePoints(type, amount);
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(message, RoomChatMessageBubbles.ALERT);
else
habbo.alert(message);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java
index 23b3451b..dce20efb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/PointsCommand.java
@@ -48,7 +48,7 @@ public class PointsCommand extends BasePointsCommand {
if (amount != 0) {
habbo.givePoints(type, amount);
- if (habbo.getHabboInfo().getCurrentRoom() != null)
+ if (habbo.getRoomUnit().getRoom() != null)
habbo.whisper(replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT);
else
habbo.alert(replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type)));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java
index 40f82a89..8b50d3d5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/list/points/RoomPointsCommand.java
@@ -55,7 +55,7 @@ public class RoomPointsCommand extends BasePointsCommand {
if (amount != 0) {
final String message = replaceAmountAndType(getTextsValue("commands.generic.cmd_points.received"), amount + "", getTextsValue("seasonal.name." + type));
- for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) {
+ for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getRoomUnitManager().getCurrentHabbos().values()) {
habbo.givePoints(type, amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
index 354429a3..e39b5fc3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/gameclients/GameClientManager.java
@@ -152,7 +152,7 @@ public class GameClientManager {
continue;
if (client.getHabbo() != null) {
- if (client.getHabbo().hasRight(minPermission)) {
+ if (client.getHabbo().hasPermissionRight(minPermission)) {
client.sendResponse(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
index aa50cea7..deae2ce4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
@@ -8,8 +8,8 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry;
import com.eu.habbo.messages.outgoing.guides.YouArePlayingGameMessageComposer;
@@ -120,7 +120,7 @@ public abstract class Game implements Runnable {
Emulator.getPluginManager().fireEvent(gameStartedEvent);
}
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
((WiredBlob) item).onGameStart(this.room);
}
@@ -136,7 +136,7 @@ public abstract class Game implements Runnable {
int totalPointsGained = this.teams.values().stream().mapToInt(GameTeam::getTotalScore).sum();
- Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getOwnerId());
+ Habbo roomOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.room.getRoomInfo().getOwnerInfo().getId());
if (roomOwner != null) {
AchievementManager.progressAchievement(roomOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("GameAuthorExperience"), totalPointsGained);
}
@@ -161,7 +161,7 @@ public abstract class Game implements Runnable {
}
if (winningTeam.getMembers().size() > 0) {
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp()));
}
}
@@ -174,19 +174,19 @@ public abstract class Game implements Runnable {
}
if (team.getMembers().size() > 0 && team.getTotalScore() > 0) {
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), team.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), team.getTotalScore(), false, Emulator.getIntUnixTimestamp()));
}
}
}
}
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
((InteractionWiredHighscore) item).reloadData();
this.room.updateItem(item);
}
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) {
((WiredBlob) item).onGameEnd(this.room);
}
}
@@ -209,7 +209,7 @@ public abstract class Game implements Runnable {
this.state = GameState.IDLE;
boolean gamesActive = false;
- for (HabboItem timer : room.getFloorItems()) {
+ for (RoomItem timer : room.getRoomItemManager().getFloorItems().values()) {
if (timer instanceof InteractionGameTimer) {
if (((InteractionGameTimer) timer).isRunning())
gamesActive = true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
index b3653c11..781bd3ac 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
@@ -24,7 +24,7 @@ public class GamePlayer {
}
public synchronized void addScore(int amount, boolean isWired) {
- if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
+ if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getRoomUnit().getRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
this.score += amount;
if (this.score < 0) this.score = 0;
@@ -33,7 +33,7 @@ public class GamePlayer {
this.wiredScore += amount;
}
- WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
+ WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getRoomUnit().getRoom(), new Object[]{this.habbo.getRoomUnit().getRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
index 33f83e3b..8968e945 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGame.java
@@ -11,8 +11,8 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer;
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
import gnu.trove.map.hash.THashMap;
@@ -35,8 +35,8 @@ public class BattleBanzaiGame extends Game {
public static final int POINTS_LOCK_TILE = Emulator.getConfig().getInt("hotel.banzai.points.tile.lock", 1);
private static final ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Emulator.getConfig().getInt("hotel.banzai.fill.threads", 2));
- private final THashMap> lockedTiles;
- private final THashMap gameTiles;
+ private final THashMap> lockedTiles;
+ private final THashMap gameTiles;
private int tileCount;
private int countDown;
private int countDown2;
@@ -69,8 +69,8 @@ public class BattleBanzaiGame extends Game {
}
}
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
- item.setExtradata("1");
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
+ item.setExtraData("1");
this.room.updateItemState(item);
}
@@ -104,13 +104,13 @@ public class BattleBanzaiGame extends Game {
this.countDown--;
if (this.countDown == 0) {
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
- item.setExtradata("1");
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
+ item.setExtraData("1");
this.room.updateItemState(item);
if(this.countDown2 > 0) {
this.countDown2--;
if(this.countDown2 == 0) {
- item.setExtradata("2");
+ item.setExtraData("2");
this.room.updateItemState(item);
}
}
@@ -130,7 +130,7 @@ public class BattleBanzaiGame extends Game {
int total = 0;
synchronized (this.lockedTiles) {
- for (Map.Entry> set : this.lockedTiles.entrySet()) {
+ for (Map.Entry> set : this.lockedTiles.entrySet()) {
total += set.getValue().size();
}
}
@@ -146,8 +146,8 @@ public class BattleBanzaiGame extends Game {
}
if (highestScore != null) {
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
- item.setExtradata((highestScore.teamColor.type + 2) + "");
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
+ item.setExtraData((highestScore.teamColor.type + 2) + "");
this.room.updateItemState(item);
}
}
@@ -194,8 +194,8 @@ public class BattleBanzaiGame extends Game {
}
}
- for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
- item.setExtradata((6 + winningTeam.teamColor.type) + "");
+ for (RoomItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionBattleBanzaiSphere.class)) {
+ item.setExtraData((6 + winningTeam.teamColor.type) + "");
this.room.updateItemState(item);
}
synchronized (this.lockedTiles) {
@@ -212,9 +212,9 @@ public class BattleBanzaiGame extends Game {
this.refreshGates();
- for (HabboItem tile : this.gameTiles.values()) {
- if (tile.getExtradata().equals("1")) {
- tile.setExtradata("0");
+ for (RoomItem tile : this.gameTiles.values()) {
+ if (tile.getExtraData().equals("1")) {
+ tile.setExtraData("0");
this.room.updateItem(tile);
}
}
@@ -226,27 +226,27 @@ public class BattleBanzaiGame extends Game {
private synchronized void resetMap() {
this.tileCount = 0;
- for (HabboItem item : this.room.getFloorItems()) {
+ for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) {
if (item instanceof InteractionBattleBanzaiTile) {
- item.setExtradata("1");
+ item.setExtraData("1");
this.room.updateItemState(item);
this.tileCount++;
this.gameTiles.put(item.getId(), item);
}
if (item instanceof InteractionBattleBanzaiScoreboard) {
- item.setExtradata("0");
+ item.setExtraData("0");
this.room.updateItemState(item);
}
}
}
- public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) {
+ public void tileLocked(GameTeamColors teamColor, RoomItem item, Habbo habbo) {
this.tileLocked(teamColor, item, habbo, false);
}
- public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) {
+ public void tileLocked(GameTeamColors teamColor, RoomItem item, Habbo habbo, boolean doNotCheckFill) {
synchronized (this.lockedTiles) {
if (item instanceof InteractionBattleBanzaiTile) {
if (!this.lockedTiles.containsKey(teamColor)) {
@@ -262,11 +262,11 @@ public class BattleBanzaiGame extends Game {
if (doNotCheckFill) return;
- final int x = item.getX();
- final int y = item.getY();
+ final int x = item.getCurrentPosition().getX();
+ final int y = item.getCurrentPosition().getY();
final List
> filledAreas = new ArrayList<>();
- final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor));
+ final THashSet lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor));
executor.execute(() -> {
filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor));
@@ -278,12 +278,12 @@ public class BattleBanzaiGame extends Game {
if (largestAreaOfAll.isPresent()) {
for (RoomTile tile : largestAreaOfAll.get()) {
- Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.getX() && i.getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny();
+ Optional tileItem = this.gameTiles.values().stream().filter(i -> i.getCurrentPosition().getX() == tile.getX() && i.getCurrentPosition().getY() == tile.getY() && i instanceof InteractionBattleBanzaiTile).findAny();
tileItem.ifPresent(habboItem -> {
this.tileLocked(teamColor, habboItem, habbo, true);
- habboItem.setExtradata((2 + (teamColor.type * 3)) + "");
+ habboItem.setExtraData((2 + (teamColor.type * 3)) + "");
this.room.updateItem(habboItem);
});
}
@@ -297,7 +297,7 @@ public class BattleBanzaiGame extends Game {
}
}
- private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) {
+ private List floodFill(int x, int y, THashSet lockedTiles, List stack, GameTeamColors color) {
if (this.isOutOfBounds(x, y) || this.isForeignLockedTile(x, y, color)) return null;
RoomTile tile = this.room.getLayout().getTile((short) x, (short) y);
@@ -320,28 +320,28 @@ public class BattleBanzaiGame extends Game {
}
- private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) {
- for (HabboItem item : lockedTiles) {
- if (item.getX() == x && item.getY() == y) return true;
+ private boolean hasLockedTileAtCoordinates(int x, int y, THashSet lockedTiles) {
+ for (RoomItem item : lockedTiles) {
+ if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return true;
}
return false;
}
private boolean isOutOfBounds(int x, int y) {
- for (HabboItem item : this.gameTiles.values()) {
- if (item.getX() == x && item.getY() == y) return false;
+ for (RoomItem item : this.gameTiles.values()) {
+ if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return false;
}
return true;
}
private boolean isForeignLockedTile(int x, int y, GameTeamColors color) {
- for (HashMap.Entry> lockedTilesForColor : this.lockedTiles.entrySet()) {
+ for (HashMap.Entry> lockedTilesForColor : this.lockedTiles.entrySet()) {
if (lockedTilesForColor.getKey() == color) continue;
- for (HabboItem item : lockedTilesForColor.getValue()) {
- if (item.getX() == x && item.getY() == y) return true;
+ for (RoomItem item : lockedTilesForColor.getValue()) {
+ if (item.getCurrentPosition().getX() == x && item.getCurrentPosition().getY() == y) return true;
}
}
@@ -366,16 +366,16 @@ public class BattleBanzaiGame extends Game {
THashMap scoreBoards = this.room.getRoomSpecialTypes().getBattleBanzaiScoreboards(teamColors);
for (InteractionBattleBanzaiScoreboard scoreboard : scoreBoards.values()) {
- if (scoreboard.getExtradata().isEmpty()) {
- scoreboard.setExtradata("0");
+ if (scoreboard.getExtraData().isEmpty()) {
+ scoreboard.setExtraData("0");
}
- int oldScore = Integer.parseInt(scoreboard.getExtradata());
+ int oldScore = Integer.parseInt(scoreboard.getExtraData());
if (oldScore == totalScore)
continue;
- scoreboard.setExtradata(totalScore + "");
+ scoreboard.setExtraData(totalScore + "");
this.room.updateItemState(scoreboard);
}
}
@@ -383,8 +383,8 @@ public class BattleBanzaiGame extends Game {
private void refreshGates() {
Collection gates = this.room.getRoomSpecialTypes().getBattleBanzaiGates().values();
THashSet tilesToUpdate = new THashSet<>(gates.size());
- for (HabboItem item : gates) {
- tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY()));
+ for (RoomItem item : gates) {
+ tilesToUpdate.add(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
}
this.room.updateTiles(tilesToUpdate);
@@ -410,7 +410,7 @@ public class BattleBanzaiGame extends Game {
}
this.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor());
- tile.setExtradata(state + "");
+ tile.setExtraData(state + "");
this.room.updateItem(tile);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java
index 94725332..50460edc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/battlebanzai/BattleBanzaiGameTeam.java
@@ -7,10 +7,10 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
public class BattleBanzaiGameTeam extends GameTeam {
public BattleBanzaiGameTeam(GameTeamColors teamColor) {
@@ -20,25 +20,27 @@ public class BattleBanzaiGameTeam extends GameTeam {
@Override
public void addMember(GamePlayer gamePlayer) {
super.addMember(gamePlayer);
- RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit();
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
+ RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit();
+ if (roomHabbo.getEffectId() > 0) {
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId());
+ roomHabbo.setPreviousEffectEndTimestamp(roomHabbo.getPreviousEffectEndTimestamp());
+ }
- gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1, true);
+ gamePlayer.getHabbo().getRoomUnit().giveEffect(BattleBanzaiGame.effectId + this.teamColor.type, -1, true);
}
@Override
public void removeMember(GamePlayer gamePlayer) {
super.removeMember(gamePlayer);
- if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getRoomUnit().getRoom() == null)
return;
Habbo habbo = gamePlayer.getHabbo();
- Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
- RoomUnit roomUnit = habbo.getRoomUnit();
- Room room = roomUnit.getRoom();
+ Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class);
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
+ Room room = roomHabbo.getRoom();
if(room == null) return;
- HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY());
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
@@ -46,22 +48,22 @@ public class BattleBanzaiGameTeam extends GameTeam {
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
+ } else if (roomHabbo.getPreviousEffectId() > 0) {
+ nextEffectF = roomHabbo.getPreviousEffectId();
+ nextEffectM = roomHabbo.getPreviousEffectId();
+ nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
}
- roomUnit.setCanWalk(true);
+ roomHabbo.setCanWalk(true);
if (room.getRoomSpecialTypes() != null) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java
index 4039feb9..bed87dcd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/football/FootballGame.java
@@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards.InteractionFootballScoreboard;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUserAction;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer;
@@ -35,11 +35,11 @@ public class FootballGame extends Game {
if (this.room == null || !this.room.isLoaded())
return;
- Habbo habbo = this.room.getHabbo(kicker);
+ Habbo habbo = this.room.getRoomUnitManager().getHabboByRoomUnit(kicker);
if (habbo != null) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored"));
- if (habbo.getHabboInfo().getId() != this.room.getOwnerId()) {
- AchievementManager.progressAchievement(this.room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom"));
+ if (habbo.getHabboInfo().getId() != this.room.getRoomInfo().getOwnerInfo().getId()) {
+ AchievementManager.progressAchievement(this.room.getRoomInfo().getOwnerInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom"));
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
index 262f48db..f859c4f8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGame.java
@@ -13,8 +13,8 @@ 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.RoomUserAction;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.users.ExpressionMessageComposer;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
@@ -78,9 +78,9 @@ public class FreezeGame extends Game {
}
synchronized void resetMap() {
- for (HabboItem item : this.room.getFloorItems()) {
+ for (RoomItem item : this.room.getRoomItemManager().getFloorItems().values()) {
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeScoreboard) {
- item.setExtradata("0");
+ item.setExtraData("0");
this.room.updateItemState(item);
}
}
@@ -90,10 +90,10 @@ public class FreezeGame extends Game {
if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
return;
- if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty())
+ if (!item.getExtraData().equalsIgnoreCase("0") && !item.getExtraData().isEmpty())
return;
- if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), this.room.getLayout().getTile(item.getX(), item.getY()))) {
+ if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentPosition(), this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()))) {
if (((FreezeGamePlayer) habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) {
Emulator.getThreading().run(new FreezeThrowSnowball(habbo, item, this.room));
}
@@ -147,7 +147,7 @@ public class FreezeGame extends Game {
powerUp += Emulator.getRandom().nextInt(6) + 1;
}
- block.setExtradata((powerUp + 1) + String.format("%3d", delay));
+ block.setExtraData((powerUp + 1) + String.format("%3d", delay));
this.room.updateItemState(block);
}
@@ -173,7 +173,7 @@ public class FreezeGame extends Game {
Emulator.getThreading().run(new FreezeClearEffects(player.getHabbo()), 1000);
if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) {
InteractionFreezeExitTile tile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
- tile.setExtradata("1");
+ tile.setExtraData("1");
this.room.updateItemState(tile);
this.room.teleportHabboToItem(player.getHabbo(), tile);
}
@@ -189,12 +189,12 @@ public class FreezeGame extends Game {
super.start();
if (this.room.getRoomSpecialTypes().hasFreezeExitTile()) {
- for (Habbo habbo : this.room.getHabbos()) {
+ for (Habbo habbo : this.room.getRoomUnitManager().getCurrentHabbos().values()) {
if (this.getTeamForHabbo(habbo) == null) {
- for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation())) {
+ for (RoomItem item : this.room.getRoomItemManager().getItemsAt(habbo.getRoomUnit().getCurrentPosition())) {
if (item instanceof InteractionFreezeTile) {
- HabboItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
- WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getX(), exitTile.getY()));
+ RoomItem exitTile = this.room.getRoomSpecialTypes().getRandomFreezeExitTile();
+ WiredEffectTeleport.teleportUnitToTile(habbo.getRoomUnit(), this.room.getLayout().getTile(exitTile.getCurrentPosition().getX(), exitTile.getCurrentPosition().getY()));
}
}
}
@@ -227,16 +227,16 @@ public class FreezeGame extends Game {
THashMap scoreBoards = this.room.getRoomSpecialTypes().getFreezeScoreboards(team.teamColor);
for (InteractionFreezeScoreboard scoreboard : scoreBoards.values()) {
- if (scoreboard.getExtradata().isEmpty()) {
- scoreboard.setExtradata("0");
+ if (scoreboard.getExtraData().isEmpty()) {
+ scoreboard.setExtraData("0");
}
- int oldScore = Integer.parseInt(scoreboard.getExtradata());
+ int oldScore = Integer.parseInt(scoreboard.getExtraData());
if (oldScore == totalScore)
continue;
- scoreboard.setExtradata(totalScore + "");
+ scoreboard.setExtraData(totalScore + "");
this.room.updateItemState(scoreboard);
}
}
@@ -282,7 +282,7 @@ public class FreezeGame extends Game {
for (Map.Entry set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet()) {
if (teamMemberCount.containsKey(set.getValue().teamColor)) {
int amount = Math.min(teamMemberCount.get(set.getValue().teamColor), 5);
- set.getValue().setExtradata(amount + "");
+ set.getValue().setExtraData(amount + "");
teamMemberCount.put(set.getValue().teamColor, teamMemberCount.get(set.getValue().teamColor) - amount);
this.room.updateItemState(set.getValue());
}
@@ -295,7 +295,7 @@ public class FreezeGame extends Game {
public void setFreezeTileState(String state) {
this.room.getRoomSpecialTypes().getFreezeExitTiles().forEachValue(object -> {
- object.setExtradata(state);
+ object.setExtraData(state);
FreezeGame.this.room.updateItemState(object);
return true;
});
@@ -304,8 +304,8 @@ public class FreezeGame extends Game {
private void refreshGates() {
THashSet tilesToUpdate = new THashSet<>();
- for (HabboItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) {
- tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY()));
+ for (RoomItem item : this.room.getRoomSpecialTypes().getFreezeGates().values()) {
+ tilesToUpdate.add(this.room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
}
this.room.updateTiles(tilesToUpdate);
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java
index 7c14d9cb..80334649 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGamePlayer.java
@@ -52,7 +52,7 @@ public class FreezeGamePlayer extends GamePlayer {
public void addLife() {
if (this.lives < FreezeGame.MAX_LIVES) {
this.lives++;
- super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose());
+ super.getHabbo().getRoomUnit().getRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose());
}
}
@@ -61,13 +61,13 @@ public class FreezeGamePlayer extends GamePlayer {
if (this.lives == 0) {
this.dead = true;
- FreezeGame game = (FreezeGame) super.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
+ FreezeGame game = (FreezeGame) super.getHabbo().getRoomUnit().getRoom().getGame(FreezeGame.class);
if (game != null) {
game.playerDies(this);
}
} else {
- super.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose());
+ super.getHabbo().getRoomUnit().getRoom().sendComposer(new GamePlayerValueMessageComposer(this).compose());
}
}
@@ -208,6 +208,6 @@ public class FreezeGamePlayer extends GamePlayer {
if (this.dead)
return;
- super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1, true);
+ super.getHabbo().getRoomUnit().giveEffect(this.correctEffectId(), -1, true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
index 845a9bb6..a31f278d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
@@ -6,10 +6,10 @@ import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
public class FreezeGameTeam extends GameTeam {
public FreezeGameTeam(GameTeamColors teamColor) {
@@ -19,16 +19,16 @@ public class FreezeGameTeam extends GameTeam {
@Override
public void removeMember(GamePlayer gamePlayer) {
super.removeMember(gamePlayer);
- if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null)
+ if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getRoomUnit().getRoom() == null)
return;
Habbo habbo = gamePlayer.getHabbo();
- Game game = habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
- RoomUnit roomUnit = habbo.getRoomUnit();
- Room room = roomUnit.getRoom();
+ Game game = habbo.getRoomUnit().getRoom().getGame(FreezeGame.class);
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
+ Room room = roomHabbo.getRoom();
if(room == null) return;
- HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY());
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
@@ -36,22 +36,22 @@ public class FreezeGameTeam extends GameTeam {
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
+ } else if (roomHabbo.getPreviousEffectId() > 0) {
+ nextEffectF = roomHabbo.getPreviousEffectId();
+ nextEffectM = roomHabbo.getPreviousEffectId();
+ nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
}
- roomUnit.setCanWalk(true);
+ roomHabbo.setCanWalk(true);
if (room.getRoomSpecialTypes() != null) {
for (InteractionGameGate gate : room.getRoomSpecialTypes().getFreezeGates().values()) {
@@ -64,9 +64,9 @@ public class FreezeGameTeam extends GameTeam {
public void addMember(GamePlayer gamePlayer) {
super.addMember(gamePlayer);
- RoomUnit roomUnit = gamePlayer.getHabbo().getRoomUnit();
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), FreezeGame.effectId + this.teamColor.type, -1, true);
+ RoomHabbo roomHabbo = gamePlayer.getHabbo().getRoomUnit();
+ if (roomHabbo.getEffectId() > 0)
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
+ gamePlayer.getHabbo().getRoomUnit().giveEffect(FreezeGame.effectId + this.teamColor.type, -1, true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
index bd612428..743d9d56 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
@@ -9,10 +9,10 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
import com.eu.habbo.plugin.events.users.UserTakeStepEvent;
@@ -34,8 +34,8 @@ public abstract class TagGame extends Game {
public static void onUserLookAtPoint(RoomUnitLookAtPointEvent event) {
if (event.room == null || event.roomUnit == null || event.location == null) return;
- if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentLocation(), event.location)) {
- Habbo habbo = event.room.getHabbo(event.roomUnit);
+ if (RoomLayout.tilesAdjecent(event.roomUnit.getCurrentPosition(), event.location)) {
+ Habbo habbo = event.room.getRoomUnitManager().getHabboByRoomUnit(event.roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentGame() != null) {
@@ -44,7 +44,7 @@ public abstract class TagGame extends Game {
if (game != null) {
if (game.isTagger(habbo)) {
- for (Habbo tagged : event.room.getHabbosAt(event.location)) {
+ for (Habbo tagged : event.room.getRoomUnitManager().getHabbosAt(event.location)) {
if (tagged == habbo || tagged.getHabboInfo().getCurrentGame() == null || tagged.getHabboInfo().getCurrentGame() != habbo.getHabboInfo().getCurrentGame()) {
continue;
}
@@ -63,15 +63,15 @@ public abstract class TagGame extends Game {
@EventHandler
public static void onUserWalkEvent(UserTakeStepEvent event) {
if (event.habbo.getHabboInfo().getCurrentGame() != null && TagGame.class.isAssignableFrom(event.habbo.getHabboInfo().getCurrentGame())) {
- THashSet items = event.habbo.getHabboInfo().getCurrentRoom().getItemsAt(event.toLocation);
+ THashSet items = event.habbo.getRoomUnit().getRoom().getRoomItemManager().getItemsAt(event.toLocation);
- TagGame game = (TagGame) event.habbo.getHabboInfo().getCurrentRoom().getGame(event.habbo.getHabboInfo().getCurrentGame());
+ TagGame game = (TagGame) event.habbo.getRoomUnit().getRoom().getGame(event.habbo.getHabboInfo().getCurrentGame());
if (game != null) {
- for (HabboItem item : items) {
+ for (RoomItem item : items) {
if (item instanceof InteractionTagField && ((InteractionTagField) item).gameClazz == event.habbo.getHabboInfo().getCurrentGame()) {
if (game.taggers.isEmpty()) {
- game.tagged(event.habbo.getHabboInfo().getCurrentRoom(), null, event.habbo);
+ game.tagged(event.habbo.getRoomUnit().getRoom(), null, event.habbo);
}
return;
}
@@ -97,22 +97,22 @@ public abstract class TagGame extends Game {
return;
}
- THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole());
+ THashSet poles = room.getRoomSpecialTypes().getItemsOfType(this.getTagPole());
InteractionTagPole pole = this.taggers.get(tagger);
- room.giveEffect(tagged, this.getTaggedEffect(tagged), -1);
+ tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1);
if (poles.size() > this.taggers.size()) {
for (Map.Entry set : this.taggers.entrySet()) {
poles.remove(set.getValue());
}
- for (HabboItem item : poles) {
- tagged.getHabboInfo().getCurrentRoom().giveEffect(tagged, this.getTaggedEffect(tagged), -1);
+ for (RoomItem item : poles) {
+ tagged.getRoomUnit().giveEffect(this.getTaggedEffect(tagged), -1);
this.taggers.put(tagged, (InteractionTagPole) item);
}
} else {
if (tagger != null) {
- room.giveEffect(tagger, this.getEffect(tagger), -1);
+ tagger.getRoomUnit().giveEffect(this.getEffect(tagger), -1);
this.taggers.remove(tagger);
}
@@ -120,7 +120,7 @@ public abstract class TagGame extends Game {
}
if (pole != null) {
- pole.setExtradata("1");
+ pole.setExtraData("1");
room.updateItemState(pole);
Emulator.getThreading().run(new HabboItemNewState(pole, room, "0"), 1000);
}
@@ -130,39 +130,39 @@ public abstract class TagGame extends Game {
public synchronized boolean addHabbo(Habbo habbo, GameTeamColors teamColor) {
super.addHabbo(habbo, GameTeamColors.RED);
- RoomUnit roomUnit = habbo.getRoomUnit();
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
if (this.getTagPole() != null) {
- THashSet poles = habbo.getHabboInfo().getCurrentRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole());
+ THashSet poles = habbo.getRoomUnit().getRoom().getRoomSpecialTypes().getItemsOfType(this.getTagPole());
if (poles.size() > this.taggers.size()) {
for (Map.Entry set : this.taggers.entrySet()) {
poles.remove(set.getValue());
}
- TObjectHashIterator iterator = poles.iterator();
+ TObjectHashIterator iterator = poles.iterator();
if ((iterator.hasNext())) {
- HabboItem item = iterator.next();
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
- this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
+ RoomItem item = iterator.next();
+ if (roomHabbo.getEffectId() > 0)
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
+ habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
+ this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true));
this.taggers.put(habbo, (InteractionTagPole) item);
return true;
}
}
} else {
if (this.taggers.isEmpty()) {
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
- this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1, true));
+ if (roomHabbo.getEffectId() > 0)
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
+ habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
+ this.room.scheduledTasks.add(() -> habbo.getRoomUnit().giveEffect(this.getTaggedEffect(habbo), -1, true));
this.taggers.put(habbo, null);
return true;
}
}
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1, true);
+ if (roomHabbo.getEffectId() > 0)
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
+ habbo.getRoomUnit().giveEffect(this.getEffect(habbo), -1, true);
return true;
}
@@ -172,11 +172,11 @@ public abstract class TagGame extends Game {
super.removeHabbo(habbo);
this.taggers.remove(habbo);
- RoomUnit roomUnit = habbo.getRoomUnit();
- Room room = roomUnit.getRoom();
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
+ Room room = roomHabbo.getRoom();
if (room == null) return;
- HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY());
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
@@ -184,19 +184,19 @@ public abstract class TagGame extends Game {
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
+ } else if (roomHabbo.getPreviousEffectId() > 0) {
+ nextEffectF = roomHabbo.getPreviousEffectId();
+ nextEffectM = roomHabbo.getPreviousEffectId();
+ nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
+ habbo.getRoomUnit().giveEffect(nextEffectF, nextEffectDuration, true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
index 9cb2a072..0bf1d1d6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
@@ -3,10 +3,10 @@ package com.eu.habbo.habbohotel.games.wired;
import com.eu.habbo.habbohotel.games.*;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
public class WiredGame extends Game {
public GameState state = GameState.RUNNING;
@@ -31,21 +31,21 @@ public class WiredGame extends Game {
@Override
public boolean addHabbo(Habbo habbo, GameTeamColors teamColor) {
- RoomUnit roomUnit = habbo.getRoomUnit();
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- this.room.giveEffect(habbo, FreezeGame.effectId + teamColor.type, -1, true);
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
+ if (roomHabbo.getEffectId() > 0)
+ roomHabbo.setPreviousEffectId(roomHabbo.getEffectId(), roomHabbo.getPreviousEffectEndTimestamp());
+ roomHabbo.giveEffect(FreezeGame.effectId + teamColor.type, -1, true);
return super.addHabbo(habbo, teamColor);
}
@Override
public void removeHabbo(Habbo habbo) {
super.removeHabbo(habbo);
- RoomUnit roomUnit = habbo.getRoomUnit();
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
Room room = this.room;
if (room == null) return;
- HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY());
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomHabbo.getCurrentPosition().getX(), roomHabbo.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
@@ -53,19 +53,19 @@ public class WiredGame extends Game {
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
+ } else if (roomHabbo.getPreviousEffectId() > 0) {
+ nextEffectF = roomHabbo.getPreviousEffectId();
+ nextEffectM = roomHabbo.getPreviousEffectId();
+ nextEffectDuration = roomHabbo.getPreviousEffectEndTimestamp();
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
+ roomHabbo.giveEffect(nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
+ roomHabbo.giveEffect(nextEffectF, nextEffectDuration, true);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
index 06827a70..93217ee5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/GuildManager.java
@@ -152,10 +152,10 @@ public class GuildManager {
statement.execute();
}
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(guild.getRoomId());
if (room != null) {
- room.setGuildId(0);
+ room.getRoomInfo().setGuild(null);
}
} catch (SQLException e) {
log.error("Caught SQL exception", e);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java
index 788f92d8..57dd19c3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/IEventTriggers.java
@@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
public interface IEventTriggers {
void onClick(GameClient client, Room room, Object[] objects) throws Exception;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
index bfb3c6a7..8827829d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
@@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionMultiHeight;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.list.array.TIntArrayList;
@@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class Item implements ISerialize {
-
@Getter
private int id;
@Getter
@@ -33,7 +32,7 @@ public class Item implements ISerialize {
private boolean allowWalk;
private boolean allowSit;
private boolean allowLay;
- private boolean allowRecyle;
+ private boolean allowRecycle;
private boolean allowTrade;
private boolean allowMarketplace;
private boolean allowGift;
@@ -52,7 +51,6 @@ public class Item implements ISerialize {
private String customParams;
@Getter
private String clothingOnWalk;
-
@Getter
private ItemInteraction interactionType;
@Getter
@@ -66,15 +64,15 @@ public class Item implements ISerialize {
return item.getName().toLowerCase().startsWith("a0 pet");
}
- public static double getCurrentHeight(HabboItem item) {
+ public static double getCurrentHeight(RoomItem item) {
if (item instanceof InteractionMultiHeight && item.getBaseItem().getMultiHeights().length > 0) {
- if (item.getExtradata().isEmpty()) {
- item.setExtradata("0");
+ if (item.getExtraData().isEmpty()) {
+ item.setExtraData("0");
}
try {
- int index = Integer.parseInt(item.getExtradata()) % (item.getBaseItem().getMultiHeights().length);
- return item.getBaseItem().getMultiHeights()[(item.getExtradata().isEmpty() ? 0 : index)];
+ int index = Integer.parseInt(item.getExtraData()) % (item.getBaseItem().getMultiHeights().length);
+ return item.getBaseItem().getMultiHeights()[(item.getExtraData().isEmpty() ? 0 : index)];
} catch (NumberFormatException ignored) {
}
@@ -103,7 +101,7 @@ public class Item implements ISerialize {
this.allowWalk = set.getBoolean("allow_walk");
this.allowSit = set.getBoolean("allow_sit");
this.allowLay = set.getBoolean("allow_lay");
- this.allowRecyle = set.getBoolean("allow_recycle");
+ this.allowRecycle = set.getBoolean("allow_recycle");
this.allowTrade = set.getBoolean("allow_trade");
this.allowMarketplace = set.getBoolean("allow_marketplace_sell");
this.allowGift = set.getBoolean("allow_gift");
@@ -164,7 +162,7 @@ public class Item implements ISerialize {
}
public boolean allowRecyle() {
- return this.allowRecyle;
+ return this.allowRecycle;
}
public boolean allowTrade() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java
index fd32de85..2f830413 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemInteraction.java
@@ -1,6 +1,6 @@
package com.eu.habbo.habbohotel.items;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -9,5 +9,5 @@ public class ItemInteraction {
@Getter
private final String name;
@Getter
- private final Class extends HabboItem> type;
+ private final Class extends RoomItem> type;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
index f798e0fe..125a12d3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
@@ -51,8 +51,9 @@ import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent;
@@ -147,9 +148,9 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("hopper", InteractionHopper.class));
this.interactionsList.add(new ItemInteraction("costume_hopper", InteractionCostumeHopper.class));
this.interactionsList.add(new ItemInteraction("effect_gate", InteractionEffectGate.class));
- this.interactionsList.add(new ItemInteraction("club_hopper", InteractionHabboClubHopper.class));
- this.interactionsList.add(new ItemInteraction("club_gate", InteractionHabboClubGate.class));
- this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionHabboClubTeleportTile.class));
+ this.interactionsList.add(new ItemInteraction("club_hopper", InteractionRoomClubHopper.class));
+ this.interactionsList.add(new ItemInteraction("club_gate", InteractionRoomClubGate.class));
+ this.interactionsList.add(new ItemInteraction("club_teleporttile", InteractionRoomClubTeleportTile.class));
this.interactionsList.add(new ItemInteraction("onewaygate", InteractionOneWayGate.class));
this.interactionsList.add(new ItemInteraction("love_lock", InteractionLoveLock.class));
this.interactionsList.add(new ItemInteraction("clothing", InteractionClothing.class));
@@ -198,10 +199,10 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerHabboWalkOnFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerHabboWalkOffFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerHabboEntersRoom.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerHabboSaysKeyword.class));
+ this.interactionsList.add(new ItemInteraction("wf_trg_walks_on_furni", WiredTriggerRoomWalkOnFurni.class));
+ this.interactionsList.add(new ItemInteraction("wf_trg_walks_off_furni", WiredTriggerRoomWalkOffFurni.class));
+ this.interactionsList.add(new ItemInteraction("wf_trg_enter_room", WiredTriggerRoomEntersRoom.class));
+ this.interactionsList.add(new ItemInteraction("wf_trg_says_something", WiredTriggerRoomSaysKeyword.class));
this.interactionsList.add(new ItemInteraction("wf_trg_periodically", WiredTriggerRepeater.class));
this.interactionsList.add(new ItemInteraction("wf_trg_period_long", WiredTriggerRepeaterLong.class));
this.interactionsList.add(new ItemInteraction("wf_trg_state_changed", WiredTriggerFurniStateToggled.class));
@@ -211,7 +212,7 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_trg_game_starts", WiredTriggerGameStarts.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_ends", WiredTriggerGameEnds.class));
this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_stf", WiredTriggerBotReachedFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedRoom.class));
this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class));
@@ -234,43 +235,43 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("wf_act_move_furni_to", WiredEffectMoveFurniTo.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_reward", WiredEffectGiveReward.class));
this.interactionsList.add(new ItemInteraction("wf_act_call_stacks", WiredEffectTriggerStacks.class));
- this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickHabbo.class));
- this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_act_kick_user", WiredEffectKickRoom.class));
+ this.interactionsList.add(new ItemInteraction("wf_act_mute_triggerer", WiredEffectMuteRoom.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_teleport", WiredEffectBotTeleport.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_move", WiredEffectBotWalkToFurni.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_talk", WiredEffectBotTalk.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_give_handitem", WiredEffectBotGiveHandItem.class));
- this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_act_bot_follow_avatar", WiredEffectBotFollowRoom.class));
this.interactionsList.add(new ItemInteraction("wf_act_bot_clothes", WiredEffectBotClothes.class));
- this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_act_bot_talk_to_avatar", WiredEffectBotTalkToRoom.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_respect", WiredEffectGiveRespect.class));
this.interactionsList.add(new ItemInteraction("wf_act_alert", WiredEffectAlert.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_furnis_hv_avtrs", WiredConditionFurniHaveRoom.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_stuff_is", WiredConditionFurniTypeMatch.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_group", WiredConditionGroupMember.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionHabboCount.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionHabboHasEffect.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionHabboWearsBadge.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_user_count_in", WiredConditionRoomCount.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_effect", WiredConditionRoomHasEffect.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_wearing_badge", WiredConditionRoomWearsBadge.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_time_less_than", WiredConditionLessTimeElapsed.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_match_snapshot", WiredConditionMatchStatePosition.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_time_more_than", WiredConditionMoreTimeElapsed.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_furni_on", WiredConditionNotFurniHaveFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveHabbo.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_not_hv_avtrs", WiredConditionNotFurniHaveRoom.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_stuff_is", WiredConditionNotFurniTypeMatch.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotHabboCount.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotHabboHasEffect.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotHabboWearsBadge.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_not_user_count", WiredConditionNotRoomCount.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_fx", WiredConditionNotRoomHasEffect.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_not_wearing_b", WiredConditionNotRoomWearsBadge.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_group", WiredConditionNotInGroup.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_in_team", WiredConditionNotInTeam.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_match_snap", WiredConditionNotMatchStatePosition.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_not_trggrer_on", WiredConditionNotTriggerOnFurni.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_actor_in_team", WiredConditionTeamMember.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_trggrer_on_frn", WiredConditionTriggerOnFurni.class));
- this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionHabboHasHandItem.class));
+ this.interactionsList.add(new ItemInteraction("wf_cnd_has_handitem", WiredConditionRoomHasHandItem.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_date_rng_active", WiredConditionDateRangeActive.class));
@@ -363,7 +364,7 @@ public class ItemManager {
}
- public ItemInteraction getItemInteraction(Class extends HabboItem> type) {
+ public ItemInteraction getItemInteraction(Class extends RoomItem> type) {
for (ItemInteraction interaction : this.interactionsList) {
if (interaction.getType() == type)
return interaction;
@@ -477,7 +478,7 @@ public class ItemManager {
return null;
}
- public HabboItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) {
+ public RoomItem createItem(int habboId, Item item, int limitedStack, int limitedSells, String extraData) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data, limited_data) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, habboId);
statement.setInt(2, item.getId());
@@ -487,14 +488,15 @@ public class ItemManager {
try (ResultSet set = statement.getGeneratedKeys()) {
if (set.next()) {
- Class extends HabboItem> itemClass = item.getInteractionType().getType();
+ Class extends RoomItem> itemClass = item.getInteractionType().getType();
+ HabboInfo userInfo = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(habboId);
if (itemClass != null) {
try {
- return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells);
+ return itemClass.getDeclaredConstructor(int.class, HabboInfo.class, Item.class, String.class, int.class, int.class).newInstance(set.getInt(1), userInfo, item, extraData, limitedStack, limitedSells);
} catch (Exception e) {
log.error("Caught exception", e);
- return new InteractionDefault(set.getInt(1), habboId, item, extraData, limitedStack, limitedSells);
+ return new InteractionDefault(set.getInt(1), userInfo, item, extraData, limitedStack, limitedSells);
}
}
}
@@ -537,7 +539,7 @@ public class ItemManager {
return new ArrayList<>(this.newuserGifts.values());
}
- public void deleteItem(HabboItem item) {
+ public void deleteItem(RoomItem item) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM items WHERE id = ?")) {
statement.setInt(1, item.getId());
statement.execute();
@@ -546,10 +548,10 @@ public class ItemManager {
}
}
- public HabboItem handleRecycle(Habbo habbo, String itemId) {
+ public RoomItem handleRecycle(Habbo habbo, String itemId) {
String extradata = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR);
- HabboItem item = null;
+ RoomItem item = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items (user_id, item_id, extra_data) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, habbo.getHabboInfo().getId());
statement.setInt(2, Emulator.getGameEnvironment().getCatalogManager().ecotronItem.getId());
@@ -562,7 +564,7 @@ public class ItemManager {
preparedStatement.setInt(1, set.getInt(1));
preparedStatement.setInt(2, Integer.parseInt(itemId));
preparedStatement.addBatch();
- item = new InteractionDefault(set.getInt(1), habbo.getHabboInfo().getId(), Emulator.getGameEnvironment().getCatalogManager().ecotronItem, extradata, 0, 0);
+ item = new InteractionDefault(set.getInt(1), habbo.getHabboInfo(), Emulator.getGameEnvironment().getCatalogManager().ecotronItem, extradata, 0, 0);
}
preparedStatement.executeBatch();
@@ -575,9 +577,9 @@ public class ItemManager {
return item;
}
- public HabboItem handleOpenRecycleBox(Habbo habbo, HabboItem box) {
+ public RoomItem handleOpenRecycleBox(Habbo habbo, RoomItem box) {
Emulator.getThreading().run(new QueryDeleteHabboItem(box.getId()));
- HabboItem item = null;
+ RoomItem item = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_presents WHERE item_id = ? LIMIT 1")) {
statement.setInt(1, box.getId());
try (ResultSet rewardSet = statement.executeQuery()) {
@@ -627,7 +629,7 @@ public class ItemManager {
}
}
- public void insertHopper(HabboItem hopper) {
+ public void insertHopper(RoomItem hopper) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO items_hoppers VALUES (?, ?)")) {
statement.setInt(1, hopper.getId());
statement.setInt(2, hopper.getBaseItem().getId());
@@ -637,7 +639,7 @@ public class ItemManager {
}
}
- public int[] getTargetTeleportRoomId(HabboItem item) {
+ public int[] getTargetTeleportRoomId(RoomItem item) {
int[] a = new int[]{};
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items.id, items.room_id FROM items_teleports INNER JOIN items ON items_teleports.teleport_one_id = items.id OR items_teleports.teleport_two_id = items.id WHERE items.id != ? AND items.room_id > 0 LIMIT 1")) {
@@ -654,8 +656,8 @@ public class ItemManager {
return a;
}
- public HabboItem loadHabboItem(int itemId) {
- HabboItem item = null;
+ public RoomItem loadHabboItem(int itemId) {
+ RoomItem item = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) {
statement.setInt(1, itemId);
try (ResultSet set = statement.executeQuery()) {
@@ -672,20 +674,26 @@ public class ItemManager {
return item;
}
- public HabboItem loadHabboItem(ResultSet set) throws SQLException {
+ public RoomItem loadHabboItem(ResultSet set) throws SQLException {
Item baseItem = this.getItem(set.getInt("item_id"));
if (baseItem == null)
return null;
- Class extends HabboItem> itemClass = baseItem.getInteractionType().getType();
+ Class extends RoomItem> itemClass = baseItem.getInteractionType().getType();
if (itemClass != null) {
try {
- Constructor extends HabboItem> c = itemClass.getConstructor(ResultSet.class, Item.class);
+ Constructor extends RoomItem> c = itemClass.getConstructor(ResultSet.class, Item.class);
c.setAccessible(true);
- return (HabboItem) c.newInstance(set, baseItem);
+ RoomItem item = c.newInstance(set, baseItem);
+
+ if (item instanceof InteractionWired interactionWired) {
+ interactionWired.loadWiredSettings(set);
+ }
+
+ return item;
} catch (Exception e) {
log.error("Caught exception", e);
}
@@ -694,7 +702,7 @@ public class ItemManager {
return null;
}
- public HabboItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) {
+ public RoomItem createGift(String username, Item item, String extraData, int limitedStack, int limitedSells) {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username);
int userId = 0;
@@ -722,7 +730,7 @@ public class ItemManager {
return null;
}
- public HabboItem createGift(int userId, Item item, String extraData, int limitedStack, int limitedSells) {
+ public RoomItem createGift(int userId, Item item, String extraData, int limitedStack, int limitedSells) {
if (userId == 0)
return null;
@@ -731,7 +739,7 @@ public class ItemManager {
extraData = extraData.substring(0, 1000);
}
- HabboItem gift = this.createItem(userId, item, limitedStack, limitedSells, extraData);
+ RoomItem gift = this.createItem(userId, item, limitedStack, limitedSells, extraData);
if (gift != null) {
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java
index eda6da13..6420116a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/NewUserGift.java
@@ -2,7 +2,7 @@ package com.eu.habbo.habbohotel.items;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import lombok.Getter;
@@ -52,7 +52,7 @@ public class NewUserGift implements ISerialize {
Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getKey());
if (item != null) {
- HabboItem createdItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
+ RoomItem createdItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
if (createdItem != null) {
habbo.addFurniture(createdItem);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
index 890738e6..9239c6a4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBackgroundToner.java
@@ -5,29 +5,30 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.BackgroundAnimation;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionBackgroundToner extends HabboItem {
+public class InteractionBackgroundToner extends RoomItem {
public InteractionBackgroundToner(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionBackgroundToner(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionBackgroundToner(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt(5 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(4);
- if (this.getExtradata().split(":").length == 4) {
- String[] colorData = this.getExtradata().split(":");
+ if (this.getExtraData().split(":").length == 4) {
+ String[] colorData = this.getExtraData().split(":");
serverMessage.appendInt(Integer.parseInt(colorData[0]));
serverMessage.appendInt(Integer.parseInt(colorData[1]));
serverMessage.appendInt(Integer.parseInt(colorData[2]));
@@ -37,8 +38,8 @@ public class InteractionBackgroundToner extends HabboItem {
serverMessage.appendInt(126);
serverMessage.appendInt(126);
serverMessage.appendInt(126);
- this.setExtradata("0:126:126:126");
- this.needsUpdate(true);
+ this.setExtraData("0:126:126:126");
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
}
@@ -61,31 +62,31 @@ public class InteractionBackgroundToner extends HabboItem {
if(client != null)
{
- if (!client.getHabbo().getRoomUnit().getRoom().hasRights(client.getHabbo())) {
+ if (!client.getHabbo().getRoomUnit().getRoom().getRoomRightsManager().hasRights(client.getHabbo())) {
ScripterManager.scripterDetected(
client,
Emulator.getTexts().getValue("scripter.warning.item.bgtoner.permission").replace("%username%", client.getHabbo().getHabboInfo().getUsername())
- .replace("%room%", room.getName())
- .replace("%owner%", room.getOwnerName())
+ .replace("%room%", room.getRoomInfo().getName())
+ .replace("%owner%", room.getRoomInfo().getOwnerInfo().getUsername())
);
return;
}
- if (client.getHabbo().getRoomUnit().isCmdSit() && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
+ if (client.getHabbo().getRoomUnit().isCmdSitEnabled() && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
new BackgroundAnimation(this, room).run();
return;
}
}
- if (this.getExtradata().split(":").length == 4) {
- String[] data = this.getExtradata().split(":");
- this.setExtradata((data[0].equals("0") ? "1" : "0") + ":" + data[1] + ":" + data[2] + ":" + data[3]);
+ if (this.getExtraData().split(":").length == 4) {
+ String[] data = this.getExtraData().split(":");
+ this.setExtraData((data[0].equals("0") ? "1" : "0") + ":" + data[1] + ":" + data[2] + ":" + data[3]);
room.updateItem(this);
} else {
- this.setExtradata("0:126:126:126");
+ this.setExtraData("0:126:126:126");
room.updateItem(this);
}
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java
index c34be7e5..d62cf21c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBadgeDisplay.java
@@ -3,20 +3,21 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionBadgeDisplay extends HabboItem {
+public class InteractionBadgeDisplay extends RoomItem {
public InteractionBadgeDisplay(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionBadgeDisplay(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionBadgeDisplay(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -24,13 +25,13 @@ public class InteractionBadgeDisplay extends HabboItem {
serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(4);
serverMessage.appendString("0");
- String[] data = this.getExtradata().split((char) 9 + "");
+ String[] data = this.getExtraData().split((char) 9 + "");
if (data.length == 3) {
serverMessage.appendString(data[2]);
serverMessage.appendString(data[1]);
serverMessage.appendString(data[0]);
} else {
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
serverMessage.appendString("Unknown User");
serverMessage.appendString("Unknown Date");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java
index f669479a..c8a6493a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBlackHole.java
@@ -6,6 +6,7 @@ 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.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -15,8 +16,8 @@ public class InteractionBlackHole extends InteractionGate {
super(set, baseItem);
}
- public InteractionBlackHole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionBlackHole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -24,10 +25,10 @@ public class InteractionBlackHole extends InteractionGate {
Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount");
int holesCountProgress = 0;
- Habbo owner = room.getHabbo(this.getUserId());
+ Habbo owner = room.getRoomUnitManager().getRoomHabboById(this.getOwnerInfo().getId());
if (owner == null) {
- holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), holeCountAchievement);
+ holesCountProgress = AchievementManager.getAchievementProgressForHabbo(this.getOwnerInfo().getId(), holeCountAchievement);
} else {
holesCountProgress = owner.getHabboStats().getAchievementProgress(holeCountAchievement);
}
@@ -37,7 +38,7 @@ public class InteractionBlackHole extends InteractionGate {
if (owner != null) {
AchievementManager.progressAchievement(owner, holeCountAchievement, holeDifference);
} else {
- AchievementManager.progressAchievement(this.getUserId(), holeCountAchievement, holeDifference);
+ AchievementManager.progressAchievement(this.getOwnerInfo().getId(), holeCountAchievement, holeDifference);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
index f6877649..dff6cbd5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
@@ -6,10 +6,9 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import gnu.trove.TCollections;
@@ -39,8 +38,8 @@ public class InteractionBuildArea extends InteractionCustomValues {
tiles = new THashSet<>();
}
- public InteractionBuildArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
+ public InteractionBuildArea(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues);
defaultValues.put("tilesLeft", "0");
defaultValues.put("tilesRight", "0");
defaultValues.put("tilesFront", "0");
@@ -69,7 +68,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
- builderInfo = HabboManager.getOfflineHabboInfo(builderName);
+ builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
@@ -78,10 +77,10 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (!canBuild.isEmpty()) {
for (RoomTile tile : this.tiles) {
- THashSet tileItems = room.getItemsAt(tile);
- for (HabboItem tileItem : tileItems) {
- if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
- room.pickUpItem(tileItem, null);
+ THashSet tileItems = room.getRoomItemManager().getItemsAt(tile);
+ for (RoomItem tileItem : tileItems) {
+ if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) {
+ room.getRoomItemManager().pickUpItem(tileItem, null);
}
}
}
@@ -103,7 +102,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
- builderInfo = HabboManager.getOfflineHabboInfo(builderName);
+ builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
@@ -127,11 +126,11 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (!canBuild.isEmpty()) {
for (RoomTile tile : this.tiles) {
- THashSet tileItems = room.getItemsAt(tile);
+ THashSet tileItems = room.getRoomItemManager().getItemsAt(tile);
if (newTiles.contains(tile)) continue;
- for (HabboItem tileItem : tileItems) {
- if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
- room.pickUpItem(tileItem, null);
+ for (RoomItem tileItem : tileItems) {
+ if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) {
+ room.getRoomItemManager().pickUpItem(tileItem, null);
}
}
}
@@ -140,7 +139,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
}
public boolean inSquare(RoomTile location) {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = this.getRoom();
if (room != null && this.tiles.size() == 0) {
regenAffectedTiles(room);
@@ -151,10 +150,10 @@ public class InteractionBuildArea extends InteractionCustomValues {
}
private void regenAffectedTiles(Room room) {
- int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack")));
- int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight")));
- int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront")));
- int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft")));
+ int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(this.values.get("tilesBack")));
+ int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(this.values.get("tilesRight")));
+ int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(this.values.get("tilesFront")));
+ int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(this.values.get("tilesLeft")));
this.tiles.clear();
@@ -179,7 +178,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
- builderInfo = HabboManager.getOfflineHabboInfo(builderName);
+ builderInfo = Emulator.getGameEnvironment().getHabboManager().getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
@@ -188,10 +187,10 @@ public class InteractionBuildArea extends InteractionCustomValues {
THashSet oldTiles = new THashSet<>();
- int minX = Math.max(0, this.getX() - Integer.parseInt(oldValues.get("tilesBack")));
- int minY = Math.max(0, this.getY() - Integer.parseInt(oldValues.get("tilesRight")));
- int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(oldValues.get("tilesFront")));
- int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(oldValues.get("tilesLeft")));
+ int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(oldValues.get("tilesBack")));
+ int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(oldValues.get("tilesRight")));
+ int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(oldValues.get("tilesFront")));
+ int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(oldValues.get("tilesLeft")));
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
@@ -202,10 +201,10 @@ public class InteractionBuildArea extends InteractionCustomValues {
}
if (!canBuild.isEmpty()) {
for (RoomTile tile : oldTiles) {
- THashSet tileItems = room.getItemsAt(tile);
- for (HabboItem tileItem : tileItems) {
- if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
- room.pickUpItem(tileItem, null);
+ THashSet tileItems = room.getRoomItemManager().getItemsAt(tile);
+ for (RoomItem tileItem : tileItems) {
+ if (canBuild.contains(tileItem.getOwnerInfo().getId()) && tileItem != this) {
+ room.getRoomItemManager().pickUpItem(tileItem, null);
}
}
}
@@ -217,21 +216,21 @@ public class InteractionBuildArea extends InteractionCustomValues {
if (effectItem != null) {
TIntObjectMap ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
ownerNames.put(-1, "System");
- THashSet items = new THashSet<>();
+ THashSet items = new THashSet<>();
int id = 0;
for (RoomTile tile : this.tiles) {
id--;
- HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0);
- item.setX(tile.getX());
- item.setY(tile.getY());
- item.setZ(tile.relativeHeight());
+ RoomItem item = new InteractionDefault(id, null, effectItem, "1", 0, 0);
+
+ item.setCurrentPosition(tile);
+ item.setCurrentZ(tile.relativeHeight());
items.add(item);
}
client.sendResponse(new ObjectsMessageComposer(ownerNames, items));
Emulator.getThreading().run(() -> {
- for (HabboItem item : items) {
+ for (RoomItem item : items) {
client.sendResponse(new RemoveFloorItemComposer(item, true));
}
}, 3000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java
index b1223794..114871a0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCannon.java
@@ -5,8 +5,9 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.CannonKickAction;
import com.eu.habbo.threading.runnables.CannonResetCooldownAction;
@@ -15,23 +16,23 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-public class InteractionCannon extends HabboItem {
+public class InteractionCannon extends RoomItem {
public boolean cooldown = false;
public InteractionCannon(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionCannon(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionCannon(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -55,22 +56,22 @@ public class InteractionCannon extends HabboItem {
if (room == null)
return;
- RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
RoomTile fuseTile = this.getRotation() >= 4 ? tile : room.getLayout().getTileInFront(tile, ((this.getRotation() % 2) + 2) % 8);
List tiles = room.getLayout().getTilesAround(fuseTile);
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? -1 : 0)) % 8));
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + (this.getRotation() >= 4 ? 5 : 4)) % 8));
- if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentLocation())) && client.getHabbo().getRoomUnit().canWalk()) && !this.cooldown) {
+ if ((client == null || (tiles.contains(client.getHabbo().getRoomUnit().getCurrentPosition())) && client.getHabbo().getRoomUnit().isCanWalk()) && !this.cooldown) {
if (client != null) {
client.getHabbo().getRoomUnit().setCanWalk(false);
- client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation());
+ client.getHabbo().getRoomUnit().walkTo(client.getHabbo().getRoomUnit().getCurrentPosition());
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
- client.getHabbo().getRoomUnit().statusUpdate(true);
+ client.getHabbo().getRoomUnit().setStatusUpdateNeeded(true);
}
this.cooldown = true;
- this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
+ this.setExtraData(this.getExtraData().equals("1") ? "0" : "1");
room.updateItemState(this);
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
@@ -94,7 +95,7 @@ public class InteractionCannon extends HabboItem {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java
index 9bcd0794..d34bc24c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionClothing.java
@@ -2,20 +2,21 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionClothing extends HabboItem {
+public class InteractionClothing extends RoomItem {
public InteractionClothing(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionClothing(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionClothing(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
index 9d181a92..c01803cc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorPlate.java
@@ -2,7 +2,8 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import lombok.extern.slf4j.Slf4j;
import java.sql.ResultSet;
@@ -15,8 +16,8 @@ public class InteractionColorPlate extends InteractionDefault {
super(set, baseItem);
}
- public InteractionColorPlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionColorPlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -36,12 +37,12 @@ public class InteractionColorPlate extends InteractionDefault {
private void change(Room room, int amount) {
int state = 0;
- if (this.getExtradata() == null || this.getExtradata().isEmpty()) {
- this.setExtradata("0");
+ if (this.getExtraData() == null || this.getExtraData().isEmpty()) {
+ this.setExtraData("0");
}
try {
- state = Integer.parseInt(this.getExtradata());
+ state = Integer.parseInt(this.getExtraData());
} catch (Exception e) {
log.error("Caught exception", e);
}
@@ -55,8 +56,8 @@ public class InteractionColorPlate extends InteractionDefault {
state = 0;
}
- this.setExtradata(state + "");
- this.needsUpdate(true);
+ this.setExtraData(state + "");
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java
index 2f57bec8..f7c817ac 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionColorWheel.java
@@ -4,8 +4,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.ItemUpdateMessageComposer;
import com.eu.habbo.threading.runnables.RandomDiceNumber;
@@ -13,21 +14,21 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionColorWheel extends HabboItem {
+public class InteractionColorWheel extends RoomItem {
private Runnable rollTaks;
public InteractionColorWheel(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionColorWheel(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionColorWheel(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -46,11 +47,11 @@ public class InteractionColorWheel extends HabboItem {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (!room.hasRights(client.getHabbo()))
+ if (!room.getRoomRightsManager().hasRights(client.getHabbo()))
return;
- if (this.rollTaks == null && !this.getExtradata().equalsIgnoreCase("-1")) {
- this.setExtradata("-1");
+ if (this.rollTaks == null && !this.getExtraData().equalsIgnoreCase("-1")) {
+ this.setExtraData("-1");
room.sendComposer(new ItemUpdateMessageComposer(this).compose());
Emulator.getThreading().run(this);
Emulator.getThreading().run(new RandomDiceNumber(this, room, this.getBaseItem().getStateCount()), 3000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java
index 96e83953..55ed6ed2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCostumeHopper.java
@@ -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.users.HabboInfo;
import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer;
import java.sql.ResultSet;
@@ -13,8 +14,8 @@ public class InteractionCostumeHopper extends InteractionHopper {
super(set, baseItem);
}
- public InteractionCostumeHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionCostumeHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java
index 2ccdb52e..7ebe0137 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackable.java
@@ -6,10 +6,11 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.CrackableReward;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.CrackableExplode;
@@ -18,7 +19,7 @@ import com.eu.habbo.util.pathfinding.Rotation;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionCrackable extends HabboItem {
+public class InteractionCrackable extends RoomItem {
private final Object lock = new Object();
public boolean cracked = false;
protected int ticks = 0;
@@ -27,19 +28,19 @@ public class InteractionCrackable extends HabboItem {
super(set, baseItem);
}
- public InteractionCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionCrackable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
serverMessage.appendInt(7 + (this.isLimited() ? 256 : 0));
- serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtradata()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + "");
- serverMessage.appendInt(Integer.parseInt(this.getExtradata()));
+ serverMessage.appendString(Emulator.getGameEnvironment().getItemManager().calculateCrackState(Integer.parseInt(this.getExtraData()), Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()), this.getBaseItem()) + "");
+ serverMessage.appendInt(Integer.parseInt(this.getExtraData()));
serverMessage.appendInt(Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()));
super.serializeExtradata(serverMessage);
@@ -63,19 +64,19 @@ public class InteractionCrackable extends HabboItem {
super.onClick(client, room, objects);
synchronized (this.lock) {
- if (this.getRoomId() == 0)
+ if (this.getRoom() == null)
return;
if (this.cracked)
return;
- if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5) {
- client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())));
+ if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentPosition().distance(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) > 1.5) {
+ client.getHabbo().getRoomUnit().walkTo(room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getCurrentPosition().getX(), client.getHabbo().getRoomUnit().getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY())));
return;
}
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
if (this.getBaseItem().getEffectF() > 0)
if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() == client.getHabbo().getRoomUnit().getEffectId())
@@ -92,7 +93,7 @@ public class InteractionCrackable extends HabboItem {
public void onTick(Habbo habbo, Room room) {
if (this.cracked) return;
- if (this.allowAnyone() || this.getUserId() == habbo.getHabboInfo().getId()) {
+ if (this.allowAnyone() || this.getOwnerInfo().getId() == habbo.getHabboInfo().getId()) {
CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId());
if (rewardData != null) {
@@ -102,11 +103,11 @@ public class InteractionCrackable extends HabboItem {
if(this.ticks < 1)
{
// If there are no ticks (for example because the room has been reloaded), check the current extradata of the item and update the ticks.
- this.ticks = Integer.parseInt(this.getExtradata());
+ this.ticks = Integer.parseInt(this.getExtraData());
}
this.ticks++;
- this.setExtradata("" + (this.ticks));
- this.needsUpdate(true);
+ this.setExtraData("" + (this.ticks));
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
if (!rewardData.getAchievementTick().isEmpty()) {
@@ -114,7 +115,7 @@ public class InteractionCrackable extends HabboItem {
}
if (!this.cracked && this.ticks == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId())) {
this.cracked = true;
- Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getX(), this.getY()), 1500);
+ Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getCurrentPosition()), 1500);
if (!rewardData.getAchievementCracked().isEmpty()) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.getAchievementCracked()));
@@ -168,7 +169,7 @@ public class InteractionCrackable extends HabboItem {
public void reset(Room room) {
this.cracked = false;
this.ticks = 0;
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java
index 60244939..af4de4b3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCrackableMaster.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,8 +11,8 @@ public class InteractionCrackableMaster extends InteractionCrackable {
super(set, baseItem);
}
- public InteractionCrackableMaster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionCrackableMaster(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java
index 8f39af73..bb996240 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionCustomValues.java
@@ -3,8 +3,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.map.hash.THashMap;
@@ -12,7 +13,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
-public abstract class InteractionCustomValues extends HabboItem {
+public abstract class InteractionCustomValues extends RoomItem {
public final THashMap values = new THashMap<>();
public InteractionCustomValues(ResultSet set, Item baseItem, THashMap defaultValues) throws SQLException {
@@ -29,8 +30,8 @@ public abstract class InteractionCustomValues extends HabboItem {
}
}
- public InteractionCustomValues(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionCustomValues(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, THashMap defaultValues) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.values.putAll(defaultValues);
}
@@ -52,7 +53,7 @@ public abstract class InteractionCustomValues extends HabboItem {
@Override
public void run() {
- this.setExtradata(this.toExtraData());
+ this.setExtraData(this.toExtraData());
super.run();
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
index 255054ba..c3fcd2a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
@@ -1,12 +1,14 @@
package com.eu.habbo.habbohotel.items.interactions;
-import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.*;
+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.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import lombok.extern.slf4j.Slf4j;
@@ -15,20 +17,19 @@ import java.sql.ResultSet;
import java.sql.SQLException;
@Slf4j
-public class InteractionDefault extends HabboItem {
-
+public class InteractionDefault extends RoomItem {
public InteractionDefault(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionDefault(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionDefault(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -47,11 +48,16 @@ public class InteractionDefault extends HabboItem {
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
super.onMove(room, oldLocation, newLocation);
- if (room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) {
- for (RoomUnit unit : room.getRoomUnits()) {
- if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem()))
+ //Check if there a no rollers
+ if (room.getRoomItemManager().getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) {
+ for (RoomUnit unit : room.getRoomUnitManager().getCurrentRoomUnits().values()) {
+ if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) {
continue; // If the unit was previously on the furni...
- if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore...
+ }
+
+ if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) {
+ continue; // but is not anymore...
+ }
try {
this.onWalkOff(unit, room, new Object[]{oldLocation, newLocation}); // the unit walked off!
@@ -69,20 +75,20 @@ public class InteractionDefault extends HabboItem {
if (objects != null && objects.length > 0) {
if (objects[0] instanceof Integer) {
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
if (this.getBaseItem().getStateCount() > 0) {
int currentState = 0;
try {
- currentState = Integer.parseInt(this.getExtradata());
+ currentState = Integer.parseInt(this.getExtraData());
} catch (NumberFormatException e) {
- log.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
+ log.error("Incorrect extradata (" + this.getExtraData() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
}
- this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount());
- this.needsUpdate(true);
+ this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount());
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}
@@ -99,114 +105,21 @@ public class InteractionDefault extends HabboItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
-
- if (roomUnit == null || (this.getBaseItem().getEffectF() == 0 && this.getBaseItem().getEffectM() == 0)) return;
- if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo == null) return;
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
- return;
- }
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
- }
- } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) {
- Bot bot = room.getBot(roomUnit);
-
- if (bot == null) return;
-
- if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM()) {
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1);
- return;
- }
-
- if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF()) {
- if (roomUnit.getEffectId() > 0)
- roomUnit.setPreviousEffectId(roomUnit.getEffectId(), roomUnit.getPreviousEffectEndTimestamp());
- room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1);
- }
- }
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
-
- if (roomUnit != null) {
- if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
- int nextEffectM = 0;
- int nextEffectF = 0;
- int nextEffectDuration = -1;
-
- if (objects != null && objects.length == 2) {
- if (objects[0] instanceof RoomTile goalTile && objects[1] instanceof RoomTile) {
- HabboItem topItem = room.getTopItemAt(goalTile.getX(), goalTile.getY(), (objects[0] != objects[1]) ? this : null);
-
- if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF())) {
- return;
- }
-
- if (topItem != null) {
- nextEffectM = topItem.getBaseItem().getEffectM();
- nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
- }
- }
- }
-
- if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration);
- return;
- }
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration);
- }
- }
- } else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT)) {
- Bot bot = room.getBot(roomUnit);
-
- if (bot != null) {
- if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
- room.giveEffect(roomUnit, nextEffectM, nextEffectDuration);
- return;
- }
-
- if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
- room.giveEffect(roomUnit, nextEffectF, nextEffectDuration);
- }
- }
- }
- }
- }
}
public boolean canToggle(Habbo habbo, Room room) {
- if (room.hasRights(habbo)) return true;
+ if (room.getRoomRightsManager().hasRights(habbo)) return true;
if (!habbo.getHabboStats().isRentingSpace()) return false;
- HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().getRentedItemId());
+ RoomItem rentSpace = room.getRoomItemManager().getRoomItemById(habbo.getHabboStats().getRentedItemId());
- return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
+ return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getCurrentPosition().getX(), rentSpace.getCurrentPosition().getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
index 896cf046..8f983a3d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
@@ -5,8 +5,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent;
import com.eu.habbo.threading.runnables.RandomDiceNumber;
@@ -14,9 +15,9 @@ import com.eu.habbo.threading.runnables.RandomDiceNumber;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionDice extends HabboItem {
- public InteractionDice(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+public class InteractionDice extends RoomItem {
+ public InteractionDice(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public InteractionDice(ResultSet set, Item baseItem) throws SQLException {
@@ -26,7 +27,7 @@ public class InteractionDice extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -46,14 +47,14 @@ public class InteractionDice extends HabboItem {
super.onClick(client, room, objects);
if (client != null) {
- if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) {
- if (!this.getExtradata().equalsIgnoreCase("-1")) {
+ if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) {
+ if (!this.getExtraData().equalsIgnoreCase("-1")) {
FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1));
if (event.isCancelled())
return;
- this.setExtradata("-1");
+ this.setExtraData("-1");
room.updateItemState(this);
Emulator.getThreading().run(this);
@@ -74,7 +75,7 @@ public class InteractionDice extends HabboItem {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java
index eb0e8b19..e88ff3fd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGate.java
@@ -5,7 +5,9 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet;
@@ -28,12 +30,12 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi
public InteractionEffectGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionEffectGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionEffectGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -43,17 +45,16 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- if (roomUnit == null || room == null)
+ if (roomUnit == null || room == null || !(roomUnit instanceof RoomHabbo roomHabbo))
return false;
String customparams = this.getBaseItem().getCustomParams().trim();
if (!customparams.isEmpty()) {
- return Arrays.asList(customparams.split(";"))
- .contains(String.valueOf(roomUnit.getEffectId()));
+ return Arrays.asList(customparams.split(";")).contains(String.valueOf(roomHabbo.getEffectId()));
}
- return defaultAllowedEnables.contains(roomUnit.getEffectId());
+ return defaultAllowedEnables.contains(roomHabbo.getEffectId());
}
@Override
@@ -61,7 +62,7 @@ public class InteractionEffectGate extends InteractionDefault implements Conditi
super.onWalkOn(roomUnit, room, objects);
if (this.canWalkOn(roomUnit, room, objects)) {
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
index 4d8d011a..75781047 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectGiver.java
@@ -5,8 +5,10 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,38 +16,41 @@ import java.sql.SQLException;
public class InteractionEffectGiver extends InteractionDefault {
public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionEffectGiver(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) ||
- (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) {
+ if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) ||
+ (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY())) {
this.handle(room, client.getHabbo().getRoomUnit());
}
}
protected void handle(Room room, RoomUnit roomUnit) {
- if (this.getExtradata().isEmpty()) this.setExtradata("0");
+ if (this.getExtraData().isEmpty()) this.setExtraData("0");
- if (!this.getExtradata().equals("0")) return;
+ if (!this.getExtraData().equals("0")) return;
- HabboItem instance = this;
- room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem(), -1);
+ RoomItem instance = this;
+
+ if(roomUnit instanceof RoomAvatar roomAvatar) {
+ roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), -1);
+ }
if (this.getBaseItem().getStateCount() > 1) {
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItem(this);
Emulator.getThreading().run(() -> {
- InteractionEffectGiver.this.setExtradata("0");
+ InteractionEffectGiver.this.setExtraData("0");
room.updateItem(instance);
}, 500);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java
index ac10dcc7..a89643ef 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectTile.java
@@ -4,10 +4,12 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@@ -19,8 +21,8 @@ public class InteractionEffectTile extends InteractionPressurePlate {
super(set, baseItem);
}
- public InteractionEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionEffectTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -51,14 +53,14 @@ public class InteractionEffectTile extends InteractionPressurePlate {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (roomUnit.getRoomUnitType() == RoomUnitType.USER) {
- Habbo habbo = room.getHabbo(roomUnit);
+ if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
this.giveEffect(room, roomUnit, habbo.getHabboInfo().getGender());
}
} else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT) {
- Bot bot = room.getBot(roomUnit);
+ Bot bot = room.getRoomUnitManager().getRoomBotById(roomUnit.getVirtualId());
if (bot != null) {
this.giveEffect(room, roomUnit, bot.getGender());
@@ -67,10 +69,12 @@ public class InteractionEffectTile extends InteractionPressurePlate {
}
private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender) {
- if (gender.equals(HabboGender.M)) {
- room.giveEffect(roomUnit, this.getBaseItem().getEffectM(), -1);
- } else {
- room.giveEffect(roomUnit, this.getBaseItem().getEffectF(), -1);
+ if(roomUnit instanceof RoomAvatar roomAvatar) {
+ if (gender.equals(HabboGender.M)) {
+ roomAvatar.giveEffect(this.getBaseItem().getEffectM(), -1);
+ } else {
+ roomAvatar.giveEffect(this.getBaseItem().getEffectF(), -1);
+ }
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java
index 3084f3e4..50a30309 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectToggle.java
@@ -4,6 +4,7 @@ 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.users.HabboGender;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,19 +14,19 @@ public class InteractionEffectToggle extends InteractionDefault {
super(set, baseItem);
}
- public InteractionEffectToggle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionEffectToggle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if (this.getExtradata().isEmpty()) {
- this.setExtradata("0");
+ if (this.getExtraData().isEmpty()) {
+ this.setExtraData("0");
}
if (client != null) {
- if (room.hasRights(client.getHabbo())) {
- if (Integer.parseInt(this.getExtradata()) < this.getBaseItem().getStateCount() - 1) {
+ if (room.getRoomRightsManager().hasRights(client.getHabbo())) {
+ if (Integer.parseInt(this.getExtraData()) < this.getBaseItem().getStateCount() - 1) {
if ((client.getHabbo().getHabboInfo().getGender() == HabboGender.M && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) ||
(client.getHabbo().getHabboInfo().getGender() == HabboGender.F && client.getHabbo().getRoomUnit().getEffectId() == this.getBaseItem().getEffectF())) {
super.onClick(client, room, objects);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
index 49261af4..f579950b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachine.java
@@ -2,7 +2,8 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,16 +11,16 @@ import java.sql.SQLException;
public class InteractionEffectVendingMachine extends InteractionVendingMachine {
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionEffectVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionEffectVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
- public void giveVendingMachineItem(Room room, RoomUnit unit) {
- room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30);
+ public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) {
+ roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java
index 84f91edc..c7a77d10 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionEffectVendingMachineNoSides.java
@@ -3,7 +3,8 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
@@ -12,17 +13,17 @@ import java.sql.SQLException;
public class InteractionEffectVendingMachineNoSides extends InteractionVendingMachine {
public InteractionEffectVendingMachineNoSides(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionEffectVendingMachineNoSides(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionEffectVendingMachineNoSides(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
- public void giveVendingMachineItem(Room room, RoomUnit unit) {
- room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30);
+ public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) {
+ roomAvatar.giveEffect(this.getBaseItem().getRandomVendingItem(), 30);
}
@Override
@@ -31,7 +32,7 @@ public class InteractionEffectVendingMachineNoSides extends InteractionVendingMa
THashSet tiles = new THashSet<>();
for(int x = -1; x <= 1; x++) {
for(int y = -1; y <= 1; y++) {
- RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y));
+ RoomTile tile = room.getLayout().getTile((short)(this.getCurrentPosition().getX() + x), (short)(this.getCurrentPosition().getY() + y));
if(tile != null) {
tiles.add(tile);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java
index f6fa36e8..b5c5e429 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionExternalImage.java
@@ -3,20 +3,21 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionExternalImage extends HabboItem {
+public class InteractionExternalImage extends RoomItem {
public InteractionExternalImage(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionExternalImage(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionExternalImage(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -37,7 +38,7 @@ public class InteractionExternalImage extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
index daf5ab50..9ebe2cb2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
@@ -4,8 +4,9 @@ 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.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
@@ -18,15 +19,15 @@ public class InteractionFXBox extends InteractionDefault {
// this.setExtradata("0");
}
- public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionFXBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
// this.setExtradata("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) {
- if(this.getExtradata().equals("1"))
+ if (client != null && this.getOwnerInfo().getId() == client.getHabbo().getHabboInfo().getId()) {
+ if (this.getExtraData().equals("1"))
return;
int effectId = -1;
@@ -43,23 +44,23 @@ public class InteractionFXBox extends InteractionDefault {
}
}
- if(effectId < 0)
+ if (effectId < 0)
return;
- if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId))
+ if (client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId))
return;
client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0);
client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
- room.removeHabboItem(this);
- HabboItem item = this;
+ room.getRoomItemManager().removeRoomItem(this);
+ RoomItem item = this;
Emulator.getThreading().run(() -> {
new QueryDeleteHabboItem(item.getId()).run();
room.sendComposer(new RemoveFloorItemComposer(item).compose());
- room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
+ room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
}, 500);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java
index 22f4071d..b4763a98 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFireworks.java
@@ -7,8 +7,9 @@ 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.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import lombok.extern.slf4j.Slf4j;
@@ -30,8 +31,8 @@ public class InteractionFireworks extends InteractionDefault {
super(set, baseItem);
}
- public InteractionFireworks(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionFireworks(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -53,10 +54,10 @@ public class InteractionFireworks extends InteractionDefault {
// Wireds can always detonate fireworks if charged
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) {
- if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
+ if (this.getExtraData().equalsIgnoreCase(STATE_CHARGED)) {
super.onClick(client, room, objects);
- if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) {
+ if (this.getExtraData().equalsIgnoreCase(STATE_EXPLOSION)) {
this.reCharge(room);
}
}
@@ -70,13 +71,13 @@ public class InteractionFireworks extends InteractionDefault {
// Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks
if (!this.canToggle(client.getHabbo(), room)) {
RoomTile closestTile = null;
- for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
- if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
+ for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) {
+ if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) {
closestTile = tile;
}
}
- if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
+ if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) {
List onSuccess = new ArrayList<>();
onSuccess.add(() -> {
try {
@@ -86,15 +87,15 @@ public class InteractionFireworks extends InteractionDefault {
}
});
- client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
+ client.getHabbo().getRoomUnit().walkTo(closestTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
}
}
- if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
+ if (this.getExtraData().equalsIgnoreCase(STATE_CHARGED)) {
super.onClick(client, room, objects);
- if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION))
+ if (this.getExtraData().equalsIgnoreCase(STATE_EXPLOSION))
{
this.reCharge(room);
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
@@ -110,14 +111,14 @@ public class InteractionFireworks extends InteractionDefault {
@Override
public void onPlace(Room room) {
super.onPlace(room);
- this.setExtradata(STATE_CHARGED);
+ this.setExtraData(STATE_CHARGED);
}
@Override
public boolean canToggle(Habbo habbo, Room room) {
- return room.hasRights(habbo) || RoomLayout.tilesAdjecent(
- room.getLayout().getTile(this.getX(), this.getY()),
- habbo.getRoomUnit().getCurrentLocation()
+ return room.getRoomRightsManager().hasRights(habbo) || RoomLayout.tilesAdjecent(
+ room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()),
+ habbo.getRoomUnit().getCurrentPosition()
);
}
@@ -133,8 +134,8 @@ public class InteractionFireworks extends InteractionDefault {
}
Emulator.getThreading().run(() -> {
- this.setExtradata(STATE_CHARGED);
- this.needsUpdate(true);
+ this.setExtraData(STATE_CHARGED);
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}, explodeDuration);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
index 9646940b..abb1fabf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGate.java
@@ -4,27 +4,28 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionGate extends HabboItem {
+public class InteractionGate extends RoomItem {
public InteractionGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -34,28 +35,27 @@ public class InteractionGate extends HabboItem {
}
public boolean isWalkable() {
- return this.getExtradata().equals("1");
+ return this.getExtraData().equals("1");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
- if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired)
- return;
+ if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !executedByWired) return;
// If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close
- for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
- if (room.hasHabbosAt(tile.getX(), tile.getY()))
+ for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
+ if (room.getRoomUnitManager().hasHabbosAt(tile))
return;
// Gate closed = 0, open = 1
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
- this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + "");
- room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
- this.needsUpdate(true);
+ this.setExtraData((Integer.parseInt(this.getExtraData()) + 1) % 2 + "");
+ room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
index 712c6c4d..5498893e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGift.java
@@ -4,18 +4,19 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.HashSet;
@Slf4j
-public class InteractionGift extends HabboItem {
+public class InteractionGift extends RoomItem {
public boolean explode = false;
private int[] itemId;
@Getter
@@ -37,8 +38,8 @@ public class InteractionGift extends HabboItem {
}
}
- public InteractionGift(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGift(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
try {
this.loadData();
@@ -91,8 +92,8 @@ public class InteractionGift extends HabboItem {
private void loadData() throws NumberFormatException {
String[] data = null;
- if (this.getExtradata().contains("\t"))
- data = this.getExtradata().split("\t");
+ if (this.getExtraData().contains("\t"))
+ data = this.getExtraData().split("\t");
if (data != null && data.length >= 5) {
int count = Integer.parseInt(data[0]);
@@ -121,8 +122,8 @@ public class InteractionGift extends HabboItem {
}
}
- public THashSet loadItems() {
- THashSet items = new THashSet<>();
+ public HashSet loadItems() {
+ HashSet items = new HashSet<>();
for (int anItemId : this.itemId) {
if (anItemId == 0)
continue;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java
index 721f252f..9e74799c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupEffectTile.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,8 +11,8 @@ public class InteractionGroupEffectTile extends InteractionEffectTile {
super(set, baseItem);
}
- public InteractionGroupEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGroupEffectTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java
index 6aae5d31..7e1082b7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGroupPressurePlate.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,8 +11,8 @@ public class InteractionGroupPressurePlate extends InteractionPressurePlate {
super(set, baseItem);
}
- public InteractionGroupPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGroupPressurePlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
index 3ba1afc6..8646cead 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
@@ -4,7 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
@@ -23,8 +24,8 @@ public class InteractionGuildFurni extends InteractionDefault {
this.guildId = set.getInt("guild_id");
}
- public InteractionGuildFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGuildFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.guildId = 0;
}
@@ -43,14 +44,14 @@ public class InteractionGuildFurni extends InteractionDefault {
if (guild != null) {
serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(5);
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
serverMessage.appendString(guild.getId() + "");
serverMessage.appendString(guild.getBadge());
serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getSymbolColor(guild.getColorOne()).getValueA());
serverMessage.appendString(Emulator.getGameEnvironment().getGuildManager().getBackgroundColor(guild.getColorTwo()).getValueA());
} else {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
}
if (this.isLimited()) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
index 7e836dab..048c837a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildGate.java
@@ -7,8 +7,9 @@ import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet;
@@ -17,12 +18,12 @@ import java.sql.SQLException;
public class InteractionGuildGate extends InteractionGuildFurni implements ConditionalGate {
public InteractionGuildGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionGuildGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionGuildGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -35,9 +36,9 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi
if (roomUnit == null)
return false;
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
- return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasRight(Permission.ACC_GUILDGATE));
+ return habbo != null && (habbo.getHabboStats().hasGuild(super.getGuildId()) || habbo.hasPermissionRight(Permission.ACC_GUILDGATE));
}
@Override
@@ -45,7 +46,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi
super.onWalkOn(roomUnit, room, objects);
if (this.canWalkOn(roomUnit, room, objects)) {
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
}
}
@@ -59,7 +60,7 @@ public class InteractionGuildGate extends InteractionGuildFurni implements Condi
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItemState(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java
index 008b4279..d6a51125 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGymEquipment.java
@@ -2,13 +2,18 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
-import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -21,13 +26,13 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
super(set, baseItem);
}
- public InteractionGymEquipment(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGymEquipment(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.USER) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT));
+ return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.HABBO) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT));
}
@Override
@@ -40,13 +45,13 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
super.onWalkOn(roomUnit, room, objects);
if (this.forceRotation()) {
- roomUnit.setRotation(RoomUserRotation.fromValue(this.getRotation()));
+ roomUnit.setRotation(RoomRotation.fromValue(this.getRotation()));
roomUnit.setCanRotate(false);
}
- this.roomUnitId = roomUnit.getId();
+ this.roomUnitId = roomUnit.getVirtualId();
- if (roomUnit.getRoomUnitType() == RoomUnitType.USER) {
- Habbo habbo = room.getHabbo(roomUnit);
+ if (roomUnit.getRoomUnitType() == RoomUnitType.HABBO) {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
this.startTime = Emulator.getIntUnixTimestamp();
@@ -62,9 +67,9 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
this.reset(room);
- if (roomUnit != null) {
- Habbo habbo = room.getHabbo(roomUnit);
- HabboItem topItem = room.getTopItemAt(roomUnit.getCurrentLocation().getX(), roomUnit.getCurrentLocation().getY());
+ if (roomUnit instanceof RoomAvatar roomAvatar) {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY());
int nextEffectM = 0;
int nextEffectF = 0;
int nextEffectDuration = -1;
@@ -72,23 +77,23 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
if (topItem != null) {
nextEffectM = topItem.getBaseItem().getEffectM();
nextEffectF = topItem.getBaseItem().getEffectF();
- } else if (roomUnit.getPreviousEffectId() > 0) {
- nextEffectF = roomUnit.getPreviousEffectId();
- nextEffectM = roomUnit.getPreviousEffectId();
- nextEffectDuration = roomUnit.getPreviousEffectEndTimestamp();
+ } else if (roomAvatar.getPreviousEffectId() > 0) {
+ nextEffectF = roomAvatar.getPreviousEffectId();
+ nextEffectM = roomAvatar.getPreviousEffectId();
+ nextEffectDuration = roomAvatar.getPreviousEffectEndTimestamp();
}
if (this.forceRotation()) {
- roomUnit.setCanRotate(true);
+ roomAvatar.setCanRotate(true);
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
- room.giveEffect(habbo, nextEffectM, nextEffectDuration, true);
+ roomAvatar.giveEffect(nextEffectM, nextEffectDuration, true);
return;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F)) {
- room.giveEffect(habbo, nextEffectF, nextEffectDuration, true);
+ roomAvatar.giveEffect(nextEffectF, nextEffectDuration, true);
}
}
}
@@ -104,7 +109,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
@Override
public void cycle(Room room) {
if (this.roomUnitId != -1) {
- Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId);
+ Habbo habbo = room.getRoomUnitManager().getHabboByVirtualId(this.roomUnitId);
if (habbo != null) {
int timestamp = Emulator.getIntUnixTimestamp();
@@ -126,12 +131,12 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
super.setRotation(rotation);
if (this.forceRotation() && this.roomUnitId != -1) {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = this.getRoom();
if (room != null) {
RoomUnit roomUnit = this.getCurrentRoomUnit(room);
if (roomUnit != null) {
- roomUnit.setRotation(RoomUserRotation.fromValue(rotation));
+ roomUnit.setRotation(RoomRotation.fromValue(rotation));
room.updateRoomUnit(roomUnit);
}
}
@@ -161,27 +166,21 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
private void setEffect(Room room, int effectId) {
if (this.roomUnitId == -1) return;
- room.giveEffect(this.getCurrentRoomUnit(room), effectId, -1);
+ RoomUnit roomUnit = this.getCurrentRoomUnit(room);
+
+ if(roomUnit instanceof RoomAvatar roomAvatar) {
+ roomAvatar.giveEffect(effectId, -1);
+ }
}
private void reset(Room room) {
this.roomUnitId = -1;
this.startTime = 0;
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
}
private RoomUnit getCurrentRoomUnit(Room room) {
- Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId);
- if (habbo != null) {
- return habbo.getRoomUnit();
- } else {
- Bot bot = room.getBotByRoomUnitId(this.roomUnitId);
- if (bot != null) {
- return bot.getRoomUnit();
- }
- }
-
- return null;
+ return room.getRoomUnitManager().getCurrentRoomUnits().get(this.roomUnitId);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
index 7c7599f0..77ec9e26 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditem.java
@@ -5,8 +5,11 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.messages.outgoing.rooms.users.CarryObjectMessageComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -16,34 +19,39 @@ public class InteractionHanditem extends InteractionDefault {
super(set, baseItem);
}
- public InteractionHanditem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionHanditem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) ||
- (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY())) {
+ if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY())) ||
+ (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY())) {
this.handle(room, client.getHabbo().getRoomUnit());
}
}
protected void handle(Room room, RoomUnit roomUnit) {
- if (this.getExtradata().isEmpty()) this.setExtradata("0");
+ if (this.getExtraData().isEmpty()) this.setExtraData("0");
- if (!this.getExtradata().equals("0")) return;
+ if (!this.getExtraData().equals("0")) return;
- HabboItem instance = this;
- room.giveHandItem(roomUnit, this.getBaseItem().getRandomVendingItem());
+ if(!(roomUnit instanceof RoomAvatar roomAvatar)) {
+ return;
+ }
+
+ RoomItem instance = this;
+ roomAvatar.setHandItem(this.getBaseItem().getRandomVendingItem());
+ room.sendComposer(new CarryObjectMessageComposer(roomAvatar).compose());
if (this.getBaseItem().getStateCount() > 1) {
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItem(this);
Emulator.getThreading().run(() -> {
- InteractionHanditem.this.setExtradata("0");
+ InteractionHanditem.this.setExtraData("0");
room.updateItem(instance);
}, 500);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
index aa1eb152..bf8c2bd0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHanditemTile.java
@@ -3,7 +3,8 @@ package com.eu.habbo.habbohotel.items.interactions;
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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,15 +14,15 @@ public class InteractionHanditemTile extends InteractionHanditem {
super(set, baseItem);
}
- public InteractionHanditemTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionHanditemTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
InteractionHanditemTile instance = this;
Emulator.getThreading().run(() -> {
- if (roomUnit.getCurrentLocation().getX() == instance.getX() && roomUnit.getCurrentLocation().getY() == instance.getY()) {
+ if (roomUnit.getCurrentPosition().getX() == instance.getCurrentPosition().getX() && roomUnit.getCurrentPosition().getY() == instance.getCurrentPosition().getY()) {
instance.handle(room, roomUnit);
}
}, 3000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java
index f20c26d6..717cbc3c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHopper.java
@@ -5,29 +5,30 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.hopper.HopperActionOne;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionHopper extends HabboItem {
+public class InteractionHopper extends RoomItem {
public InteractionHopper(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -52,16 +53,16 @@ public class InteractionHopper extends HabboItem {
super.onClick(client, room, objects);
if (room != null) {
- RoomTile loc = HabboItem.getSquareInFront(room.getLayout(), this);
+ RoomTile loc = RoomItem.getSquareInFront(room.getLayout(), this);
if (loc != null) {
if (this.canUseTeleport(client, loc, room)) {
client.getHabbo().getRoomUnit().setTeleporting(true);
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
Emulator.getThreading().run(new HopperActionOne(this, room, client), 500);
} else {
- client.getHabbo().getRoomUnit().setGoalLocation(loc);
+ client.getHabbo().getRoomUnit().walkTo(loc);
}
}
}
@@ -69,15 +70,15 @@ public class InteractionHopper extends HabboItem {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
public void run() {
- if (!this.getExtradata().equals("0")) {
- this.setExtradata("0");
+ if (!this.getExtraData().equals("0")) {
+ this.setExtraData("0");
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = this.getRoom();
if (room != null) {
room.updateItemState(this);
}
@@ -86,18 +87,24 @@ public class InteractionHopper extends HabboItem {
}
protected boolean canUseTeleport(GameClient client, RoomTile front, Room room) {
- if (client.getHabbo().getRoomUnit().getX() != front.getX())
+ if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() != front.getX())
return false;
- if (client.getHabbo().getRoomUnit().getY() != front.getY())
+ if (client.getHabbo().getRoomUnit().getCurrentPosition().getY() != front.getY())
return false;
if (client.getHabbo().getRoomUnit().isTeleporting())
return false;
- if (!room.getHabbosAt(this.getX(), this.getY()).isEmpty())
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+
+ if(tile == null) {
+ return false;
+ }
+
+ if (room.getRoomUnitManager().hasHabbosAt(tile))
return false;
- return this.getExtradata().equals("0");
+ return this.getExtraData().equals("0");
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
index d8e5fa5c..2a508003 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
@@ -2,8 +2,9 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.habboway.nux.InClientLinkMessageComposer;
import gnu.trove.map.hash.THashMap;
@@ -22,8 +23,8 @@ public class InteractionInformationTerminal extends InteractionCustomValues {
super(set, baseItem, defaultValues);
}
- public InteractionInformationTerminal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
+ public InteractionInformationTerminal(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues);
}
@Override
@@ -40,7 +41,7 @@ public class InteractionInformationTerminal extends InteractionCustomValues {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.values.containsKey("internalLink")) {
habbo.getClient().sendResponse(new InClientLinkMessageComposer(this.values.get("internalLink")));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
index dec7b52a..f97e02cc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionJukeBox.java
@@ -3,26 +3,27 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionJukeBox extends HabboItem {
+public class InteractionJukeBox extends RoomItem {
public InteractionJukeBox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionJukeBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionJukeBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -48,10 +49,10 @@ public class InteractionJukeBox extends HabboItem {
if (client != null && objects.length == 1) {
if ((Integer) objects[0] == 0) {
- if (room.getTraxManager().isPlaying()) {
- room.getTraxManager().stop();
+ if (room.getRoomTraxManager().isPlaying()) {
+ room.getRoomTraxManager().stop();
} else {
- room.getTraxManager().play(0, client.getHabbo());
+ room.getRoomTraxManager().play(0, client.getHabbo());
}
}
}
@@ -60,16 +61,16 @@ public class InteractionJukeBox extends HabboItem {
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
- this.setExtradata("0");
- room.getTraxManager().removeTraxOnRoom(this);
+ this.setExtraData("0");
+ room.getRoomTraxManager().removeTraxOnRoom(this);
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
- room.getTraxManager().addTraxOnRoom(this);
- if (room.getTraxManager().isPlaying()) {
- this.setExtradata("1");
+ room.getRoomTraxManager().addTraxOnRoom(this);
+ if (room.getRoomTraxManager().isPlaying()) {
+ this.setExtraData("1");
}
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java
index 2369b288..a0db0e72 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionLoveLock.java
@@ -6,9 +6,10 @@ 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.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.lovelock.FriendFurniStartConfirmationMessageComposer;
@@ -16,7 +17,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
-public class InteractionLoveLock extends HabboItem {
+public class InteractionLoveLock extends RoomItem {
public int userOneId;
public int userTwoId;
@@ -24,8 +25,8 @@ public class InteractionLoveLock extends HabboItem {
super(set, baseItem);
}
- public InteractionLoveLock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionLoveLock(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -33,7 +34,7 @@ public class InteractionLoveLock extends HabboItem {
serverMessage.appendInt(2 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(6);
- String[] data = this.getExtradata().split("\t");
+ String[] data = this.getExtraData().split("\t");
if (data.length == 6) {
serverMessage.appendString("1");
@@ -71,19 +72,19 @@ public class InteractionLoveLock extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (this.getExtradata().contains("\t"))
+ if (this.getExtraData().contains("\t"))
return;
if (client == null)
return;
- if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) {
+ if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) {
if (this.userOneId == 0) {
this.userOneId = client.getHabbo().getHabboInfo().getId();
client.sendResponse(new FriendFurniStartConfirmationMessageComposer(this));
} else {
if (this.userOneId != client.getHabbo().getHabboInfo().getId()) {
- Habbo habbo = room.getHabbo(this.userOneId);
+ Habbo habbo = room.getRoomUnitManager().getRoomHabboById(this.userOneId);
if (habbo != null) {
this.userTwoId = client.getHabbo().getHabboInfo().getId();
@@ -95,8 +96,8 @@ public class InteractionLoveLock extends HabboItem {
}
public boolean lock(Habbo userOne, Habbo userTwo, Room room) {
- RoomTile tile = room.getLayout().getTile(this.getX(), this.getY());
- if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentLocation(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentLocation(), tile)) {
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+ if (RoomLayout.tilesAdjecent(userOne.getRoomUnit().getCurrentPosition(), tile) && RoomLayout.tilesAdjecent(userTwo.getRoomUnit().getCurrentPosition(), tile)) {
String data = "1";
data += "\t";
data += userOne.getHabboInfo().getUsername();
@@ -109,8 +110,8 @@ public class InteractionLoveLock extends HabboItem {
data += "\t";
data += Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR);
- this.setExtradata(data);
- this.needsUpdate(true);
+ this.setExtraData(data);
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
room.updateItem(this);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
index 84adbbb1..af830c07 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMannequin.java
@@ -4,8 +4,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer;
@@ -14,13 +15,13 @@ import com.eu.habbo.messages.outgoing.users.UserObjectComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionMannequin extends HabboItem {
+public class InteractionMannequin extends RoomItem {
public InteractionMannequin(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionMannequin(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionMannequin(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -32,8 +33,8 @@ public class InteractionMannequin extends HabboItem {
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(3);
- if (this.getExtradata().split(":").length >= 2) {
- String[] data = this.getExtradata().split(":");
+ if (this.getExtraData().split(":").length >= 2) {
+ String[] data = this.getExtraData().split(":");
serverMessage.appendString("GENDER");
serverMessage.appendString(data[0].toLowerCase());
serverMessage.appendString("FIGURE");
@@ -47,8 +48,8 @@ public class InteractionMannequin extends HabboItem {
serverMessage.appendString("");
serverMessage.appendString("OUTFIT_NAME");
serverMessage.appendString("My Look");
- this.setExtradata("m: :My look");
- this.needsUpdate(true);
+ this.setExtraData("m: :My look");
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
}
super.serializeExtradata(serverMessage);
@@ -66,7 +67,7 @@ public class InteractionMannequin extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- String[] data = this.getExtradata().split(":");
+ String[] data = this.getExtraData().split(":");
if(data.length < 2)
return;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java
index 44f024db..1d79a5e4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java
@@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -18,8 +19,8 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements
super(set, baseItem);
}
- public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionMonsterCrackable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -33,7 +34,7 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if (room.isPublicRoom()) this.respawn = true;
+ if (room.getRoomInfo().isPublicRoom()) this.respawn = true;
super.onClick(client, room, objects);
}
@@ -46,9 +47,10 @@ public class InteractionMonsterCrackable extends InteractionCrackable implements
@Override
public void reset(Room room) {
RoomTile tile = room.getRandomWalkableTile();
- this.setX(tile.getX());
- this.setY(tile.getY());
- this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false));
+
+ this.setCurrentPosition(tile);
+ this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false));
+
super.reset(room);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java
index 0830cad5..7c16ea07 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMoodLight.java
@@ -4,26 +4,28 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
+import gnu.trove.map.TIntObjectMap;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionMoodLight extends HabboItem {
+public class InteractionMoodLight extends RoomItem {
public InteractionMoodLight(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionMoodLight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionMoodLight(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -46,10 +48,10 @@ public class InteractionMoodLight extends HabboItem {
@Override
public void onPlace(Room room) {
if (room != null) {
- for (RoomMoodlightData data : room.getMoodlightData().valueCollection()) {
+ for (RoomMoodlightData data : ((TIntObjectMap) room.getRoomInfo().getMoodLightData()).valueCollection()) {
if (data.isEnabled()) {
- this.setExtradata(data.toString());
- this.needsUpdate(true);
+ this.setExtraData(data.toString());
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
Emulator.getThreading().run(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
index ddce7f99..5b9ee060 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMultiHeight.java
@@ -2,10 +2,12 @@ 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.*;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
@@ -14,9 +16,9 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
-public class InteractionMultiHeight extends HabboItem {
- public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+public class InteractionMultiHeight extends RoomItem {
+ public InteractionMultiHeight(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public InteractionMultiHeight(ResultSet set, Item baseItem) throws SQLException {
@@ -26,7 +28,7 @@ public class InteractionMultiHeight extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -45,50 +47,53 @@ public class InteractionMultiHeight extends HabboItem {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (client != null && !room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))
+ if (client != null && !room.getRoomRightsManager().hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE)) {
return;
+ }
- if (objects.length <= 0) {
+ if (objects.length == 0) {
return;
}
if (objects[0] instanceof Integer && room != null) {
- HabboItem topItem = room.getTopItemAt(this.getX(), this.getY());
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+
if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
return;
}
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0) {
+ this.setExtraData("0");
+ }
if (this.getBaseItem().getMultiHeights().length > 0) {
- this.setExtradata("" + (Integer.parseInt(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length));
- this.needsUpdate(true);
- room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
+ this.setExtraData(String.valueOf((Integer.parseInt(this.getExtraData()) + 1) % (this.getBaseItem().getMultiHeights().length)));
+ this.setSqlUpdateNeeded(true);
+ room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
room.updateItemState(this);
}
}
}
public void updateUnitsOnItem(Room room) {
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
for(RoomTile tile : occupiedTiles) {
- Collection unitsOnItem = room.getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY()));
+ Collection unitsOnItem = room.getRoomUnitManager().getRoomUnitsAt(room.getLayout().getTile(tile.getX(), tile.getY()));
for (RoomUnit unit : unitsOnItem) {
- if (unit.hasStatus(RoomUnitStatus.MOVE) && unit.getGoalLocation() != tile)
- continue;
+ if (unit.hasStatus(RoomUnitStatus.MOVE)) {
+ if (unit.getTargetPosition() != tile) {
+ continue;
+ }
+ }
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
- unit.setSitUpdate(true);
- unit.statusUpdate(true);
+ unit.setStatusUpdateNeeded(true);
} else {
- unit.setZ(unit.getCurrentLocation().getStackHeight());
- unit.setPreviousLocationZ(unit.getZ());
- unit.statusUpdate(true);
+ unit.setCurrentZ(unit.getCurrentPosition().getStackHeight());
}
}
}
@@ -102,45 +107,11 @@ public class InteractionMultiHeight extends HabboItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
-
- if (roomUnit != null
- && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
- && roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
- room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
- return;
- }
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
- room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
- }
- }
- }
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
-
- if (roomUnit != null
- && (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
- && roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
- room.giveEffect(habbo, 0, -1);
- return;
- }
-
- if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
- room.giveEffect(habbo, 0, -1);
- }
- }
- }
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
index 39eb0b27..3cb5277f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMusicDisc.java
@@ -2,8 +2,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import lombok.extern.slf4j.Slf4j;
@@ -11,14 +12,14 @@ import java.sql.ResultSet;
import java.sql.SQLException;
@Slf4j
-public class InteractionMusicDisc extends HabboItem {
+public class InteractionMusicDisc extends RoomItem {
private int songId;
public InteractionMusicDisc(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- String[] stuff = this.getExtradata().split("\n");
+ String[] stuff = this.getExtraData().split("\n");
if (stuff.length >= 7 && !stuff[6].isEmpty()) {
try {
@@ -29,10 +30,10 @@ public class InteractionMusicDisc extends HabboItem {
}
}
- public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionMusicDisc(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
- String[] stuff = this.getExtradata().split("\n");
+ String[] stuff = this.getExtraData().split("\n");
if (stuff.length >= 7 && !stuff[6].isEmpty()) {
try {
@@ -46,7 +47,7 @@ public class InteractionMusicDisc extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -74,13 +75,13 @@ public class InteractionMusicDisc extends HabboItem {
public void onPlace(Room room) {
super.onPlace(room);
- room.getTraxManager().sendUpdatedSongList();
+ room.getRoomTraxManager().sendUpdatedSongList();
}
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
- room.getTraxManager().sendUpdatedSongList();
+ room.getRoomTraxManager().sendUpdatedSongList();
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
index e5fbd80b..9ff89f85 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.outgoing.rooms.items.ObjectDataUpdateMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.ObjectsMessageComposer;
@@ -39,8 +40,8 @@ public class InteractionMuteArea extends InteractionCustomValues {
tiles = new THashSet<>();
}
- public InteractionMuteArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
+ public InteractionMuteArea(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues);
tiles = new THashSet<>();
}
@@ -48,7 +49,7 @@ public class InteractionMuteArea extends InteractionCustomValues {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.hasRights(client.getHabbo()))) {
+ if((objects.length >= 2 && objects[1] instanceof WiredEffectType) || (client != null && room.getRoomRightsManager().hasRights(client.getHabbo()))) {
this.values.put("state", this.values.get("state").equals("0") ? "1" : "0");
room.sendComposer(new ObjectDataUpdateMessageComposer(this).compose());
}
@@ -73,7 +74,7 @@ public class InteractionMuteArea extends InteractionCustomValues {
}
public boolean inSquare(RoomTile location) {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = this.getRoom();
if(!this.values.get("state").equals("1"))
return false;
@@ -96,10 +97,10 @@ public class InteractionMuteArea extends InteractionCustomValues {
}
private void regenAffectedTiles(Room room) {
- int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack")));
- int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight")));
- int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront")));
- int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft")));
+ int minX = Math.max(0, this.getCurrentPosition().getX() - Integer.parseInt(this.values.get("tilesBack")));
+ int minY = Math.max(0, this.getCurrentPosition().getY() - Integer.parseInt(this.values.get("tilesRight")));
+ int maxX = Math.min(room.getLayout().getMapSizeX(), this.getCurrentPosition().getX() + Integer.parseInt(this.values.get("tilesFront")));
+ int maxY = Math.min(room.getLayout().getMapSizeY(), this.getCurrentPosition().getY() + Integer.parseInt(this.values.get("tilesLeft")));
this.tiles.clear();
@@ -124,21 +125,21 @@ public class InteractionMuteArea extends InteractionCustomValues {
if(effectItem != null) {
TIntObjectMap ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
ownerNames.put(-1, "System");
- THashSet items = new THashSet<>();
+ THashSet items = new THashSet<>();
int id = 0;
for(RoomTile tile : this.tiles) {
id--;
- HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0);
- item.setX(tile.getX());
- item.setY(tile.getY());
- item.setZ(tile.relativeHeight());
+ RoomItem item = new InteractionDefault(id, null, effectItem, "1", 0, 0);
+
+ item.setCurrentPosition(tile);
+ item.setCurrentZ(tile.relativeHeight());
items.add(item);
}
client.sendResponse(new ObjectsMessageComposer(ownerNames, items));
Emulator.getThreading().run(() -> {
- for(HabboItem item : items) {
+ for(RoomItem item : items) {
client.sendResponse(new RemoveFloorItemComposer(item, true));
}
}, 3000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
index f31560db..b8516dda 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionNoSidesVendingMachine.java
@@ -3,6 +3,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.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
@@ -13,8 +14,8 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine
super(set, baseItem);
}
- public InteractionNoSidesVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionNoSidesVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -23,7 +24,7 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine
THashSet tiles = new THashSet<>();
for(int x = -1; x <= 1; x++) {
for(int y = -1; y <= 1; y++) {
- RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y));
+ RoomTile tile = room.getLayout().getTile((short)(this.getCurrentPosition().getX() + x), (short)(this.getCurrentPosition().getY() + y));
if(tile != null) {
tiles.add(tile);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java
index a782efd5..d3546bc1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionObstacle.java
@@ -5,9 +5,15 @@ import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.pets.HorsePet;
import com.eu.habbo.habbohotel.pets.Pet;
-import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
@@ -15,26 +21,26 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Objects;
-public class InteractionObstacle extends HabboItem implements ICycleable {
+public class InteractionObstacle extends RoomItem implements ICycleable {
private final THashSet middleTiles;
public InteractionObstacle(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
this.middleTiles = new THashSet<>();
}
- public InteractionObstacle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionObstacle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
this.middleTiles = new THashSet<>();
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -88,24 +94,24 @@ public class InteractionObstacle extends HabboItem implements ICycleable {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) {
if (roomUnit.getBodyRotation().getValue() % 2 == 0) {
if (this.getRotation() == 2) {
- if (roomUnit.getBodyRotation().equals(RoomUserRotation.WEST)) {
- ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() - 3), roomUnit.getY()));
- } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.EAST)) {
- ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile((short) (roomUnit.getX() + 3), roomUnit.getY()));
+ if (roomUnit.getBodyRotation().equals(RoomRotation.WEST)) {
+ ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() - 3), roomUnit.getCurrentPosition().getY()));
+ } else if (roomUnit.getBodyRotation().equals(RoomRotation.EAST)) {
+ ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile((short) (roomUnit.getCurrentPosition().getX() + 3), roomUnit.getCurrentPosition().getY()));
}
} else if (this.getRotation() == 4) {
- if (roomUnit.getBodyRotation().equals(RoomUserRotation.NORTH)) {
- ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() - 3)));
- } else if (roomUnit.getBodyRotation().equals(RoomUserRotation.SOUTH)) {
- ((HorsePet) pet).getRider().getRoomUnit().setGoalLocation(room.getLayout().getTile(roomUnit.getX(), (short) (roomUnit.getY() + 3)));
+ if (roomUnit.getBodyRotation().equals(RoomRotation.NORTH)) {
+ ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() - 3)));
+ } else if (roomUnit.getBodyRotation().equals(RoomRotation.SOUTH)) {
+ ((HorsePet) pet).getRider().getRoomUnit().walkTo(room.getLayout().getTile(roomUnit.getCurrentPosition().getX(), (short) (roomUnit.getCurrentPosition().getY() + 3)));
}
}
}
@@ -117,10 +123,10 @@ public class InteractionObstacle extends HabboItem implements ICycleable {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet instanceof HorsePet && ((HorsePet) pet).getRider() != null) {
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
@@ -150,12 +156,12 @@ public class InteractionObstacle extends HabboItem implements ICycleable {
middleTiles.clear();
if(this.getRotation() == 2) {
- middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), this.getY()));
- middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1)));
+ middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), this.getCurrentPosition().getY()));
+ middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), (short)(this.getCurrentPosition().getY() + 1)));
}
else if(this.getRotation() == 4) {
- middleTiles.add(room.getLayout().getTile(this.getX(), (short)(this.getY() + 1)));
- middleTiles.add(room.getLayout().getTile((short)(this.getX() + 1), (short)(this.getY() + 1)));
+ middleTiles.add(room.getLayout().getTile(this.getCurrentPosition().getX(), (short)(this.getCurrentPosition().getY() + 1)));
+ middleTiles.add(room.getLayout().getTile((short)(this.getCurrentPosition().getX() + 1), (short)(this.getCurrentPosition().getY() + 1)));
}
}
@@ -174,19 +180,23 @@ public class InteractionObstacle extends HabboItem implements ICycleable {
}
for(RoomTile tile : this.middleTiles) {
- for(RoomUnit unit : tile.getUnits()) {
- if(unit.getPath().size() == 0 && !unit.hasStatus(RoomUnitStatus.MOVE)) {
- if(unit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue() != this.getRotation())
+ for(RoomUnit roomUnit : room.getRoomUnitManager().getRoomUnitsAt(tile)) {
+ if(roomUnit == null) {
+ continue;
+ }
+
+ if(roomUnit.getPath().size() == 0 && !roomUnit.hasStatus(RoomUnitStatus.MOVE)) {
+ if(roomUnit.getBodyRotation().getValue() != this.getRotation() && Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue() != this.getRotation())
continue;
- RoomTile tileInfront = room.getLayout().getTileInFront(unit.getCurrentLocation(), unit.getBodyRotation().getValue());
- if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileInfront).size() == 0) {
- unit.setGoalLocation(tileInfront);
+ RoomTile tileInfront = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), roomUnit.getBodyRotation().getValue());
+ if(tileInfront.getState() != RoomTileState.INVALID && tileInfront.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileInfront).size() == 0) {
+ roomUnit.walkTo(tileInfront);
}
else {
- RoomTile tileBehind = room.getLayout().getTileInFront(unit.getCurrentLocation(), Objects.requireNonNull(unit.getBodyRotation().getOpposite()).getValue());
- if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitsAt(tileBehind).size() == 0) {
- unit.setGoalLocation(tileBehind);
+ RoomTile tileBehind = room.getLayout().getTileInFront(roomUnit.getCurrentPosition(), Objects.requireNonNull(roomUnit.getBodyRotation().getOpposite()).getValue());
+ if(tileBehind.getState() != RoomTileState.INVALID && tileBehind.getState() != RoomTileState.BLOCKED && room.getRoomUnitManager().getRoomUnitsAt(tileBehind).size() == 0) {
+ roomUnit.walkTo(tileBehind);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
index d2f559cb..084affc3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionOneWayGate.java
@@ -5,8 +5,9 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
@@ -18,17 +19,17 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class InteractionOneWayGate extends HabboItem {
+public class InteractionOneWayGate extends RoomItem {
private boolean walkable = false;
public InteractionOneWayGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionOneWayGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionOneWayGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -48,13 +49,13 @@ public class InteractionOneWayGate extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
- if (this.getExtradata().length() == 0) {
- this.setExtradata("0");
- this.needsUpdate(true);
+ if (this.getExtraData().length() == 0) {
+ this.setExtraData("0");
+ this.setSqlUpdateNeeded(true);
}
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -64,11 +65,11 @@ public class InteractionOneWayGate extends HabboItem {
super.onClick(client, room, objects);
if (client != null) {
- RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation());
+ RoomTile tileInfront = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation());
if (tileInfront == null)
return;
- RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
+ RoomTile currentLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
if (currentLocation == null)
return;
@@ -76,62 +77,60 @@ public class InteractionOneWayGate extends HabboItem {
if (unit == null)
return;
- if (tileInfront.getX() == unit.getX() && tileInfront.getY() == unit.getY()) {
- if (!currentLocation.hasUnits()) {
- List onSuccess = new ArrayList<>();
- List onFail = new ArrayList<>();
+ if (tileInfront.equals(unit.getCurrentPosition()) && !room.getRoomUnitManager().areRoomUnitsAt(currentLocation)) {
+ List onSuccess = new ArrayList<>();
+ List onFail = new ArrayList<>();
- onSuccess.add(() -> {
- unit.setCanLeaveRoomByDoor(false);
- walkable = this.getBaseItem().allowWalk();
- RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4);
- unit.setGoalLocation(tile);
- Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
+ onSuccess.add(() -> {
+ unit.setCanLeaveRoomByDoor(false);
+ walkable = this.getBaseItem().allowWalk();
+ RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getRotation() + 4);
+ unit.walkTo(tile);
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
- Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
- });
+ Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, unit, room, new Object[]{this}), 500);
+ });
- onFail.add(() -> {
- unit.setCanLeaveRoomByDoor(true);
- walkable = this.getBaseItem().allowWalk();
- room.updateTile(currentLocation);
- room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose());
- unit.removeOverrideTile(currentLocation);
- });
-
- walkable = true;
+ onFail.add(() -> {
+ unit.setCanLeaveRoomByDoor(true);
+ walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation);
- unit.addOverrideTile(currentLocation);
- unit.setGoalLocation(currentLocation);
- Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
- room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose());
+ room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose());
+ unit.removeOverrideTile(currentLocation);
+ });
- /*
- room.scheduledTasks.add(new Runnable()
+ walkable = true;
+ room.updateTile(currentLocation);
+ unit.addOverrideTile(currentLocation);
+ unit.walkTo(currentLocation);
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
+ room.sendComposer(new DiceValueMessageComposer(this.getId(), 1).compose());
+
+ /*
+ room.scheduledTasks.add(new Runnable()
+ {
+ @Override
+ public void run()
{
- @Override
- public void run()
- {
- gate.roomUnitID = client.getHabbo().getRoomUnit().getId();
- room.updateTile(gatePosition);
- client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4));
- }
- });
- */
- }
+ gate.roomUnitID = client.getHabbo().getRoomUnit().getId();
+ room.updateTile(gatePosition);
+ client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(InteractionOneWayGate.this.getX(), InteractionOneWayGate.this.getY()), InteractionOneWayGate.this.getRotation() + 4));
+ }
+ });
+ */
}
}
}
private void refresh(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.sendComposer(new DiceValueMessageComposer(this.getId(), 0).compose());
- room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
+ room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
this.refresh(room);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java
index ae9b8872..f9a31eb7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPostIt.java
@@ -2,22 +2,23 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionPostIt extends HabboItem {
+public class InteractionPostIt extends RoomItem {
public static String STICKYPOLE_PREFIX_TEXT = "";
public InteractionPostIt(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionPostIt(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPostIt(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -38,7 +39,7 @@ public class InteractionPostIt extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata().replace(((char) 9) + "", ""));
+ serverMessage.appendString(this.getExtraData().replace(((char) 9) + "", ""));
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java
index bdb3afd4..2b5d2180 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPoster.java
@@ -2,16 +2,17 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionPoster extends HabboItem {
- public InteractionPoster(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+public class InteractionPoster extends RoomItem {
+ public InteractionPoster(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public InteractionPoster(ResultSet set, Item baseItem) throws SQLException {
@@ -36,7 +37,7 @@ public class InteractionPoster extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
index 04491166..6af9943d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPressurePlate.java
@@ -5,21 +5,23 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.HashSet;
public class InteractionPressurePlate extends InteractionDefault {
public InteractionPressurePlate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionPressurePlate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -65,7 +67,7 @@ public class InteractionPressurePlate extends InteractionDefault {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
public void updateState(Room room) {
@@ -73,7 +75,7 @@ public class InteractionPressurePlate extends InteractionDefault {
if (room == null || room.getLayout() == null || this.getBaseItem() == null) return;
- RoomTile tileAtItem = room.getLayout().getTile(this.getX(), this.getY());
+ RoomTile tileAtItem = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
if (tileAtItem == null) return;
@@ -82,7 +84,8 @@ public class InteractionPressurePlate extends InteractionDefault {
if (tiles == null) return;
for (RoomTile tile : tiles) {
- THashSet tileHasHabboOrBot = room.getHabbosAndBotsAt(tile.getX(), tile.getY());
+ HashSet tileHasHabboOrBot = (HashSet) room.getRoomUnitManager().getAvatarsAt(tile);
+
if (tileHasHabboOrBot.isEmpty() && this.requiresAllTilesOccupied()) {
occupied = false;
break;
@@ -93,7 +96,7 @@ public class InteractionPressurePlate extends InteractionDefault {
}
}
- this.setExtradata(occupied ? "1" : "0");
+ this.setExtraData(occupied ? "1" : "0");
room.updateItemState(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
index 008370b8..ab19efe7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPushable.java
@@ -3,7 +3,12 @@ package com.eu.habbo.habbohotel.items.interactions;
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.*;
+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.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.KickBallAction;
import java.sql.ResultSet;
@@ -17,12 +22,12 @@ public abstract class InteractionPushable extends InteractionDefault {
public InteractionPushable(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionPushable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionPushable(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -43,7 +48,7 @@ public abstract class InteractionPushable extends InteractionDefault {
return;
int velocity = this.getWalkOffVelocity(roomUnit, room);
- RoomUserRotation direction = this.getWalkOffDirection(roomUnit, room);
+ RoomRotation direction = this.getWalkOffDirection(roomUnit, room);
this.onKick(room, roomUnit, velocity, direction);
if (velocity > 0) {
@@ -60,9 +65,9 @@ public abstract class InteractionPushable extends InteractionDefault {
super.onClick(client, room, objects);
if (client == null) return;
- if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) {
+ if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentPosition(), room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) {
int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room);
- RoomUserRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room);
+ RoomRotation direction = this.getWalkOnDirection(client.getHabbo().getRoomUnit(), room);
this.onTackle(room, client.getHabbo().getRoomUnit(), velocity, direction);
if (velocity > 0) {
@@ -81,9 +86,9 @@ public abstract class InteractionPushable extends InteractionDefault {
int velocity;
boolean isDrag = false;
- RoomUserRotation direction;
+ RoomRotation direction;
- if (this.getX() == roomUnit.getGoalLocation().getX() && this.getY() == roomUnit.getGoalLocation().getY()) //User clicked on the tile the ball is on, they want to kick it
+ if (this.getCurrentPosition().getX() == roomUnit.getTargetPosition().getX() && this.getCurrentPosition().getY() == roomUnit.getTargetPosition().getY()) //User clicked on the tile the ball is on, they want to kick it
{
velocity = this.getWalkOnVelocity(roomUnit, room);
direction = this.getWalkOnDirection(roomUnit, room);
@@ -109,54 +114,54 @@ public abstract class InteractionPushable extends InteractionDefault {
public abstract int getWalkOnVelocity(RoomUnit roomUnit, Room room);
- public abstract RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room);
+ public abstract RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room);
public abstract int getWalkOffVelocity(RoomUnit roomUnit, Room room);
- public abstract RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room);
+ public abstract RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room);
public abstract int getDragVelocity(RoomUnit roomUnit, Room room);
- public abstract RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room);
+ public abstract RoomRotation getDragDirection(RoomUnit roomUnit, Room room);
public abstract int getTackleVelocity(RoomUnit roomUnit, Room room);
- public abstract RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room);
+ public abstract RoomRotation getTackleDirection(RoomUnit roomUnit, Room room);
public abstract int getNextRollDelay(int currentStep, int totalSteps); //The length in milliseconds when the ball should next roll
- public abstract RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection); //Returns the new direction to move the ball when the ball cannot move
+ public abstract RoomRotation getBounceDirection(Room room, RoomRotation currentDirection); //Returns the new direction to move the ball when the ball cannot move
public abstract boolean validMove(Room room, RoomTile from, RoomTile to); //Checks if the next move is valid
- public abstract void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction);
+ public abstract void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction);
- public abstract void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction);
+ public abstract void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction);
- public abstract void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction);
+ public abstract void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction);
- public abstract void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps);
+ public abstract void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps);
- public abstract void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker);
+ public abstract void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker);
public abstract void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps);
- public abstract boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps);
+ public abstract boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps);
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
index 36250f87..1087cbbd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPuzzleBox.java
@@ -2,81 +2,92 @@ 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.*;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionPuzzleBox extends HabboItem {
+public class InteractionPuzzleBox extends RoomItem {
public InteractionPuzzleBox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionPuzzleBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPuzzleBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- RoomTile boxLocation = room.getLayout().getTile(this.getX(), this.getY());
- RoomUserRotation rotation = null;
+ RoomTile boxLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+ RoomRotation rotation = null;
- if (this.getX() == client.getHabbo().getRoomUnit().getX()) {
- if (this.getY() == client.getHabbo().getRoomUnit().getY() + 1) {
- rotation = RoomUserRotation.SOUTH;
- } else if (this.getY() == client.getHabbo().getRoomUnit().getY() - 1) {
- rotation = RoomUserRotation.NORTH;
+ if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX()) {
+ if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() + 1) {
+ rotation = RoomRotation.SOUTH;
+ } else {
+ if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY() - 1) {
+ rotation = RoomRotation.NORTH;
+ }
}
- } else if (this.getY() == client.getHabbo().getRoomUnit().getY()) {
- if (this.getX() == client.getHabbo().getRoomUnit().getX() + 1) {
- rotation = RoomUserRotation.EAST;
- } else if (this.getX() == client.getHabbo().getRoomUnit().getX() - 1) {
- rotation = RoomUserRotation.WEST;
+ } else {
+ if (this.getCurrentPosition().getY() == client.getHabbo().getRoomUnit().getCurrentPosition().getY()) {
+ if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() + 1) {
+ rotation = RoomRotation.EAST;
+ } else if (this.getCurrentPosition().getX() == client.getHabbo().getRoomUnit().getCurrentPosition().getX() - 1) {
+ rotation = RoomRotation.WEST;
+ }
}
}
if (rotation == null) {
- RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), false);
+ RoomTile nearestTile = client.getHabbo().getRoomUnit().getClosestAdjacentTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false);
- if (nearestTile != null) client.getHabbo().getRoomUnit().setGoalLocation(nearestTile);
+ if (nearestTile != null) client.getHabbo().getRoomUnit().walkTo(nearestTile);
return;
}
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
- RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), rotation.getValue());
+ RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), rotation.getValue());
- if (tile == null || tile.getState() == RoomTileState.INVALID || room.hasHabbosAt(tile.getX(), tile.getY())) {
+ if (tile == null || tile.getState() == RoomTileState.INVALID || room.getRoomUnitManager().hasHabbosAt(tile)) {
return;
}
- if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentLocation(), rotation.getValue())))
+ if (!boxLocation.equals(room.getLayout().getTileInFront(client.getHabbo().getRoomUnit().getCurrentPosition(), rotation.getValue())))
return;
- HabboItem item = room.getTopItemAt(tile.getX(), tile.getY());
+ RoomItem item = room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY());
- if (item != null && !room.getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack()) return;
+ if (item != null && !room.getRoomItemManager().getTopItemAt(tile.getX(), tile.getY()).getBaseItem().allowStack())
+ return;
+
+ this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false));
+ this.setSqlUpdateNeeded(true);
- this.setZ(room.getStackHeight(tile.getX(), tile.getY(), false));
- this.needsUpdate(true);
room.updateItem(this);
room.scheduledComposers.add(new FloorItemOnRollerComposer(this, null, tile, 0, room).compose());
room.scheduledTasks.add(() -> {
- client.getHabbo().getRoomUnit().setGoalLocation(boxLocation);
+ client.getHabbo().getRoomUnit().walkTo(boxLocation);
- room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().setGoalLocation(boxLocation));
+ room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().walkTo(boxLocation));
});
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java
index 0ec3ce19..150c90ef 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionPyramid.java
@@ -4,6 +4,8 @@ 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.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -15,20 +17,26 @@ public class InteractionPyramid extends InteractionGate {
super(set, baseItem);
}
- public InteractionPyramid(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPyramid(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public void change(Room room) {
- if (!(this.getExtradata().equals("0") || this.getExtradata().equals("1")))
- this.setExtradata("0");
+ if (!(this.getExtraData().equals("0") || this.getExtraData().equals("1")))
+ this.setExtraData("0");
if (room != null) {
- if (room.getHabbosAt(this.getX(), this.getY()).isEmpty()) {
- int state = Integer.parseInt(this.getExtradata());
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+
+ if(tile == null) {
+ return;
+ }
+
+ if (!room.getRoomUnitManager().hasHabbosAt(tile)) {
+ int state = Integer.parseInt(this.getExtraData());
state = Math.abs(state - 1);
- this.setExtradata(state + "");
+ this.setExtraData(state + "");
room.updateItemState(this);
this.nextChange = Emulator.getIntUnixTimestamp() + 1 + (Emulator.getRandom().nextInt(Emulator.getConfig().getInt("pyramids.max.delay")));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java
index 2178ccef..7a4e42c2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRandomState.java
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.RandomStateParams;
import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,28 +14,28 @@ public class InteractionRandomState extends InteractionDefault {
super(set, baseItem);
}
- public InteractionRandomState(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRandomState(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
- this.setExtradata("");
+ this.setExtraData("");
room.updateItemState(this);
}
public void onRandomStateClick(Room room) throws Exception {
RandomStateParams params = new RandomStateParams(this.getBaseItem().getCustomParams());
- this.setExtradata("");
+ this.setExtraData("");
room.updateItemState(this);
int randomState = Emulator.getRandom().nextInt(params.getStates()) + 1;
Emulator.getThreading().run(() -> {
- this.setExtradata(randomState + "");
+ this.setExtraData(randomState + "");
room.updateItemState(this);
}, params.getDelay());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java
index 250d7504..95c2f938 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRedeemableSubscriptionBox.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,8 +11,8 @@ public class InteractionRedeemableSubscriptionBox extends InteractionCrackable {
super(set, baseItem);
}
- public InteractionRedeemableSubscriptionBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRedeemableSubscriptionBox(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public boolean userRequiredToBeAdjacent() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
index 73e4053c..99af029c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRentableSpace.java
@@ -5,9 +5,10 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.rentablespaces.RentableSpaceStatusMessageComposer;
import com.eu.habbo.threading.runnables.ClearRentedSpace;
@@ -21,7 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
@Slf4j
-public class InteractionRentableSpace extends HabboItem {
+public class InteractionRentableSpace extends RoomItem {
private int renterId;
private String renterName;
@@ -57,8 +58,8 @@ public class InteractionRentableSpace extends HabboItem {
}
}
} else {
- if (this.getRoomId() > 0) {
- Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId())));
+ if (this.getRoom() != null) {
+ Emulator.getThreading().run(new ClearRentedSpace(this, Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId())));
this.renterId = 0;
}
}
@@ -66,23 +67,23 @@ public class InteractionRentableSpace extends HabboItem {
}
}
- public InteractionRentableSpace(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRentableSpace(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.renterName = "";
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- if (this.getExtradata().isEmpty())
+ if (this.getExtraData().isEmpty())
return false;
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null)
return true;
- if (habbo.getHabboInfo().getId() == room.getId())
+ if (habbo.getHabboInfo().getId() == room.getRoomInfo().getId())
return true;
if (this.endTimestamp > Emulator.getIntUnixTimestamp()) {
@@ -109,8 +110,8 @@ public class InteractionRentableSpace extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
- if (this.getExtradata().isEmpty())
- this.setExtradata("0:0");
+ if (this.getExtraData().isEmpty())
+ this.setExtraData("0:0");
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
@@ -144,30 +145,30 @@ public class InteractionRentableSpace extends HabboItem {
habbo.getHabboStats().setRentedItemId(this.getId());
habbo.getHabboStats().setRentedTimeEnd(this.endTimestamp);
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
this.run();
}
public void endRent() {
this.setEndTimestamp(0);
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = this.getRoom();
if (room == null)
return;
- Rectangle rect = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
+ Rectangle rect = RoomLayout.getRectangle(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
- THashSet items = new THashSet<>();
+ THashSet items = new THashSet<>();
for (int i = rect.x; i < rect.x + rect.getWidth(); i++) {
for (int j = rect.y; j < rect.y + rect.getHeight(); j++) {
- items.addAll(room.getItemsAt(i, j, this.getZ()));
+ items.addAll(room.getRoomItemManager().getItemsAt(i, j, this.getCurrentZ()));
}
}
- for (HabboItem item : items) {
- if (item.getUserId() == this.renterId) {
- room.pickUpItem(item, null);
+ for (RoomItem item : items) {
+ if (item.getOwnerInfo().getId() == this.renterId) {
+ room.getRoomItemManager().pickUpItem(item, null);
}
}
@@ -191,12 +192,12 @@ public class InteractionRentableSpace extends HabboItem {
this.setRenterId(0);
this.setRenterName("");
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
this.run();
}
@Override
- public String getExtradata() {
+ public String getExtraData() {
return this.renterId + ":" + this.endTimestamp;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
index c2e7ea41..d146d843 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoller.java
@@ -4,8 +4,9 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@@ -14,24 +15,24 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-public class InteractionRoller extends HabboItem {
+public class InteractionRoller extends RoomItem {
public static boolean NO_RULES = false;
public static final int DELAY = 400;
public InteractionRoller(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionRoller(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionRoller(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -68,11 +69,11 @@ public class InteractionRoller extends HabboItem {
@Override
- public boolean canStackAt(Room room, List>> itemsAtLocation) {
+ public boolean canStackAt(List>> itemsAtLocation) {
if (NO_RULES) return true;
if (itemsAtLocation.isEmpty()) return false;
- for (Pair> set : itemsAtLocation) {
+ for (Pair> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) {
if (set.getValue().size() > 1) {
return false;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
index 3a977194..3b6329ea 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
@@ -2,7 +2,8 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
@@ -22,8 +23,8 @@ public class InteractionRoomAds extends InteractionCustomValues {
super(set, baseItem, defaultValues);
}
- public InteractionRoomAds(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
+ public InteractionRoomAds(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java
similarity index 73%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java
index fe76c514..808f26a1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubGate.java
@@ -5,23 +5,24 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.interfaces.ConditionalGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer;
import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionHabboClubGate extends InteractionDefault implements ConditionalGate {
- public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
+public class InteractionRoomClubGate extends InteractionDefault implements ConditionalGate {
+ public InteractionRoomClubGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionHabboClubGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionRoomClubGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -31,7 +32,7 @@ public class InteractionHabboClubGate extends InteractionDefault implements Cond
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
return habbo != null && habbo.getHabboStats().hasActiveClub();
}
@@ -41,7 +42,7 @@ public class InteractionHabboClubGate extends InteractionDefault implements Cond
super.onWalkOn(roomUnit, room, objects);
if (this.canWalkOn(roomUnit, room, objects)) {
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
}
}
@@ -69,7 +70,7 @@ public class InteractionHabboClubGate extends InteractionDefault implements Cond
if (roomUnit == null || room == null)
return;
- room.getHabbo(roomUnit).getClient().sendResponse(
+ room.getRoomUnitManager().getHabboByRoomUnit(roomUnit).getClient().sendResponse(
new CustomUserNotificationMessageComposer(CustomUserNotificationMessageComposer.GATE_NO_HC)
);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java
similarity index 71%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java
index e4b03e71..0ebcc7e7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubHopper.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubHopper.java
@@ -4,18 +4,19 @@ 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.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.generic.alerts.CustomUserNotificationMessageComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionHabboClubHopper extends InteractionHopper {
- public InteractionHabboClubHopper(ResultSet set, Item baseItem) throws SQLException {
+public class InteractionRoomClubHopper extends InteractionHopper {
+ public InteractionRoomClubHopper(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionHabboClubHopper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRoomClubHopper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java
similarity index 56%
rename from src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java
rename to src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java
index 9d1bfb1b..e6e940b6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubTeleportTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomClubTeleportTile.java
@@ -3,24 +3,25 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionHabboClubTeleportTile extends InteractionTeleportTile {
- public InteractionHabboClubTeleportTile(ResultSet set, Item baseItem) throws SQLException {
+public class InteractionRoomClubTeleportTile extends InteractionTeleportTile {
+ public InteractionRoomClubTeleportTile(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionHabboClubTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRoomClubTeleportTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboStats().hasActiveClub();
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java
index 8384d916..65f58760 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomOMatic.java
@@ -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.users.HabboInfo;
import com.eu.habbo.messages.outgoing.navigator.NoOwnedRoomsAlertMessageComposer;
import java.sql.ResultSet;
@@ -13,8 +14,8 @@ public class InteractionRoomOMatic extends InteractionDefault {
super(set, baseItem);
}
- public InteractionRoomOMatic(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionRoomOMatic(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java
index 987bea3a..fe64e06e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSnowboardSlope.java
@@ -7,9 +7,10 @@ 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.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.awt.*;
@@ -17,8 +18,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionSnowboardSlope extends InteractionMultiHeight {
- public InteractionSnowboardSlope(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionSnowboardSlope(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public InteractionSnowboardSlope(ResultSet set, Item baseItem) throws SQLException {
@@ -26,42 +27,38 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
}
@Override
- public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- room.giveEffect(roomUnit, 97, -1);
+ public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
+ super.onWalkOn(roomUnit, room, objects);
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
-
- if (roomUnit.getEffectId() == 97) {
- room.giveEffect(roomUnit, 0, -1);
- }
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
- THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class);
+ THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class);
Achievement snowboardBuild = Emulator.getGameEnvironment().getAchievementManager().getAchievement("snowBoardBuild");
if (snowboardBuild == null) return;
int progress;
- Habbo habbo = room.getHabbo(room.getOwnerId());
+ Habbo habbo = room.getRoomUnitManager().getRoomHabboById(room.getRoomInfo().getOwnerInfo().getId());
if (habbo != null) {
progress = habbo.getHabboStats().getAchievementProgress(snowboardBuild);
} else {
- progress = AchievementManager.getAchievementProgressForHabbo(room.getOwnerId(), snowboardBuild);
+ progress = AchievementManager.getAchievementProgressForHabbo(room.getRoomInfo().getOwnerInfo().getId(), snowboardBuild);
}
progress = Math.max(items.size() - progress, 0);
if (progress > 0) {
- AchievementManager.progressAchievement(room.getOwnerId(), snowboardBuild);
+ AchievementManager.progressAchievement(room.getRoomInfo().getOwnerInfo().getId(), snowboardBuild);
}
}
@@ -69,7 +66,7 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
public void onPickUp(Room room) {
for (Habbo habbo : room.getHabbosOnItem(this)) {
if (habbo.getRoomUnit().getEffectId() == 97) {
- room.giveEffect(habbo, 0, -1);
+ habbo.getRoomUnit().giveEffect(0, -1);
}
}
}
@@ -79,8 +76,8 @@ public class InteractionSnowboardSlope extends InteractionMultiHeight {
Rectangle newRect = RoomLayout.getRectangle(newLocation.getX(), newLocation.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
for (Habbo habbo : room.getHabbosOnItem(this)) {
- if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().getX(), habbo.getRoomUnit().getCurrentLocation().getY())) {
- room.giveEffect(habbo, 0, -1);
+ if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentPosition().getX(), habbo.getRoomUnit().getCurrentPosition().getY())) {
+ habbo.getRoomUnit().giveEffect(0, -1);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java
index e3e62bbb..e1e21051 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSpinningBottle.java
@@ -5,8 +5,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.plugin.events.furniture.FurnitureDiceRolledEvent;
import com.eu.habbo.threading.runnables.RandomSpinningBottleNumber;
@@ -14,9 +15,9 @@ import com.eu.habbo.threading.runnables.RandomSpinningBottleNumber;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionSpinningBottle extends HabboItem {
- public InteractionSpinningBottle(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+public class InteractionSpinningBottle extends RoomItem {
+ public InteractionSpinningBottle(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public InteractionSpinningBottle(ResultSet set, Item baseItem) throws SQLException {
@@ -26,7 +27,7 @@ public class InteractionSpinningBottle extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -46,14 +47,14 @@ public class InteractionSpinningBottle extends HabboItem {
super.onClick(client, room, objects);
if (client != null) {
- if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) {
- if (!this.getExtradata().equalsIgnoreCase("-1")) {
+ if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), client.getHabbo().getRoomUnit().getCurrentPosition())) {
+ if (!this.getExtraData().equalsIgnoreCase("-1")) {
FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1));
if (event.isCancelled())
return;
- this.setExtradata("-1");
+ this.setExtraData("-1");
room.updateItemState(this);
Emulator.getThreading().run(this);
@@ -74,7 +75,7 @@ public class InteractionSpinningBottle extends HabboItem {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java
index 669a5a69..71557ba1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStackHelper.java
@@ -2,20 +2,21 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionStackHelper extends HabboItem {
+public class InteractionStackHelper extends RoomItem {
public InteractionStackHelper(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionStackHelper(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionStackHelper(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -36,7 +37,7 @@ public class InteractionStackHelper extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java
index cd434e5f..96024d2f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionStickyPole.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,7 +11,7 @@ public class InteractionStickyPole extends InteractionDefault {
super(set, baseItem);
}
- public InteractionStickyPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionStickyPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
index e1761878..8fb08d3d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitch.java
@@ -7,6 +7,7 @@ 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.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import java.sql.ResultSet;
@@ -19,13 +20,13 @@ public class InteractionSwitch extends InteractionDefault {
super(set, baseItem);
}
- public InteractionSwitch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionSwitch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canToggle(Habbo habbo, Room room) {
- return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation());
+ return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition());
}
@Override
@@ -45,13 +46,13 @@ public class InteractionSwitch extends InteractionDefault {
if (!this.canToggle(client.getHabbo(), room)) {
RoomTile closestTile = null;
- for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
- if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
+ for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) {
+ if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) {
closestTile = tile;
}
}
- if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
+ if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) {
List onSuccess = new ArrayList<>();
onSuccess.add(() -> {
try {
@@ -61,7 +62,7 @@ public class InteractionSwitch extends InteractionDefault {
}
});
- client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
+ client.getHabbo().getRoomUnit().walkTo(closestTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java
index 37fbce36..3a013ce7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionSwitchRemoteControl.java
@@ -5,6 +5,7 @@ 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.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import lombok.extern.slf4j.Slf4j;
import java.sql.ResultSet;
@@ -16,13 +17,13 @@ public class InteractionSwitchRemoteControl extends InteractionDefault {
super(set, baseItem);
}
- public InteractionSwitchRemoteControl(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionSwitchRemoteControl(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canToggle(Habbo habbo, Room room) {
- return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation());
+ return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition());
}
@Override
@@ -40,20 +41,20 @@ public class InteractionSwitchRemoteControl extends InteractionDefault {
if (room != null) {
super.onClick(client, room, objects);
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
if (this.getBaseItem().getStateCount() > 0) {
int currentState = 0;
try {
- currentState = Integer.parseInt(this.getExtradata());
+ currentState = Integer.parseInt(this.getExtraData());
} catch (NumberFormatException e) {
- log.error("Incorrect extradata (" + this.getExtradata() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
+ log.error("Incorrect extradata (" + this.getExtraData() + ") for item ID (" + this.getId() + ") of type (" + this.getBaseItem().getName() + ")");
}
- this.setExtradata("" + (currentState + 1) % this.getBaseItem().getStateCount());
- this.needsUpdate(true);
+ this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount());
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java
index c958a9d4..6d7be0ce 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTalkingFurniture.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,7 +11,7 @@ public class InteractionTalkingFurniture extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTalkingFurniture(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTalkingFurniture(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
index 5e152373..b4313254 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
@@ -5,9 +5,11 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import com.eu.habbo.threading.runnables.teleport.TeleportActionOne;
@@ -17,7 +19,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class InteractionTeleport extends HabboItem {
+public class InteractionTeleport extends RoomItem {
private int targetId;
private int targetRoomId;
private int roomUnitID = -1;
@@ -26,26 +28,26 @@ public class InteractionTeleport extends HabboItem {
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
walkable = baseItem.allowWalk();
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTeleport(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
walkable = item.allowWalk();
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return this.getBaseItem().allowWalk() || roomUnit.getId() == this.roomUnitID;
+ return this.getBaseItem().allowWalk() || roomUnit.getVirtualId() == this.roomUnitID;
}
@Override
@@ -62,67 +64,73 @@ public class InteractionTeleport extends HabboItem {
Habbo habbo = client.getHabbo();
- if (habbo == null)
+ if (habbo == null) {
return;
+ }
- RoomUnit unit = habbo.getRoomUnit();
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
- if (unit == null)
+ if (roomHabbo == null) {
return;
+ }
- RoomTile currentLocation = room.getLayout().getTile(this.getX(), this.getY());
+ RoomTile currentItemLocation = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
- if (currentLocation == null)
+ if (currentItemLocation == null) {
return;
+ }
- RoomTile infrontTile = room.getLayout().getTileInFront(currentLocation, this.getRotation());
+ RoomTile inFrontTile = room.getLayout().getTileInFront(currentItemLocation, this.getRotation());
- if (!canUseTeleport(client, room))
+ if (!canUseTeleport(client, room)) {
return;
+ }
- if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
- startTeleport(room, habbo);
- walkable = true;
+ if (this.roomUnitID == roomHabbo.getVirtualId() && roomHabbo.getCurrentPosition().equals(currentItemLocation)) {
+ this.startTeleport(room, habbo);
+ this.walkable = true;
try {
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
} catch (Exception e) {
e.printStackTrace();
}
- } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
+ } else if (roomHabbo.getCurrentPosition().equals(currentItemLocation) || roomHabbo.getCurrentPosition().equals(inFrontTile)) {
// set state 1 and walk on item
- this.roomUnitID = unit.getId();
- this.setExtradata("1");
+ this.roomUnitID = roomHabbo.getVirtualId();
+ this.setExtraData("1");
room.updateItemState(this);
- unit.setGoalLocation(infrontTile);
+ roomHabbo.walkTo(inFrontTile);
List onSuccess = new ArrayList<>();
List onFail = new ArrayList<>();
onSuccess.add(() -> {
- room.updateTile(currentLocation);
- tryTeleport(client, room);
- unit.removeOverrideTile(currentLocation);
- unit.setCanLeaveRoomByDoor(true);
- walkable = this.getBaseItem().allowWalk();
+ room.updateTile(currentItemLocation);
+ this.tryTeleport(client, room);
+ roomHabbo.removeOverrideTile(currentItemLocation);
+ roomHabbo.setCanLeaveRoomByDoor(true);
+ this.walkable = this.getBaseItem().allowWalk();
});
onFail.add(() -> {
- walkable = this.getBaseItem().allowWalk();
- room.updateTile(currentLocation);
- this.setExtradata("0");
+ this.walkable = this.getBaseItem().allowWalk();
+ room.updateTile(currentItemLocation);
+ this.setExtraData("0");
room.updateItemState(this);
this.roomUnitID = -1;
- unit.removeOverrideTile(currentLocation);
- unit.setCanLeaveRoomByDoor(true);
+ roomHabbo.removeOverrideTile(currentItemLocation);
+ roomHabbo.setCanLeaveRoomByDoor(true);
});
- walkable = true;
- room.updateTile(currentLocation);
- unit.addOverrideTile(currentLocation);
- unit.setGoalLocation(currentLocation);
- unit.setCanLeaveRoomByDoor(false);
- Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
+ this.walkable = true;
+
+ room.updateTile(currentItemLocation);
+ roomHabbo.addOverrideTile(currentItemLocation);
+ roomHabbo.walkTo(currentItemLocation);
+ roomHabbo.setCanLeaveRoomByDoor(false);
+
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, currentItemLocation, room, onSuccess, onFail));
} else {
// walk to teleport and interact
List onSuccess = new ArrayList<>();
@@ -130,8 +138,8 @@ public class InteractionTeleport extends HabboItem {
onSuccess.add(() -> tryTeleport(client, room));
- unit.setGoalLocation(infrontTile);
- Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, infrontTile, room, onSuccess, onFail));
+ roomHabbo.walkTo(inFrontTile);
+ Emulator.getThreading().run(new RoomUnitWalkToLocation(roomHabbo, inFrontTile, room, onSuccess, onFail));
}
}
@@ -148,10 +156,10 @@ public class InteractionTeleport extends HabboItem {
@Override
public void run() {
- if (!this.getExtradata().equals("0")) {
- this.setExtradata("0");
+ if (!this.getExtraData().equals("0")) {
+ this.setExtraData("0");
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room != null) {
room.updateItem(this);
}
@@ -164,7 +172,7 @@ public class InteractionTeleport extends HabboItem {
this.targetId = 0;
this.targetRoomId = 0;
this.roomUnitID = -1;
- this.setExtradata("0");
+ this.setExtraData("0");
}
public int getTargetId() {
@@ -192,15 +200,17 @@ public class InteractionTeleport extends HabboItem {
Habbo habbo = client.getHabbo();
- if (habbo == null)
+ if (habbo == null) {
return false;
+ }
- RoomUnit unit = habbo.getRoomUnit();
+ RoomHabbo roomHabbo = habbo.getRoomUnit();
- if (unit == null)
+ if (roomHabbo == null) {
return false;
+ }
- return habbo.getHabboInfo().getRiding() == null;
+ return !roomHabbo.isRiding();
}
public void startTeleport(Room room, Habbo habbo) {
@@ -209,7 +219,7 @@ public class InteractionTeleport extends HabboItem {
public void startTeleport(Room room, Habbo habbo, int delay) {
if (habbo.getRoomUnit().isTeleporting()) {
- walkable = this.getBaseItem().allowWalk();
+ this.walkable = this.getBaseItem().allowWalk();
return;
}
@@ -222,9 +232,4 @@ public class InteractionTeleport extends HabboItem {
public boolean isUsable() {
return true;
}
-
- @Override
- public boolean invalidatesToRoomKick() {
- return true;
- }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java
index e8b90bbf..74aaed4f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleportTile.java
@@ -2,8 +2,9 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,8 +14,8 @@ public class InteractionTeleportTile extends InteractionTeleport {
super(set, baseItem);
}
- public InteractionTeleportTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTeleportTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -30,14 +31,14 @@ public class InteractionTeleportTile extends InteractionTeleport {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
if (roomUnit != null && this.canWalkOn(roomUnit, room, objects)) {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (!canUseTeleport(habbo.getClient(), room))
return;
if (!habbo.getRoomUnit().isTeleporting()) {
- habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation());
+ habbo.getRoomUnit().walkTo(habbo.getRoomUnit().getCurrentPosition());
this.startTeleport(room, habbo, 1000);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
index e295e4b2..fb2653ba 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTent.java
@@ -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.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -12,8 +13,8 @@ public class InteractionTent extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTent(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTent(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
index b8c1d313..f6cc49e0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
@@ -3,7 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions;
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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
@@ -19,8 +21,8 @@ public class InteractionTileEffectProvider extends InteractionCustomValues {
super(set, baseItem, defaultValues);
}
- public InteractionTileEffectProvider(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
+ public InteractionTileEffectProvider(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, defaultValues);
}
@Override
@@ -37,9 +39,13 @@ public class InteractionTileEffectProvider extends InteractionCustomValues {
public void onWalkOn(RoomUnit roomUnit, final Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
+ if(!(roomUnit instanceof RoomHabbo roomHabbo)) {
+ return;
+ }
+
int effectId = Integer.parseInt(this.values.get("effectId"));
- if (roomUnit.getEffectId() == effectId) {
+ if (roomHabbo.getEffectId() == effectId) {
effectId = 0;
}
@@ -52,6 +58,6 @@ public class InteractionTileEffectProvider extends InteractionCustomValues {
room.updateItem(proxy);
}, 500);
- room.giveEffect(roomUnit, effectId, -1);
+ roomHabbo.giveEffect(effectId, -1);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
index 1ea1eb16..66bac372 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrap.java
@@ -3,10 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions;
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.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -16,15 +17,15 @@ public class InteractionTrap extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTrap(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTrap(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
- if (this.getExtradata().equals("0") || roomUnit == null || room.getHabbo(roomUnit) == null) return;
+ if (this.getExtraData().equals("0") || roomUnit == null || room.getRoomUnitManager().getHabboByRoomUnit(roomUnit) == null) return;
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId();
roomUnit.stopWalking();
super.onWalkOn(roomUnit, room, objects);
@@ -35,24 +36,24 @@ public class InteractionTrap extends InteractionDefault {
}
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
- if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
+ if (roomUnit instanceof RoomHabbo roomHabbo) {
- if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
- room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
+ if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectM()) {
+ roomHabbo.giveEffect(this.getBaseItem().getEffectM(), -1);
return;
}
- if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
- room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
+ if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomHabbo.getEffectId() != this.getBaseItem().getEffectF()) {
+ roomHabbo.giveEffect(this.getBaseItem().getEffectF(), -1);
return;
}
- roomUnit.setCanWalk(false);
+ roomHabbo.setCanWalk(false);
Emulator.getThreading().run(() -> {
- room.giveEffect(roomUnit, 0, -1);
+ roomHabbo.giveEffect(0, -1);
roomUnit.setCanWalk(true);
- room.giveEffect(roomUnit, effect, -1);
+ roomHabbo.giveEffect(effect, -1);
}, delay);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
index 80f2c39c..6a9f93c4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTrophy.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -10,8 +11,8 @@ public class InteractionTrophy extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTrophy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTrophy(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
index 6bccfc83..72c7d8f9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVendingMachine.java
@@ -3,9 +3,16 @@ package com.eu.habbo.habbohotel.items.interactions;
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.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
@@ -17,15 +24,15 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class InteractionVendingMachine extends HabboItem {
+public class InteractionVendingMachine extends RoomItem {
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionVendingMachine(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
public THashSet getActivatorTiles(Room room) {
@@ -35,14 +42,14 @@ public class InteractionVendingMachine extends HabboItem {
if (tileInFront != null)
tiles.add(tileInFront);
- tiles.add(room.getLayout().getTile(this.getX(), this.getY()));
+ tiles.add(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
return tiles;
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -56,7 +63,7 @@ public class InteractionVendingMachine extends HabboItem {
boolean inActivatorSpace = false;
for(RoomTile ignored : activatorTiles) {
- if(unit.getCurrentLocation().is(unit.getX(), unit.getY())) {
+ if(unit.getCurrentPosition().is(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY())) {
inActivatorSpace = true;
}
}
@@ -67,7 +74,11 @@ public class InteractionVendingMachine extends HabboItem {
}
private void useVendingMachine(GameClient client, Room room, RoomUnit unit) {
- this.setExtradata("1");
+ if(!(unit instanceof RoomAvatar roomAvatar)) {
+ return;
+ }
+
+ this.setExtraData("1");
room.updateItem(this);
try {
@@ -76,25 +87,25 @@ public class InteractionVendingMachine extends HabboItem {
e.printStackTrace();
}
- if(!unit.isWalking() && !unit.hasStatus(RoomUnitStatus.SIT) && !unit.hasStatus(RoomUnitStatus.LAY)) {
- this.rotateToMachine(unit);
+ if(!roomAvatar.isWalking() && !roomAvatar.hasStatus(RoomUnitStatus.SIT) && !roomAvatar.hasStatus(RoomUnitStatus.LAY)) {
+ this.rotateToMachine(roomAvatar);
}
Emulator.getThreading().run(() -> {
- giveVendingMachineItem(room, unit);
+ giveVendingMachineItem(room, roomAvatar);
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
+ client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectM(), -1);
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+ client.getHabbo().getRoomUnit().giveEffect(this.getBaseItem().getEffectF(), -1);
Emulator.getThreading().run(this, 500);
}, 1500);
}
- public void giveVendingMachineItem(Room room, RoomUnit unit) {
- Emulator.getThreading().run(new RoomUnitGiveHanditem(unit, room, this.getBaseItem().getRandomVendingItem()));
+ public void giveVendingMachineItem(Room room, RoomAvatar roomAvatar) {
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(roomAvatar, room, this.getBaseItem().getRandomVendingItem()));
}
@Override
@@ -113,7 +124,7 @@ public class InteractionVendingMachine extends HabboItem {
boolean inActivatorSpace = false;
for(RoomTile tile : activatorTiles) {
- if(unit.getCurrentLocation().is(tile.getX(), tile.getY())) {
+ if(unit.getCurrentPosition().is(tile.getX(), tile.getY())) {
inActivatorSpace = true;
}
}
@@ -121,7 +132,7 @@ public class InteractionVendingMachine extends HabboItem {
if(!inActivatorSpace) {
RoomTile tileToWalkTo = null;
for(RoomTile tile : activatorTiles) {
- if((tile.getState() == RoomTileState.OPEN || tile.getState() == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) {
+ if((tile.getState() == RoomTileState.OPEN || tile.getState() == RoomTileState.SIT) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentPosition()) > tile.distance(unit.getCurrentPosition()))) {
tileToWalkTo = tile;
}
}
@@ -132,7 +143,7 @@ public class InteractionVendingMachine extends HabboItem {
onSuccess.add(() -> tryInteract(client, room, unit));
- unit.setGoalLocation(tileToWalkTo);
+ unit.walkTo(tileToWalkTo);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail));
}
}
@@ -149,9 +160,9 @@ public class InteractionVendingMachine extends HabboItem {
@Override
public void run() {
super.run();
- if (this.getExtradata().equals("1")) {
- this.setExtradata("0");
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ if (this.getExtraData().equals("1")) {
+ this.setExtraData("0");
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room != null) {
room.updateItem(this);
}
@@ -174,11 +185,11 @@ public class InteractionVendingMachine extends HabboItem {
}
private void rotateToMachine(RoomUnit unit) {
- RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
+ RoomRotation rotation = RoomRotation.values()[Rotation.Calculate(unit.getCurrentPosition().getX(), unit.getCurrentPosition().getY(), this.getCurrentPosition().getX(), this.getCurrentPosition().getY())];
if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) {
unit.setRotation(rotation);
- unit.statusUpdate(true);
+ unit.setStatusUpdateNeeded(true);
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java
index b79a675b..43b095e9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVikingCotie.java
@@ -5,6 +5,7 @@ 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.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,23 +15,23 @@ public class InteractionVikingCotie extends InteractionDefault {
super(set, baseItem);
}
- public InteractionVikingCotie(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionVikingCotie(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (this.getExtradata().isEmpty()) {
- this.setExtradata("0");
+ if (this.getExtraData().isEmpty()) {
+ this.setExtraData("0");
}
- if (client != null && client.getHabbo().getHabboInfo().getId() == this.getUserId()) {
+ if (client != null && client.getHabbo().getHabboInfo().getId() == this.getOwnerInfo().getId()) {
if (client.getHabbo().getRoomUnit().getEffectId() == 172 || client.getHabbo().getRoomUnit().getEffectId() == 173) {
- int state = Integer.parseInt(this.getExtradata());
+ int state = Integer.parseInt(this.getExtraData());
if (state < 5) {
state++;
- this.setExtradata(state + "");
+ this.setExtraData(state + "");
room.updateItem(this);
if (state == 5) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java
index a28b30b4..71fa2071 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java
@@ -3,8 +3,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
@@ -13,7 +14,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
-public class InteractionVoteCounter extends HabboItem {
+public class InteractionVoteCounter extends RoomItem {
private boolean frozen;
private int votes;
@@ -21,18 +22,18 @@ public class InteractionVoteCounter extends HabboItem {
public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- if(!this.getExtradata().contains(",")) {
- this.setExtradata("1,0"); // frozen,votes
+ if(!this.getExtraData().contains(",")) {
+ this.setExtraData("1,0"); // frozen,votes
}
- String[] bits = this.getExtradata().split(",");
+ String[] bits = this.getExtraData().split(",");
frozen = bits[0].equals("1");
votes = Integer.parseInt(bits[1]);
votedUsers = new ArrayList<>();
}
- public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionVoteCounter(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
if(!extradata.contains(",")) {
extradata = "1,0";
@@ -63,12 +64,12 @@ public class InteractionVoteCounter extends HabboItem {
}
private void updateExtradata() {
- this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes);
+ this.setExtraData((this.frozen ? "1" : "0") + "," + this.votes);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
return;
this.frozen = !this.frozen;
@@ -79,7 +80,7 @@ public class InteractionVoteCounter extends HabboItem {
}
updateExtradata();
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
}
@@ -99,7 +100,7 @@ public class InteractionVoteCounter extends HabboItem {
votes += vote;
updateExtradata();
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
index 062e4034..eb779f16 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java
@@ -3,9 +3,15 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.pets.Pet;
-import com.eu.habbo.habbohotel.rooms.*;
+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.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@@ -27,8 +33,8 @@ public class InteractionWater extends InteractionDefault {
this.isInRoom = this.getRoomId() != 0;
}
- public InteractionWater(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionWater(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.isDeepWater = false;
this.isInRoom = this.getRoomId() != 0;
}
@@ -78,13 +84,13 @@ public class InteractionWater extends InteractionDefault {
if(roomUnit == null) return;
roomUnit.setSwimming(true);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet == null)
return;
if (!pet.getRoomUnit().hasStatus(RoomUnitStatus.SWIM) && pet.getPetData().isCanSwim()) {
- pet.getRoomUnit().setStatus(RoomUnitStatus.SWIM, "");
+ pet.getRoomUnit().addStatus(RoomUnitStatus.SWIM, "");
}
}
@@ -95,7 +101,7 @@ public class InteractionWater extends InteractionDefault {
super.onWalkOff(roomUnit, room, objects);
if ( roomUnit.getRoomUnitType() != RoomUnitType.PET) return;
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet == null) return;
@@ -113,22 +119,22 @@ public class InteractionWater extends InteractionDefault {
}
@Override
- public boolean canStackAt(Room room, List>> itemsAtLocation) {
- for (Pair> set : itemsAtLocation) {
- for (HabboItem item : set.getValue()) {
+ public boolean canStackAt(List>> itemsAtLocation) {
+ for (Pair> set : itemsAtLocation) {
+ for (RoomItem item : set.getValue()) {
if(item != this)
return false;
}
}
- return super.canStackAt(room, itemsAtLocation);
+ return super.canStackAt(itemsAtLocation);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
if (!super.canWalkOn(roomUnit, room, objects)) return false;
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
return pet == null || pet.getPetData().isCanSwim();
}
@@ -151,7 +157,7 @@ public class InteractionWater extends InteractionDefault {
}
// Update neighbouring water.
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) {
+ for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWater.class)) {
// We already updated ourself.
if (item == this) {
continue;
@@ -168,7 +174,7 @@ public class InteractionWater extends InteractionDefault {
// Update water items we might have missed in the old location.
if (targetOld != null) {
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
+ for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
if (targetOld.intersects(item.getRectangle())) {
((InteractionWaterItem) item).update();
}
@@ -180,7 +186,7 @@ public class InteractionWater extends InteractionDefault {
Rectangle target = this.getRectangle();
// Only update water item furnis that are intersecting with us.
- for (HabboItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
+ for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionWaterItem.class)) {
if (target.intersects(item.getRectangle())) {
((InteractionWaterItem) item).update();
}
@@ -201,55 +207,63 @@ public class InteractionWater extends InteractionDefault {
byte _12 = 0;
// Check if we are touching a water tile.
- if (this.isValidForMask(room, this.getX() - 1, this.getY() - 1, this.getZ(), true)) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() - 1, this.getCurrentZ(), true)) {
_1 = 1;
}
- if (this.isValidForMask(room, this.getX(), this.getY() - 1, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX(), this.getCurrentPosition().getY() - 1, this.getCurrentZ())) {
_2 = 1;
}
- if (this.isValidForMask(room, this.getX() + 1, this.getY() - 1, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 1, this.getCurrentPosition().getY() - 1, this.getCurrentZ())) {
_3 = 1;
}
- if (this.isValidForMask(room, this.getX() + 2, this.getY() - 1, this.getZ(), true)) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() - 1, this.getCurrentZ(), true)) {
_4 = 1;
}
- if (this.isValidForMask(room, this.getX() - 1, this.getY(), this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY(), this.getCurrentZ())) {
_5 = 1;
}
- if (this.isValidForMask(room, this.getX() + 2, this.getY(), this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY(), this.getCurrentZ())) {
_6 = 1;
}
- if (this.isValidForMask(room, this.getX() - 1, this.getY() + 1, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() + 1, this.getCurrentZ())) {
_7 = 1;
}
- if (this.isValidForMask(room, this.getX() + 2, this.getY() + 1, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() + 1, this.getCurrentZ())) {
_8 = 1;
}
- if (this.isValidForMask(room, this.getX() - 1, this.getY() + 2, this.getZ(), true)) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() - 1, this.getCurrentPosition().getY() + 2, this.getCurrentZ(), true)) {
_9 = 1;
}
- if (this.isValidForMask(room, this.getX(), this.getY() + 2, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX(), this.getCurrentPosition().getY() + 2, this.getCurrentZ())) {
_10 = 1;
}
- if (this.isValidForMask(room, this.getX() + 1, this.getY() + 2, this.getZ())) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 1, this.getCurrentPosition().getY() + 2, this.getCurrentZ())) {
_11 = 1;
}
- if (this.isValidForMask(room, this.getX() + 2, this.getY() + 2, this.getZ(), true)) {
+ if (this.isValidForMask(room, this.getCurrentPosition().getX() + 2, this.getCurrentPosition().getY() + 2, this.getCurrentZ(), true)) {
_12 = 1;
}
// Check if we are touching invalid tiles.
// if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1;
- if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1;
- if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1;
+ if (_2 == 0 && room.getLayout().isVoidTile(this.getCurrentPosition().getX(), (short) (this.getCurrentPosition().getY() - 1)))
+ _2 = 1;
+ if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 1), (short) (this.getCurrentPosition().getY() - 1)))
+ _3 = 1;
// if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1;
- if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1;
- if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1;
- if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1;
- if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1;
+ if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() - 1), this.getCurrentPosition().getY()))
+ _5 = 1;
+ if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 2), this.getCurrentPosition().getY()))
+ _6 = 1;
+ if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() - 1), (short) (this.getCurrentPosition().getY() + 1)))
+ _7 = 1;
+ if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 2), (short) (this.getCurrentPosition().getY() + 1)))
+ _8 = 1;
// if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1;
- if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1;
- if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1;
+ if (_10 == 0 && room.getLayout().isVoidTile(this.getCurrentPosition().getX(), (short) (this.getCurrentPosition().getY() + 2)))
+ _10 = 1;
+ if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getCurrentPosition().getX() + 1), (short) (this.getCurrentPosition().getY() + 2)))
+ _11 = 1;
// if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1;
// Update water.
@@ -268,9 +282,9 @@ public class InteractionWater extends InteractionDefault {
String updatedData = String.valueOf(result);
- if (!this.getExtradata().equals(updatedData)) {
- this.setExtradata(updatedData);
- this.needsUpdate(true);
+ if (!this.getExtraData().equals(updatedData)) {
+ this.setExtraData(updatedData);
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
}
}
@@ -280,7 +294,7 @@ public class InteractionWater extends InteractionDefault {
}
private boolean isValidForMask(Room room, int x, int y, double z, boolean corner) {
- for (HabboItem item : room.getItemsAt(x, y, z)) {
+ for (RoomItem item : room.getRoomItemManager().getItemsAt(x, y, z)) {
if (item instanceof InteractionWater water) {
// Take out picked up water from the recalculation.
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
index 404e1f32..95c6c138 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWaterItem.java
@@ -5,7 +5,8 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.awt.*;
@@ -17,8 +18,8 @@ public class InteractionWaterItem extends InteractionMultiHeight {
super(set, baseItem);
}
- public InteractionWaterItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionWaterItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -30,8 +31,8 @@ public class InteractionWaterItem extends InteractionMultiHeight {
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
- this.setExtradata("0");
- this.needsUpdate(true);
+ this.setExtraData("0");
+ this.setSqlUpdateNeeded(true);
}
@Override
@@ -46,7 +47,7 @@ public class InteractionWaterItem extends InteractionMultiHeight {
}
public void update() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room == null) {
return;
@@ -60,9 +61,10 @@ public class InteractionWaterItem extends InteractionMultiHeight {
for (short x = (short) rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++) {
for (short y = (short) rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++) {
boolean tile = false;
- THashSet items = room.getItemsAt(room.getLayout().getTile(x, y));
+ RoomTile tile1 = room.getLayout().getTile(x, y);
+ THashSet items = room.getRoomItemManager().getItemsAt(tile1);
- for (HabboItem item : items) {
+ for (RoomItem item : items) {
if (item instanceof InteractionWater) {
tile = true;
break;
@@ -78,9 +80,9 @@ public class InteractionWaterItem extends InteractionMultiHeight {
// Update data if changed.
String updatedData = foundWater ? "1" : "0";
- if (!this.getExtradata().equals(updatedData)) {
- this.setExtradata(updatedData);
- this.needsUpdate(true);
+ if (!this.getExtraData().equals(updatedData)) {
+ this.setExtraData(updatedData);
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
index 84838123..c0680ef6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWired.java
@@ -1,50 +1,160 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
+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.items.interactions.wired.interfaces.IWiredInteraction;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
-import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer;
+import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
+import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
+import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer;
+import com.fasterxml.jackson.core.JsonProcessingException;
import gnu.trove.map.hash.TLongLongHashMap;
+import lombok.Getter;
+import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
@Slf4j
-public abstract class InteractionWired extends InteractionDefault {
+public abstract class InteractionWired extends InteractionDefault implements IWiredInteraction {
+ @Getter
+ @Setter
+ private WiredSettings wiredSettings;
private long cooldown;
private final TLongLongHashMap userExecutionCache = new TLongLongHashMap(3);
- InteractionWired(ResultSet set, Item baseItem) throws SQLException {
+ public InteractionWired(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.wiredSettings = new WiredSettings();
+ this.setExtraData("0");
}
- InteractionWired(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ InteractionWired(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.wiredSettings = new WiredSettings();
+ this.setExtraData("0");
}
public abstract boolean execute(RoomUnit roomUnit, Room room, Object[] stuff);
- public abstract String getWiredData();
+ /**
+ * On Room Loading run this, get Wired Data from Database and save it into the item
+ *
+ * @param set
+ * @throws SQLException
+ */
+ public void loadWiredSettings(ResultSet set) throws SQLException, JsonProcessingException {
+ String wiredData = set.getString("wired_data");
+ this.wiredSettings = new WiredSettings();
- public abstract void serializeWiredData(ServerMessage message, Room room);
+ if(wiredData.startsWith("{")) {
+ this.wiredSettings = WiredHandler.getObjectMapper().readValue(wiredData, WiredSettings.class);
+ }
+ }
- public abstract void loadWiredData(ResultSet set, Room room) throws SQLException;
+ /**
+ *
+ * When double-clicking into the wired, verify items first and load its default parameters
+ * then create a composer based on it's Wired Settings
+ *
+ * @param client
+ * @param room
+ * @param objects
+ * @throws Exception
+ */
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ this.wiredSettings.getItems(room);
+ if (client != null) {
+ if (room.getRoomRightsManager().hasRights(client.getHabbo())) {
+ MessageComposer composer = null;
+ if(this instanceof InteractionWiredEffect) {
+ composer = new WiredEffectDataComposer((InteractionWiredEffect) this, room);
+ } else if(this instanceof InteractionWiredCondition) {
+ composer = new WiredConditionDataComposer((InteractionWiredCondition) this, room);
+ } else if(this instanceof InteractionWiredTrigger) {
+ composer = new WiredTriggerDataComposer((InteractionWiredTrigger) this, room);
+ }
+
+ client.sendResponse(composer);
+ this.activateBox(room);
+ }
+ }
+ }
+
+ /**
+ * When click save changes on the wired this executes, reads all the packet
+ * And updates wired current Wired Settings
+ *
+ * @param packet
+ */
+ public void saveWiredSettings(ClientMessage packet, Room room) {
+ int intParamCount = packet.readInt();
+ List integerParams = new ArrayList<>();
+
+ for(int i = 0; i < intParamCount; i++)
+ {
+ integerParams.add(packet.readInt());
+ }
+
+ this.wiredSettings.setIntegerParams(integerParams);
+ this.wiredSettings.setStringParam(packet.readString());
+
+ int itemCount = packet.readInt();
+ List itemIds = new ArrayList<>();
+
+ for(int i = 0; i < itemCount; i++)
+ {
+ itemIds.add(packet.readInt());
+ }
+
+ this.wiredSettings.setItemIds(itemIds);
+
+ if(this instanceof InteractionWiredEffect) {
+ this.wiredSettings.setDelay(packet.readInt());
+ }
+
+ this.wiredSettings.setSelectionType(packet.readInt());
+
+ saveAdditionalData(room);
+ }
+
+ /**
+ * This is executed on 3 different situations
+ * When finishing executing: `saveWiredSettings`, when placing this item on floor, and when picking it up.
+ * This what it does is converts Wired Settings into a JSON string
+ * and updates wired_data in the database
+ */
@Override
public void run() {
- if (this.needsUpdate()) {
- String wiredData = this.getWiredData();
+ if (this.isSqlUpdateNeeded()) {
+ //TODO HERE IS WHERE WIRED_SAVE_EXCEPTION WILL BE THROWN
+ //EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers
+ this.loadDefaultIntegerParams();
- if (wiredData == null) {
+ String wiredData;
+
+ try {
+ wiredData = WiredHandler.getObjectMapper().writeValueAsString(this.wiredSettings);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+
+ if(wiredData.equalsIgnoreCase("{}")) {
wiredData = "";
}
@@ -63,22 +173,28 @@ public abstract class InteractionWired extends InteractionDefault {
super.run();
}
+ /**
+ * When picking up the wired, all its settings are erased and updated in database
+ *
+ * @param room
+ */
@Override
public void onPickUp(Room room) {
- this.onPickUp();
+ this.wiredSettings.dispose();
}
- public abstract void onPickUp();
+ public void loadDefaultIntegerParams() {}
+ public void saveAdditionalData(Room room) {}
public void activateBox(Room room) {
this.activateBox(room, null, 0L);
}
public void activateBox(Room room, RoomUnit roomUnit, long millis) {
- this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
+ this.setExtraData(this.getExtraData().equals("1") ? "0" : "1");
room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose());
if (roomUnit != null) {
- this.addUserExecutionCache(roomUnit.getId(), millis);
+ this.addUserExecutionCache(roomUnit.getVirtualId(), millis);
}
}
@@ -86,7 +202,6 @@ public abstract class InteractionWired extends InteractionDefault {
return 50L;
}
-
public boolean canExecute(long newMillis) {
return newMillis - this.cooldown >= this.requiredCooldown();
}
@@ -111,7 +226,6 @@ public abstract class InteractionWired extends InteractionDefault {
long lastTimestamp = this.userExecutionCache.get(roomUnitId);
return timestamp - lastTimestamp >= 100L;
}
-
}
return true;
}
@@ -123,36 +237,4 @@ public abstract class InteractionWired extends InteractionDefault {
public void addUserExecutionCache(int roomUnitId, long timestamp) {
this.userExecutionCache.put(roomUnitId, timestamp);
}
-
- public static WiredSettings readSettings(ClientMessage packet, boolean isEffect)
- {
- int intParamCount = packet.readInt();
- int[] intParams = new int[intParamCount];
-
- for(int i = 0; i < intParamCount; i++)
- {
- intParams[i] = packet.readInt();
- }
-
- String stringParam = packet.readString();
-
- int itemCount = packet.readInt();
- int[] itemIds = new int[itemCount];
-
- for(int i = 0; i < itemCount; i++)
- {
- itemIds[i] = packet.readInt();
- }
-
- WiredSettings settings = new WiredSettings(intParams, stringParam, itemIds, -1);
-
- if(isEffect)
- {
- settings.setDelay(packet.readInt());
- }
-
- settings.setStuffTypeSelectionCode(packet.readInt());
- return settings;
- }
-
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java
index df4fbd0d..fe6bef8f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredCondition.java
@@ -1,13 +1,9 @@
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.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -17,36 +13,13 @@ public abstract class InteractionWiredCondition extends InteractionWired {
super(set, baseItem);
}
- public InteractionWiredCondition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return true;
- }
-
- @Override
- public boolean isWalkable() {
- return true;
- }
-
- @Override
- public void onClick(GameClient client, Room room, Object[] objects) {
- if (client != null) {
- if (room.hasRights(client.getHabbo())) {
- client.sendResponse(new WiredConditionDataComposer(this, room));
- this.activateBox(room);
- }
- }
+ public InteractionWiredCondition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public abstract WiredConditionType getType();
- public abstract boolean saveData(WiredSettings settings);
-
public WiredConditionOperator operator() {
return WiredConditionOperator.AND;
}
-
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java
index e58e3659..68981e6c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredEffect.java
@@ -1,61 +1,49 @@
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.items.interactions.wired.WiredSettings;
+import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredEffectInteraction;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
-import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
+import gnu.trove.set.hash.THashSet;
+import lombok.Getter;
+import lombok.Setter;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
-public abstract class InteractionWiredEffect extends InteractionWired {
- private int delay;
+public abstract class InteractionWiredEffect extends InteractionWired implements IWiredEffectInteraction {
+ @Getter
+ @Setter
+ private List blockedTriggers;
+
+ @Getter
+ @Setter
+ private WiredEffectType type;
public InteractionWiredEffect(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionWiredEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionWiredEffect(int id, HabboInfo ownerInfo, Item item, String extraData, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extraData, limitedStack, limitedSells);
}
- @Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return true;
- }
+ public List getBlockedTriggers(Room room) {
+ List blockedTriggers = new ArrayList<>();
+ THashSet triggers = room.getRoomSpecialTypes().getTriggers(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
- @Override
- public boolean isWalkable() {
- return true;
- }
-
- @Override
- public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if (client != null) {
- if (room.hasRights(client.getHabbo())) {
- client.sendResponse(new WiredEffectDataComposer(this, room));
- this.activateBox(room);
+ for(InteractionWiredTrigger trigger : triggers) {
+ if(!trigger.isTriggeredByRoomUnit()) {
+ blockedTriggers.add(trigger.getBaseItem().getSpriteId());
}
}
+
+ return blockedTriggers;
}
- public abstract boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException;
-
- public int getDelay() {
- return this.delay;
- }
-
- protected void setDelay(int value) {
- this.delay = value;
- }
-
- public abstract WiredEffectType getType();
-
-
public boolean requiresTriggeringUser() {
return false;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java
index c29cf0a6..c0bae61a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredExtra.java
@@ -3,7 +3,8 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,14 +14,14 @@ public abstract class InteractionWiredExtra extends InteractionWired {
super(set, baseItem);
}
- protected InteractionWiredExtra(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ protected InteractionWiredExtra(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
if (client != null) {
- if (room.hasRights(client.getHabbo())) {
+ if (room.getRoomRightsManager().hasRights(client.getHabbo())) {
this.activateBox(room);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
index d8b3a9dc..f75c8e58 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
@@ -4,8 +4,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@@ -20,7 +21,7 @@ import java.sql.SQLException;
import java.util.List;
@Slf4j
-public class InteractionWiredHighscore extends HabboItem {
+public class InteractionWiredHighscore extends RoomItem {
public WiredHighscoreScoreType scoreType;
@@ -46,8 +47,8 @@ public class InteractionWiredHighscore extends HabboItem {
this.reloadData();
}
- public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionWiredHighscore(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.scoreType = WiredHighscoreScoreType.CLASSIC;
this.clearType = WiredHighscoreClearType.ALLTIME;
@@ -81,16 +82,16 @@ public class InteractionWiredHighscore extends HabboItem {
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
return;
- if (this.getExtradata() == null || this.getExtradata().isEmpty() || this.getExtradata().length() == 0) {
- this.setExtradata("0");
+ if (this.getExtraData() == null || this.getExtraData().isEmpty() || this.getExtraData().length() == 0) {
+ this.setExtraData("0");
}
try {
- int state = Integer.parseInt(this.getExtradata());
- this.setExtradata(Math.abs(state - 1) + "");
+ int state = Integer.parseInt(this.getExtraData());
+ this.setExtraData(Math.abs(state - 1) + "");
room.updateItem(this);
} catch (Exception e) {
log.error("Caught exception", e);
@@ -105,7 +106,7 @@ public class InteractionWiredHighscore extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt(6);
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
serverMessage.appendInt(this.scoreType.getType());
serverMessage.appendInt(this.clearType.getType());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java
index db67dd84..86e1108f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredTrigger.java
@@ -1,61 +1,50 @@
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.items.interactions.wired.WiredSettings;
+import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredTriggerInteraction;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.outgoing.wired.WiredTriggerDataComposer;
+import gnu.trove.set.hash.THashSet;
+import lombok.Getter;
+import lombok.Setter;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
-public abstract class InteractionWiredTrigger extends InteractionWired {
- private int delay;
+public abstract class InteractionWiredTrigger extends InteractionWired implements IWiredTriggerInteraction {
+ @Getter
+ @Setter
+ private List blockedEffects;
+
+ @Getter
+ @Setter
+ private WiredTriggerType type;
protected InteractionWiredTrigger(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- protected InteractionWiredTrigger(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ protected InteractionWiredTrigger(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
- @Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return true;
- }
+ public List getBlockedEffects(Room room) {
+ List blockedEffects = new ArrayList<>();
+ THashSet effects = room.getRoomSpecialTypes().getEffects(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
- @Override
- public boolean isWalkable() {
- return true;
- }
-
- @Override
- public void onClick(GameClient client, Room room, Object[] objects) {
- if (client != null) {
- if (room.hasRights(client.getHabbo())) {
- client.sendResponse(new WiredTriggerDataComposer(this, room));
- this.activateBox(room);
+ for(InteractionWiredEffect effect : effects) {
+ if (!effect.requiresTriggeringUser()) {
+ blockedEffects.add(effect.getBaseItem().getSpriteId());
}
}
- }
- public abstract WiredTriggerType getType();
-
- public abstract boolean saveData(WiredSettings settings);
-
- protected int getDelay() {
- return this.delay;
- }
-
- protected void setDelay(int value) {
- this.delay = value;
+ return blockedEffects;
}
public boolean isTriggeredByRoomUnit() {
return false;
}
-
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
index 4da6bb8f..e341d276 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
@@ -5,17 +5,17 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.YoutubeManager;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer;
-import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ScheduledFuture;
-public class InteractionYoutubeTV extends HabboItem {
+public class InteractionYoutubeTV extends RoomItem {
public YoutubeManager.YoutubePlaylist currentPlaylist = null;
public YoutubeManager.YoutubeVideo currentVideo = null;
public int startedWatchingAt = 0;
@@ -27,8 +27,8 @@ public class InteractionYoutubeTV extends HabboItem {
super(set, baseItem);
}
- public InteractionYoutubeTV(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionYoutubeTV(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -48,8 +48,8 @@ public class InteractionYoutubeTV extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
- if (this.getExtradata().length() == 0)
- this.setExtradata("");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("");
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(1);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java
index b56491bd..47d768bf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameGate.java
@@ -4,7 +4,8 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
@@ -13,17 +14,17 @@ import java.sql.SQLException;
public abstract class InteractionGameGate extends InteractionGameTeamItem {
public InteractionGameGate(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException {
super(set, baseItem, teamColor);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionGameGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
- this.setExtradata("0");
+ public InteractionGameGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
+ this.setExtraData("0");
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
@@ -34,7 +35,7 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -49,7 +50,7 @@ public abstract class InteractionGameGate extends InteractionGameTeamItem {
if (memberCount > maxPlayers) {
memberCount = maxPlayers;
}
- this.setExtradata(memberCount + "");
+ this.setExtraData(memberCount + "");
game.getRoom().updateItem(this);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java
index eb416b80..cf81f3fd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameScoreboard.java
@@ -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.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
@@ -11,24 +12,24 @@ import java.sql.SQLException;
public abstract class InteractionGameScoreboard extends InteractionGameTeamItem {
protected InteractionGameScoreboard(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException {
super(set, baseItem, teamColor);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- protected InteractionGameScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
- this.setExtradata("0");
+ protected InteractionGameScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java
index f52ff6b8..583040bb 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTeamItem.java
@@ -2,12 +2,13 @@ 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.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
-public abstract class InteractionGameTeamItem extends HabboItem {
+public abstract class InteractionGameTeamItem extends RoomItem {
public final GameTeamColors teamColor;
protected InteractionGameTeamItem(ResultSet set, Item baseItem, GameTeamColors teamColor) throws SQLException {
@@ -16,8 +17,8 @@ public abstract class InteractionGameTeamItem extends HabboItem {
this.teamColor = teamColor;
}
- protected InteractionGameTeamItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ protected InteractionGameTeamItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.teamColor = teamColor;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
index 161cea9b..a822f2ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
@@ -8,8 +8,9 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@@ -24,7 +25,7 @@ import java.sql.SQLException;
import java.util.Arrays;
@Slf4j
-public class InteractionGameTimer extends HabboItem implements Runnable {
+public class InteractionGameTimer extends RoomItem implements Runnable {
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 };
@@ -76,7 +77,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
}
if (data.length >= 1) {
- this.setExtradata(data[0] + "\t0");
+ this.setExtraData(data[0] + "\t0");
}
}
catch (Exception e) {
@@ -85,8 +86,8 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
}
}
- public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionGameTimer(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
parseCustomParams(item);
}
@@ -154,7 +155,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
@Override
public void run() {
- if (this.needsUpdate() || this.needsDelete()) {
+ if (this.isSqlUpdateNeeded() || this.isSqlDeleteNeeded()) {
super.run();
}
}
@@ -163,8 +164,8 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
public void onPickUp(Room room) {
this.endGame(room);
- this.setExtradata(this.baseTime + "\t" + this.baseTime);
- this.needsUpdate(true);
+ this.setExtraData(this.baseTime + "\t" + this.baseTime);
+ this.setSqlUpdateNeeded(true);
}
@Override
@@ -175,9 +176,9 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
this.timeNow = this.baseTime;
- this.setExtradata(this.timeNow + "\t" + this.baseTime);
+ this.setExtraData(this.timeNow + "\t" + this.baseTime);
room.updateItem(this);
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
super.onPlace(room);
}
@@ -202,8 +203,8 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if (this.getExtradata().isEmpty()) {
- this.setExtradata("0\t" + this.TIMER_INTERVAL_STEPS[0]);
+ if (this.getExtraData().isEmpty()) {
+ this.setExtraData("0\t" + this.TIMER_INTERVAL_STEPS[0]);
}
// if wired triggered it
@@ -232,7 +233,7 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
Emulator.getThreading().run(new GameTimer(this), 1000);
}
} else if (client != null) {
- if (!(room.hasRights(client.getHabbo()) || client.getHabbo().hasRight(Permission.ACC_ANYROOMOWNER)))
+ if (!(room.getRoomRightsManager().hasRights(client.getHabbo()) || client.getHabbo().hasPermissionRight(Permission.ACC_ANYROOMOWNER)))
return;
InteractionGameTimerAction state = InteractionGameTimerAction.START_STOP;
@@ -313,16 +314,11 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
}
this.baseTime = baseTime;
- this.setExtradata(this.timeNow + "\t" + this.baseTime);
+ this.setExtraData(this.timeNow + "\t" + this.baseTime);
this.timeNow = this.baseTime;
room.updateItem(this);
- this.needsUpdate(true);
- }
-
- @Override
- public String getDatabaseExtraData() {
- return this.getExtradata();
+ this.setSqlUpdateNeeded(true);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
index 0882cb0b..b0002330 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiPuck.java
@@ -5,9 +5,14 @@ import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionPushable;
-import com.eu.habbo.habbohotel.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -17,8 +22,8 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
super(set, baseItem);
}
- public InteractionBattleBanzaiPuck(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionBattleBanzaiPuck(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -27,7 +32,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@@ -37,7 +42,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@@ -47,7 +52,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getDragDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@@ -57,7 +62,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getTackleDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@@ -67,52 +72,52 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) {
+ public RoomRotation getBounceDirection(Room room, RoomRotation currentDirection) {
switch (currentDirection) {
default:
case NORTH:
- return RoomUserRotation.SOUTH;
+ return RoomRotation.SOUTH;
case NORTH_EAST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue())))
- return RoomUserRotation.NORTH_WEST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue())))
- return RoomUserRotation.SOUTH_EAST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue())))
+ return RoomRotation.NORTH_WEST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue())))
+ return RoomRotation.SOUTH_EAST;
else
- return RoomUserRotation.SOUTH_WEST;
+ return RoomRotation.SOUTH_WEST;
case EAST:
- return RoomUserRotation.WEST;
+ return RoomRotation.WEST;
case SOUTH_EAST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue())))
- return RoomUserRotation.SOUTH_WEST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue())))
- return RoomUserRotation.NORTH_EAST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue())))
+ return RoomRotation.SOUTH_WEST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue())))
+ return RoomRotation.NORTH_EAST;
else
- return RoomUserRotation.NORTH_WEST;
+ return RoomRotation.NORTH_WEST;
case SOUTH:
- return RoomUserRotation.NORTH;
+ return RoomRotation.NORTH;
case SOUTH_WEST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue())))
- return RoomUserRotation.SOUTH_EAST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue())))
- return RoomUserRotation.NORTH_WEST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue())))
+ return RoomRotation.SOUTH_EAST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue())))
+ return RoomRotation.NORTH_WEST;
else
- return RoomUserRotation.NORTH_EAST;
+ return RoomRotation.NORTH_EAST;
case WEST:
- return RoomUserRotation.EAST;
+ return RoomRotation.EAST;
case NORTH_WEST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue())))
- return RoomUserRotation.NORTH_EAST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue())))
- return RoomUserRotation.SOUTH_WEST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue())))
+ return RoomRotation.NORTH_EAST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue())))
+ return RoomRotation.SOUTH_WEST;
else
- return RoomUserRotation.SOUTH_EAST;
+ return RoomRotation.SOUTH_EAST;
}
}
@@ -123,44 +128,47 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
@Override
public boolean validMove(Room room, RoomTile from, RoomTile to) {
- if (to == null) return false;
- HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this);
- return !(!room.getLayout().tileWalkable(to.getX(), to.getY()) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
-
- //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
+ if (to == null) {
+ return false;
+ }
+
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
+
+ return !(!room.getLayout().tileWalkable(to) || (topItem != null && (!topItem.getBaseItem().allowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
+ //return !(!room.getLayout().tileWalkable(to.x, to.y) || (topItem != null && (!topItem.getBaseItem().setAllowStack() || topItem.getBaseItem().allowSit() || topItem.getBaseItem().allowLay())));
}
@Override
- public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
- Habbo habbo = room.getHabbo(kicker);
+ public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(kicker);
if (habbo != null) {
BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
if (game != null) {
GameTeam team = game.getTeamForHabbo(habbo);
if (team != null) {
- HabboItem item = room.getTopItemAt(to.getX(), to.getY());
+ RoomItem item = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY());
try {
item.onWalkOn(kicker, room, null);
} catch (Exception e) {
return;
}
- this.setExtradata(team.teamColor.type + "");
+ this.setExtraData(team.teamColor.type + "");
room.updateItemState(this);
}
}
@@ -169,7 +177,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) {
+ public void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker) {
}
@@ -179,7 +187,7 @@ public class InteractionBattleBanzaiPuck extends InteractionPushable {
}
@Override
- public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
+ public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
return to.getState() == RoomTileState.OPEN && to.isWalkable();
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java
index 77954520..a518ca52 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiSphere.java
@@ -2,28 +2,29 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionBattleBanzaiSphere extends HabboItem {
+public class InteractionBattleBanzaiSphere extends RoomItem {
public InteractionBattleBanzaiSphere(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionBattleBanzaiSphere(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionBattleBanzaiSphere(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java
index 5b7580a7..859593de 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java
@@ -4,30 +4,31 @@ 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.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.BanzaiRandomTeleport;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionBattleBanzaiTeleporter extends HabboItem {
+public class InteractionBattleBanzaiTeleporter extends RoomItem {
public InteractionBattleBanzaiTeleporter(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionBattleBanzaiTeleporter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionBattleBanzaiTeleporter(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -57,13 +58,13 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem {
super.onWalkOn(roomUnit, room, objects);
if(objects.length < 3) {
- HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this);
+ RoomItem target = room.getRoomSpecialTypes().getRandomTeleporter(null, this);
if (target == null) return;
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItemState(this);
roomUnit.removeStatus(RoomUnitStatus.MOVE);
- roomUnit.setGoalLocation(roomUnit.getCurrentLocation());
+ roomUnit.walkTo(roomUnit.getCurrentPosition());
roomUnit.setCanWalk(false);
Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
index d2583d9e..b336d2aa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTile.java
@@ -5,9 +5,10 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@@ -16,21 +17,21 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-public class InteractionBattleBanzaiTile extends HabboItem {
+public class InteractionBattleBanzaiTile extends RoomItem {
public InteractionBattleBanzaiTile(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionBattleBanzaiTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionBattleBanzaiTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -54,15 +55,15 @@ public class InteractionBattleBanzaiTile extends HabboItem {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (this.getExtradata().isEmpty())
- this.setExtradata("0");
+ if (this.getExtraData().isEmpty())
+ this.setExtraData("0");
- int state = Integer.parseInt(this.getExtradata());
+ int state = Integer.parseInt(this.getExtraData());
if (state % 3 == 2)
return;
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null)
return;
@@ -85,26 +86,26 @@ public class InteractionBattleBanzaiTile extends HabboItem {
}
public boolean isLocked() {
- if (this.getExtradata().isEmpty())
+ if (this.getExtraData().isEmpty())
return false;
- return Integer.parseInt(this.getExtradata()) % 3 == 2;
+ return Integer.parseInt(this.getExtraData()) % 3 == 2;
}
@Override
- public boolean canStackAt(Room room, List>> itemsAtLocation) {
- for (Pair> set : itemsAtLocation) {
+ public boolean canStackAt(List>> itemsAtLocation) {
+ for (Pair> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) return false;
}
- return super.canStackAt(room, itemsAtLocation);
+ return super.canStackAt(itemsAtLocation);
}
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
}
@@ -115,7 +116,7 @@ public class InteractionBattleBanzaiTile extends HabboItem {
BattleBanzaiGame game = (BattleBanzaiGame) room.getGame(BattleBanzaiGame.class);
if (game != null && game.getState() != GameState.IDLE) {
- this.setExtradata("1");
+ this.setExtraData("1");
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
index cbc343df..04c1b7d9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGate.java
@@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -19,8 +20,8 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
super(set, baseItem, teamColor);
}
- public InteractionBattleBanzaiGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ public InteractionBattleBanzaiGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
}
@Override
@@ -35,7 +36,7 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
@Override
public boolean isWalkable() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room == null) return false;
@@ -54,12 +55,12 @@ public class InteractionBattleBanzaiGate extends InteractionGameGate {
room.addGame(game);
}
- GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit));
+ GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
if (team != null) {
- game.removeHabbo(room.getHabbo(roomUnit));
+ game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
} else {
- game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
+ game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor);
}
updateState(game, 5);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java
index 206bd98b..6596d2e0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateBlue extends InteractionBattleBanzaiGate
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiGateBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java
index ee488fba..54052d44 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateGreen extends InteractionBattleBanzaiGat
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiGateGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java
index ceeca701..6b6f1c24 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateRed extends InteractionBattleBanzaiGate
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiGateRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java
index ec6609e4..770a1fe8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/gates/InteractionBattleBanzaiGateYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiGateYellow extends InteractionBattleBanzaiGa
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiGateYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java
index f34584b4..2198418b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboard.java
@@ -4,7 +4,8 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,8 +15,8 @@ public class InteractionBattleBanzaiScoreboard extends InteractionGameScoreboard
super(set, baseItem, teamColor);
}
- public InteractionBattleBanzaiScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ public InteractionBattleBanzaiScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java
index a5452738..af47fe4e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardBlue extends InteractionBattleBanz
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java
index a42332f9..1f57ffac 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardGreen extends InteractionBattleBan
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java
index 9abf0aad..431c6290 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardRed extends InteractionBattleBanza
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java
index 6b4b8950..36d80166 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/scoreboards/InteractionBattleBanzaiScoreboardYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboard
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionBattleBanzaiScoreboardYellow extends InteractionBattleBa
super(set, baseItem, TEAM_COLOR);
}
- public InteractionBattleBanzaiScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionBattleBanzaiScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
index 09a45a03..bb205a17 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootball.java
@@ -6,8 +6,13 @@ import com.eu.habbo.habbohotel.games.football.FootballGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionPushable;
import com.eu.habbo.habbohotel.items.interactions.games.football.goals.InteractionFootballGoal;
-import com.eu.habbo.habbohotel.rooms.*;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.rooms.items.OneWayDoorStatusMessageComposer;
import com.eu.habbo.util.pathfinding.Rotation;
@@ -22,17 +27,17 @@ public class InteractionFootball extends InteractionPushable {
super(set, baseItem);
}
- public InteractionFootball(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionFootball(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public int getWalkOnVelocity(RoomUnit roomUnit, Room room) {
- if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2 && this.getExtradata().equals("1"))
+ if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2 && this.getExtraData().equals("1"))
return 0;
- if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 1)
+ if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 1)
return 6;
return 1;
@@ -40,7 +45,7 @@ public class InteractionFootball extends InteractionPushable {
@Override
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
- if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 0)
+ if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 0)
return 6;
return 1;
@@ -48,7 +53,7 @@ public class InteractionFootball extends InteractionPushable {
@Override
public int getDragVelocity(RoomUnit roomUnit, Room room) {
- if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2)
+ if (roomUnit.getPath().isEmpty() && roomUnit.getTilesMoved() == 2)
return 0;
return 1;
@@ -61,22 +66,27 @@ public class InteractionFootball extends InteractionPushable {
@Override
- public RoomUserRotation getWalkOnDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getWalkOnDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@Override
- public RoomUserRotation getWalkOffDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getWalkOffDirection(RoomUnit roomUnit, Room room) {
RoomTile peek = roomUnit.getPath().peek();
- RoomTile nextWalkTile = peek != null ? room.getLayout().getTile(peek.getX(), peek.getY()) : roomUnit.getGoalLocation();
- return RoomUserRotation.values()[(RoomUserRotation.values().length + Rotation.Calculate(roomUnit.getX(), roomUnit.getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8];
+ RoomTile nextWalkTile;
+ if (peek != null) {
+ nextWalkTile = room.getLayout().getTile(peek.getX(), peek.getY());
+ } else {
+ nextWalkTile = roomUnit.getTargetPosition();
+ }
+ return RoomRotation.values()[(RoomRotation.values().length + Rotation.Calculate(roomUnit.getCurrentPosition().getX(), roomUnit.getCurrentPosition().getY(), nextWalkTile.getX(), nextWalkTile.getY()) + 4) % 8];
}
- public RoomUserRotation getDragDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getDragDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
- public RoomUserRotation getTackleDirection(RoomUnit roomUnit, Room room) {
+ public RoomRotation getTackleDirection(RoomUnit roomUnit, Room room) {
return roomUnit.getBodyRotation();
}
@@ -92,52 +102,52 @@ public class InteractionFootball extends InteractionPushable {
}
@Override
- public RoomUserRotation getBounceDirection(Room room, RoomUserRotation currentDirection) {
+ public RoomRotation getBounceDirection(Room room, RoomRotation currentDirection) {
switch (currentDirection) {
default:
case NORTH:
- return RoomUserRotation.SOUTH;
+ return RoomRotation.SOUTH;
case NORTH_EAST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue())))
- return RoomUserRotation.NORTH_WEST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue())))
- return RoomUserRotation.SOUTH_EAST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue())))
+ return RoomRotation.NORTH_WEST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue())))
+ return RoomRotation.SOUTH_EAST;
else
- return RoomUserRotation.SOUTH_WEST;
+ return RoomRotation.SOUTH_WEST;
case EAST:
- return RoomUserRotation.WEST;
+ return RoomRotation.WEST;
case SOUTH_EAST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue())))
- return RoomUserRotation.SOUTH_WEST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue())))
- return RoomUserRotation.NORTH_EAST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue())))
+ return RoomRotation.SOUTH_WEST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue())))
+ return RoomRotation.NORTH_EAST;
else
- return RoomUserRotation.NORTH_WEST;
+ return RoomRotation.NORTH_WEST;
case SOUTH:
- return RoomUserRotation.NORTH;
+ return RoomRotation.NORTH;
case SOUTH_WEST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_EAST.getValue())))
- return RoomUserRotation.SOUTH_EAST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_WEST.getValue())))
- return RoomUserRotation.NORTH_WEST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_EAST.getValue())))
+ return RoomRotation.SOUTH_EAST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_WEST.getValue())))
+ return RoomRotation.NORTH_WEST;
else
- return RoomUserRotation.NORTH_EAST;
+ return RoomRotation.NORTH_EAST;
case WEST:
- return RoomUserRotation.EAST;
+ return RoomRotation.EAST;
case NORTH_WEST:
- if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.NORTH_EAST.getValue())))
- return RoomUserRotation.NORTH_EAST;
- else if (this.validMove(room, room.getLayout().getTile(this.getX(), this.getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), RoomUserRotation.SOUTH_WEST.getValue())))
- return RoomUserRotation.SOUTH_WEST;
+ if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.NORTH_EAST.getValue())))
+ return RoomRotation.NORTH_EAST;
+ else if (this.validMove(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), room.getLayout().getTileInFront(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), RoomRotation.SOUTH_WEST.getValue())))
+ return RoomRotation.SOUTH_WEST;
else
- return RoomUserRotation.SOUTH_EAST;
+ return RoomRotation.SOUTH_EAST;
}
}
@@ -145,7 +155,7 @@ public class InteractionFootball extends InteractionPushable {
@Override
public boolean validMove(Room room, RoomTile from, RoomTile to) {
if (to == null || to.getState() == RoomTileState.INVALID) return false;
- HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this);
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
// Move is valid if there isnt any furni yet
if (topItem == null) {
@@ -153,13 +163,13 @@ public class InteractionFootball extends InteractionPushable {
}
// If any furni on tile is not stackable, move is invalid (tested on 22-03-2022)
- if (room.getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) {
+ if (room.getRoomItemManager().getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) {
return false;
}
// Ball can only go up by 1.65 according to Habbo (tested using stack tile on 22-03-2022)
- BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight());
- BigDecimal ballHeight = BigDecimal.valueOf(this.getZ());
+ BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getCurrentZ() + topItem.getBaseItem().getHeight());
+ BigDecimal ballHeight = BigDecimal.valueOf(this.getCurrentZ());
if (topItemHeight.subtract(ballHeight).compareTo(BigDecimal.valueOf(1.65)) > 0) {
return false;
@@ -186,22 +196,22 @@ public class InteractionFootball extends InteractionPushable {
//Events
@Override
- public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onDrag(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onKick(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomUserRotation direction) {
+ public void onTackle(Room room, RoomUnit roomUnit, int velocity, RoomRotation direction) {
}
@Override
- public void onMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
+ public void onMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
FootballGame game = (FootballGame) room.getGame(FootballGame.class);
if (game == null) {
try {
@@ -211,37 +221,37 @@ public class InteractionFootball extends InteractionPushable {
return;
}
}
- HabboItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this);
- HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this);
+ RoomItem currentTopItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this);
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(to.getX(), to.getY(), this);
if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) {
GameTeamColors color = interactionFootballGoal.teamColor;
game.onScore(kicker, color);
}
- this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + "");
+ this.setExtraData(Math.abs(currentStep - (totalSteps + 1)) + "");
room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose());
}
@Override
- public void onBounce(Room room, RoomUserRotation oldDirection, RoomUserRotation newDirection, RoomUnit kicker) {
+ public void onBounce(Room room, RoomRotation oldDirection, RoomRotation newDirection, RoomUnit kicker) {
}
@Override
public void onStop(Room room, RoomUnit kicker, int currentStep, int totalSteps) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose());
}
@Override
- public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomUserRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
- HabboItem topItem = room.getTopItemAt(from.getX(), from.getY(), this);
- return !((Emulator.getRandom().nextInt(10) >= 3 && room.hasHabbosAt(to.getX(), to.getY())) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
+ public boolean canStillMove(Room room, RoomTile from, RoomTile to, RoomRotation direction, RoomUnit kicker, int nextRoll, int currentStep, int totalSteps) {
+ RoomItem topItem = room.getRoomItemManager().getTopItemAt(from.getX(), from.getY(), this);
+ return !((Emulator.getRandom().nextInt(10) >= 3 && room.getRoomUnitManager().hasHabbosAt(to)) || (topItem != null && topItem.getBaseItem().getName().startsWith("fball_goal_") && currentStep != 1));
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java
index 50a232ec..c1b6bf32 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/InteractionFootballGate.java
@@ -3,10 +3,11 @@ package com.eu.habbo.habbohotel.items.interactions.games.football;
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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.clothingvalidation.ClothingValidationManager;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.UserChangeMessageComposer;
@@ -20,7 +21,7 @@ import com.eu.habbo.util.figure.FigureUtil;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionFootballGate extends HabboItem {
+public class InteractionFootballGate extends RoomItem {
private static final String CACHE_KEY = "fball_gate_look";
private String figureM;
private String figureF;
@@ -33,8 +34,8 @@ public class InteractionFootballGate extends HabboItem {
this.figureF = bits.length > 1 ? bits[1] : "";
}
- public InteractionFootballGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionFootballGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
String[] bits = extradata.split(";");
this.figureM = bits.length > 0 ? bits[0] : "";
@@ -67,8 +68,8 @@ public class InteractionFootballGate extends HabboItem {
habbo.getHabboInfo().setLook((String) habbo.getHabboStats().getCache().get(CACHE_KEY));
habbo.getHabboStats().getCache().remove(CACHE_KEY);
habbo.getClient().sendResponse(new FigureUpdateComposer(habbo));
- if (habbo.getHabboInfo().getCurrentRoom() != null) {
- habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserChangeMessageComposer(habbo).compose());
+ if (habbo.getRoomUnit().getRoom() != null) {
+ habbo.getRoomUnit().getRoom().sendComposer(new UserChangeMessageComposer(habbo).compose());
}
}
}
@@ -76,16 +77,16 @@ public class InteractionFootballGate extends HabboItem {
public void setFigureM(String look) {
this.figureM = look;
- this.setExtradata(this.figureM + ";" + this.figureF);
- this.needsUpdate(true);
+ this.setExtraData(this.figureM + ";" + this.figureF);
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
}
public void setFigureF(String look) {
this.figureF = look;
- this.setExtradata(this.figureM + ";" + this.figureF);
- this.needsUpdate(true);
+ this.setExtraData(this.figureM + ";" + this.figureF);
+ this.setSqlUpdateNeeded(true);
Emulator.getThreading().run(this);
}
@@ -113,7 +114,7 @@ public class InteractionFootballGate extends HabboItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboStats().getCache().containsKey(CACHE_KEY)) {
String oldlook = (String) habbo.getHabboStats().getCache().get(CACHE_KEY);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java
index 443bb720..a87c770c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoal.java
@@ -4,7 +4,8 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
@@ -15,8 +16,8 @@ public class InteractionFootballGoal extends InteractionGameTeamItem {
super(set, baseItem, teamColor);
}
- public InteractionFootballGoal(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ public InteractionFootballGoal(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
}
@Override
@@ -37,7 +38,7 @@ public class InteractionFootballGoal extends InteractionGameTeamItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java
index 34d2b52f..1e600210 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballGoalBlue extends InteractionFootballGoal {
super(set, baseItem, GameTeamColors.BLUE);
}
- public InteractionFootballGoalBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE);
+ public InteractionFootballGoalBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java
index 42276c9e..da40f7be 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballGoalGreen extends InteractionFootballGoal {
super(set, baseItem, GameTeamColors.GREEN);
}
- public InteractionFootballGoalGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN);
+ public InteractionFootballGoalGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java
index b4d9b5d4..945a0227 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballGoalRed extends InteractionFootballGoal {
super(set, baseItem, GameTeamColors.RED);
}
- public InteractionFootballGoalRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED);
+ public InteractionFootballGoalRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.RED);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java
index ba725033..252cc98a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/goals/InteractionFootballGoalYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.goals;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballGoalYellow extends InteractionFootballGoal {
super(set, baseItem, GameTeamColors.YELLOW);
}
- public InteractionFootballGoalYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW);
+ public InteractionFootballGoalYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java
index dba5f039..16338413 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboard.java
@@ -6,7 +6,8 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import java.sql.ResultSet;
@@ -20,14 +21,14 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard {
super(set, baseItem, teamColor);
try {
- this.score = Integer.parseInt(this.getExtradata());
+ this.score = Integer.parseInt(this.getExtraData());
} catch (Exception e) {
this.score = 0;
}
}
- public InteractionFootballScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ public InteractionFootballScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
try {
this.score = Integer.parseInt(extradata);
@@ -58,10 +59,10 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard {
this.score = 99;
}
- this.setExtradata(this.score + "");
- this.needsUpdate(true);
+ this.setExtraData(this.score + "");
+ this.setSqlUpdateNeeded(true);
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room != null) {
room.updateItem(this);
}
@@ -84,10 +85,10 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard {
this.score = 99;
}
- this.setExtradata(this.score + "");
- this.needsUpdate(true);
+ this.setExtraData(this.score + "");
+ this.setSqlUpdateNeeded(true);
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room != null) {
room.updateItem(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java
index 1a4cd219..912e0f22 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballScoreboardBlue extends InteractionFootballScoreb
super(set, baseItem, GameTeamColors.BLUE);
}
- public InteractionFootballScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE);
+ public InteractionFootballScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.BLUE);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java
index 1f785c0c..f9522567 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballScoreboardGreen extends InteractionFootballScore
super(set, baseItem, GameTeamColors.GREEN);
}
- public InteractionFootballScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN);
+ public InteractionFootballScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.GREEN);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java
index 6d65b7ea..bf40c6a0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballScoreboardRed extends InteractionFootballScorebo
super(set, baseItem, GameTeamColors.RED);
}
- public InteractionFootballScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.RED);
+ public InteractionFootballScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.RED);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java
index 731a9e82..93d4498b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/football/scoreboards/InteractionFootballScoreboardYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.football.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionFootballScoreboardYellow extends InteractionFootballScor
super(set, baseItem, GameTeamColors.YELLOW);
}
- public InteractionFootballScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW);
+ public InteractionFootballScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, GameTeamColors.YELLOW);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java
index 673e6e83..2df02776 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeBlock.java
@@ -8,24 +8,26 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.games.freeze.FreezeGamePlayer;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionFreezeBlock extends HabboItem {
+public class InteractionFreezeBlock extends RoomItem {
public InteractionFreezeBlock(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionFreezeBlock(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionFreezeBlock(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -33,12 +35,13 @@ public class InteractionFreezeBlock extends HabboItem {
if (client == null)
return;
- HabboItem item = null;
- THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY()));
+ RoomItem item = null;
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+ THashSet items = room.getRoomItemManager().getItemsAt(tile);
- for (HabboItem i : items) {
+ for (RoomItem i : items) {
if (i instanceof InteractionFreezeTile) {
- if (item == null || i.getZ() <= item.getZ()) {
+ if (item == null || i.getCurrentZ() <= item.getCurrentZ()) {
item = i;
}
}
@@ -56,11 +59,11 @@ public class InteractionFreezeBlock extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
- if (this.getExtradata().length() == 0) {
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0) {
+ this.setExtraData("0");
}
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -72,7 +75,7 @@ public class InteractionFreezeBlock extends HabboItem {
@Override
public boolean isWalkable() {
- return !this.getExtradata().isEmpty() && !this.getExtradata().equals("0");
+ return !this.getExtraData().isEmpty() && !this.getExtraData().equals("0");
}
@Override
@@ -84,14 +87,14 @@ public class InteractionFreezeBlock extends HabboItem {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (this.getExtradata().isEmpty() || this.getExtradata().equalsIgnoreCase("0"))
+ if (this.getExtraData().isEmpty() || this.getExtraData().equalsIgnoreCase("0"))
return;
FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class);
if (game == null || !game.state.equals(GameState.RUNNING))
return;
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo == null || habbo.getHabboInfo().getCurrentGame() != FreezeGame.class)
return;
@@ -103,7 +106,7 @@ public class InteractionFreezeBlock extends HabboItem {
int powerUp;
try {
- powerUp = Integer.parseInt(this.getExtradata()) / 1000;
+ powerUp = Integer.parseInt(this.getExtraData()) / 1000;
} catch (NumberFormatException e) {
powerUp = 0;
}
@@ -112,7 +115,7 @@ public class InteractionFreezeBlock extends HabboItem {
if (powerUp == 6 && !player.canPickupLife())
return;
- this.setExtradata((powerUp + 10) * 1000 + "");
+ this.setExtraData((powerUp + 10) * 1000 + "");
room.updateItem(this);
@@ -124,6 +127,6 @@ public class InteractionFreezeBlock extends HabboItem {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java
index de76eeef..62652f27 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeExitTile.java
@@ -2,27 +2,28 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionFreezeExitTile extends HabboItem {
+public class InteractionFreezeExitTile extends RoomItem {
public InteractionFreezeExitTile(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionFreezeExitTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionFreezeExitTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
@@ -43,7 +44,7 @@ public class InteractionFreezeExitTile extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
index d46b3c82..1df899dd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/InteractionFreezeTile.java
@@ -5,8 +5,9 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
@@ -15,15 +16,15 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-public class InteractionFreezeTile extends HabboItem {
+public class InteractionFreezeTile extends RoomItem {
public InteractionFreezeTile(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionFreezeTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionFreezeTile(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -41,7 +42,7 @@ public class InteractionFreezeTile extends HabboItem {
if (client == null)
return;
- if (client.getHabbo().getRoomUnit().getCurrentLocation().getX() == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().getY() == this.getY()) {
+ if (client.getHabbo().getRoomUnit().getCurrentPosition().getX() == this.getCurrentPosition().getX() && client.getHabbo().getRoomUnit().getCurrentPosition().getY() == this.getCurrentPosition().getY()) {
FreezeGame game = (FreezeGame) room.getGame(FreezeGame.class);
if (game != null)
@@ -57,14 +58,14 @@ public class InteractionFreezeTile extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
@Override
@@ -74,11 +75,11 @@ public class InteractionFreezeTile extends HabboItem {
@Override
- public boolean canStackAt(Room room, List>> itemsAtLocation) {
- for (Pair> set : itemsAtLocation) {
+ public boolean canStackAt(List>> itemsAtLocation) {
+ for (Pair> set : itemsAtLocation) {
if (set.getValue() != null && !set.getValue().isEmpty()) return false;
}
- return super.canStackAt(room, itemsAtLocation);
+ return super.canStackAt(itemsAtLocation);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
index e135e7d1..1bf54566 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGate.java
@@ -9,7 +9,8 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameGate;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -19,8 +20,8 @@ public class InteractionFreezeGate extends InteractionGameGate {
super(set, baseItem, teamColor);
}
- public InteractionFreezeGate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ public InteractionFreezeGate(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
}
@Override
@@ -34,7 +35,7 @@ public class InteractionFreezeGate extends InteractionGameGate {
@Override
public boolean isWalkable() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
if (room == null) return false;
@@ -52,12 +53,12 @@ public class InteractionFreezeGate extends InteractionGameGate {
room.addGame(game);
}
- GameTeam team = game.getTeamForHabbo(room.getHabbo(roomUnit));
+ GameTeam team = game.getTeamForHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
if (team != null) {
- game.removeHabbo(room.getHabbo(roomUnit));
+ game.removeHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit));
} else {
- game.addHabbo(room.getHabbo(roomUnit), this.teamColor);
+ game.addHabbo(room.getRoomUnitManager().getHabboByRoomUnit(roomUnit), this.teamColor);
}
updateState(game, 5);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java
index 90040250..22d10c07 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeGateBlue extends InteractionFreezeGate {
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeGateBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeGateBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java
index dd62a2eb..f99c02ff 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeGateGreen extends InteractionFreezeGate {
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeGateGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeGateGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java
index 7f502050..0d28f833 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeGateRed extends InteractionFreezeGate {
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeGateRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeGateRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java
index 418ce0ed..8b5c3add 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/gates/InteractionFreezeGateYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.gates;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeGateYellow extends InteractionFreezeGate {
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeGateYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeGateYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java
index 5f8d510d..d90ca07c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboard.java
@@ -4,7 +4,8 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameScoreboard;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,8 +15,8 @@ public class InteractionFreezeScoreboard extends InteractionGameScoreboard {
super(set, baseItem, teamColor);
}
- InteractionFreezeScoreboard(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
- super(id, userId, item, extradata, limitedStack, limitedSells, teamColor);
+ InteractionFreezeScoreboard(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, GameTeamColors teamColor) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, teamColor);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java
index 9c005626..b9fda992 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardBlue.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardBlue extends InteractionFreezeScoreboard
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeScoreboardBlue(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeScoreboardBlue(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java
index 3ce66539..9aa9ebca 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardGreen.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardGreen extends InteractionFreezeScoreboar
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeScoreboardGreen(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeScoreboardGreen(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java
index 9846fa55..719299bd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardRed.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardRed extends InteractionFreezeScoreboard
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeScoreboardRed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeScoreboardRed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java
index 1c9d94e0..59b2d384 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/freeze/scoreboards/InteractionFreezeScoreboardYellow.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -13,7 +14,7 @@ public class InteractionFreezeScoreboardYellow extends InteractionFreezeScoreboa
super(set, baseItem, TEAM_COLOR);
}
- public InteractionFreezeScoreboardYellow(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
+ public InteractionFreezeScoreboardYellow(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, TEAM_COLOR);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java
index 53c8dd7b..dce84c97 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagField.java
@@ -4,15 +4,16 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public abstract class InteractionTagField extends HabboItem {
+public abstract class InteractionTagField extends RoomItem {
public Class extends Game> gameClazz;
public InteractionTagField(ResultSet set, Item baseItem, Class extends Game> gameClazz) throws SQLException {
@@ -21,15 +22,15 @@ public abstract class InteractionTagField extends HabboItem {
this.gameClazz = gameClazz;
}
- public InteractionTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells, Class extends Game> gameClazz) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTagField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells, Class extends Game> gameClazz) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
this.gameClazz = gameClazz;
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
return habbo.getHabboInfo().getCurrentGame() == null || habbo.getHabboInfo().getCurrentGame() == this.gameClazz;
@@ -50,7 +51,7 @@ public abstract class InteractionTagField extends HabboItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentGame() == null) {
@@ -75,7 +76,7 @@ public abstract class InteractionTagField extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java
index d9aa71c6..e07f0388 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/InteractionTagPole.java
@@ -2,20 +2,21 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionTagPole extends HabboItem {
+public class InteractionTagPole extends RoomItem {
public InteractionTagPole(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTagPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -36,13 +37,13 @@ public class InteractionTagPole extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java
index df20b8d3..bd902eb8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunField.java
@@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -16,15 +17,15 @@ public class InteractionBunnyrunField extends InteractionTagField {
super(set, baseItem, BunnyrunGame.class);
}
- public InteractionBunnyrunField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, BunnyrunGame.class);
+ public InteractionBunnyrunField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, BunnyrunGame.class);
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
- Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
+ Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId());
if (itemOwner != null) {
AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbBunnyTag"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java
index 9c0ae732..1573f4e5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/bunnyrun/InteractionBunnyrunPole.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionBunnyrunPole extends InteractionTagPole {
super(set, baseItem);
}
- public InteractionBunnyrunPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionBunnyrunPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java
index 75d25b2b..34901520 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagField.java
@@ -6,8 +6,9 @@ import com.eu.habbo.habbohotel.games.tag.IceTagGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -20,15 +21,15 @@ public class InteractionIceTagField extends InteractionTagField {
super(set, baseItem, IceTagGame.class);
}
- public InteractionIceTagField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, IceTagGame.class);
+ public InteractionIceTagField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, IceTagGame.class);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null)
this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp());
}
@@ -37,7 +38,7 @@ public class InteractionIceTagField extends InteractionTagField {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.stepTimes.containsKey(habbo)) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60);
this.stepTimes.remove(habbo);
@@ -48,7 +49,7 @@ public class InteractionIceTagField extends InteractionTagField {
public void onPlace(Room room) {
super.onPlace(room);
- Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
+ Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId());
if (itemOwner != null) {
AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("TagA"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java
index b2fe44c0..78a1c4f9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/icetag/InteractionIceTagPole.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.games.tag.icetag;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -11,7 +12,7 @@ public class InteractionIceTagPole extends InteractionTagPole {
super(set, baseItem);
}
- public InteractionIceTagPole(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionIceTagPole(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java
index c25374c9..0511e567 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/tag/rollerskate/InteractionRollerskateField.java
@@ -6,8 +6,9 @@ import com.eu.habbo.habbohotel.games.tag.RollerskateGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -20,15 +21,15 @@ public class InteractionRollerskateField extends InteractionTagField {
super(set, baseItem, RollerskateGame.class);
}
- public InteractionRollerskateField(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells, RollerskateGame.class);
+ public InteractionRollerskateField(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells, RollerskateGame.class);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null)
this.stepTimes.put(habbo, Emulator.getIntUnixTimestamp());
}
@@ -37,7 +38,7 @@ public class InteractionRollerskateField extends InteractionTagField {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null && this.stepTimes.containsKey(habbo)) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagC"), (Emulator.getIntUnixTimestamp() - this.stepTimes.get(habbo)) / 60);
this.stepTimes.remove(habbo);
@@ -48,7 +49,7 @@ public class InteractionRollerskateField extends InteractionTagField {
public void onPlace(Room room) {
super.onPlace(room);
- Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
+ Habbo itemOwner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getOwnerInfo().getId());
if (itemOwner != null) {
AchievementManager.progressAchievement(itemOwner, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RbTagA"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
index 58eea046..6672f7ee 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
@@ -1,7 +1,7 @@
package com.eu.habbo.habbohotel.items.interactions.interfaces;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
public interface ConditionalGate {
void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
index b92511cd..40d0f0b0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionMonsterPlantSeed.java
@@ -4,29 +4,30 @@ 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.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionMonsterPlantSeed extends HabboItem {
+public class InteractionMonsterPlantSeed extends RoomItem {
public InteractionMonsterPlantSeed(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- if (this.getExtradata().isEmpty()) {
- this.setExtradata("" + randomRarityLevel());
- this.needsUpdate(true);
+ if (this.getExtraData().isEmpty()) {
+ this.setExtraData("" + randomRarityLevel());
+ this.setSqlUpdateNeeded(true);
}
}
- public InteractionMonsterPlantSeed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionMonsterPlantSeed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
- if (this.getExtradata().isEmpty()) {
- this.setExtradata("" + randomRarityLevel());
- this.needsUpdate(true);
+ if (this.getExtraData().isEmpty()) {
+ this.setExtraData("" + randomRarityLevel());
+ this.setSqlUpdateNeeded(true);
}
}
@@ -78,7 +79,7 @@ public class InteractionMonsterPlantSeed extends HabboItem {
serverMessage.appendInt(1 + (this.isLimited() ? 256 : 0));
serverMessage.appendInt(1);
serverMessage.appendString("rarity");
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
index 9cd0adf5..d4fea6d8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionNest.java
@@ -6,28 +6,29 @@ 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.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionNest extends HabboItem {
+public class InteractionNest extends RoomItem {
public InteractionNest(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public InteractionNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionNest(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -56,7 +57,7 @@ public class InteractionNest extends HabboItem {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet == null)
return;
@@ -71,10 +72,10 @@ public class InteractionNest extends HabboItem {
return;
pet.setTask(PetTasks.NEST);
- pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
+ pet.getRoomUnit().clearStatuses();
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
- pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getX(), this.getY(), false) + "");
+ pet.getRoomUnit().addStatus(RoomUnitStatus.LAY, room.getStackHeight(this.getCurrentPosition().getX(), this.getCurrentPosition().getY(), false) + "");
room.sendComposer(new UserUpdateComposer(roomUnit).compose());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
index 87eabfe3..68d56385 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetBreedingNest.java
@@ -7,9 +7,10 @@ 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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.pets.PerkAllowancesComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.breeding.ConfirmBreedingRequestComposer;
@@ -19,7 +20,7 @@ import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionPetBreedingNest extends HabboItem {
+public class InteractionPetBreedingNest extends RoomItem {
private Pet petOne = null;
private Pet petTwo = null;
@@ -27,13 +28,13 @@ public class InteractionPetBreedingNest extends HabboItem {
super(set, baseItem);
}
- public InteractionPetBreedingNest(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPetBreedingNest(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- return room.getPet(roomUnit) != null && !this.boxFull();
+ return room.getRoomUnitManager().getPetByRoomUnit(roomUnit) != null && !this.boxFull();
}
@Override
@@ -45,7 +46,7 @@ public class InteractionPetBreedingNest extends HabboItem {
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
- serverMessage.appendString(this.getExtradata());
+ serverMessage.appendString(this.getExtraData());
super.serializeExtradata(serverMessage);
}
@@ -57,18 +58,18 @@ public class InteractionPetBreedingNest extends HabboItem {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null && !this.boxFull()) {
this.addPet(pet);
if (this.boxFull()) {
- Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId());
- Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId());
+ Habbo ownerPetOne = room.getRoomUnitManager().getRoomHabboById(this.petOne.getUserId());
+ Habbo ownerPetTwo = room.getRoomUnitManager().getRoomHabboById(this.petTwo.getUserId());
if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) {
ownerPetTwo.getClient().sendResponse(new ConfirmBreedingRequestComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername()));
- this.setExtradata("1");
+ this.setExtraData("1");
room.updateItem(this);
}
}
@@ -98,7 +99,7 @@ public class InteractionPetBreedingNest extends HabboItem {
if (this.petOne != null && this.petOne.getRoomUnit() == roomUnit) this.petOne = null;
if (this.petTwo != null && this.petTwo.getRoomUnit() == roomUnit) this.petTwo = null;
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
}
@@ -108,14 +109,14 @@ public class InteractionPetBreedingNest extends HabboItem {
}
public void stopBreeding(Habbo habbo) {
- this.setExtradata("0");
- habbo.getHabboInfo().getCurrentRoom().updateItem(this);
+ this.setExtraData("0");
+ habbo.getRoomUnit().getRoom().updateItem(this);
if (this.petOne != null) {
habbo.getClient().sendResponse(new PerkAllowancesComposer(this.getId(), PerkAllowancesComposer.CLOSE_WIDGET, ""));
}
if (this.petTwo.getUserId() != habbo.getHabboInfo().getId()) {
- Habbo owner = this.petTwo.getRoom().getHabbo(this.petTwo.getUserId());
+ Habbo owner = this.petTwo.getRoom().getRoomUnitManager().getRoomHabboById(this.petTwo.getUserId());
if (owner != null) {
owner.getClient().sendResponse(new PerkAllowancesComposer(this.getId(), PerkAllowancesComposer.CLOSE_WIDGET, ""));
}
@@ -142,19 +143,20 @@ public class InteractionPetBreedingNest extends HabboItem {
public void breed(Habbo habbo, String name) {
Emulator.getThreading().run(new QueryDeleteHabboItem(this.getId()));
- this.setExtradata("2");
- habbo.getHabboInfo().getCurrentRoom().updateItem(this);
+ this.setExtraData("2");
+ habbo.getRoomUnit().getRoom().updateItem(this);
- HabboItem box = this;
+ RoomItem box = this;
Emulator.getThreading().run(() -> {
Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient());
- habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ());
- offspring.setNeedsUpdate(true);
+
+ habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ());
+ offspring.setSqlUpdateNeeded(true);
offspring.run();
InteractionPetBreedingNest.this.freePets();
- habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box);
+ habbo.getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(box);
habbo.getClient().sendResponse(new NestBreedingSuccessComposer(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring)));
if (box.getBaseItem().getName().startsWith("pet_breeding_")) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
index 96a0932e..88cbd152 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
@@ -6,8 +6,14 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
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.rooms.*;
+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.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.PetClearPosture;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import org.slf4j.Logger;
@@ -26,13 +32,13 @@ public class InteractionPetDrink extends InteractionDefault {
super(set, baseItem);
}
- public InteractionPetDrink(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPetDrink(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canToggle(Habbo habbo, Room room) {
- return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), habbo.getRoomUnit().getCurrentLocation());
+ return RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), habbo.getRoomUnit().getCurrentPosition());
}
@Override
@@ -42,17 +48,17 @@ public class InteractionPetDrink extends InteractionDefault {
if (!this.canToggle(client.getHabbo(), room)) {
RoomTile closestTile = null;
- for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
- if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
+ for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()))) {
+ if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentPosition()))) {
closestTile = tile;
}
}
- if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
+ if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentPosition())) {
List onSuccess = new ArrayList<>();
onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1));
- client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
+ client.getHabbo().getRoomUnit().walkTo(closestTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
}
}
@@ -63,23 +69,23 @@ public class InteractionPetDrink extends InteractionDefault {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (this.getExtradata() == null || this.getExtradata().isEmpty())
- this.setExtradata("0");
+ if (this.getExtraData() == null || this.getExtraData().isEmpty())
+ this.setExtraData("0");
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null && pet.getPetData().haveDrinkItem(this) && pet.levelThirst >= 35) {
pet.clearPosture();
- pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
- pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
- pet.getRoomUnit().clearStatus();
- pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
+ pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
+ pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
+ pet.getRoomUnit().clearStatuses();
+ pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
pet.setPacketUpdate(true);
Emulator.getThreading().run(() -> {
pet.addThirst(-75);
this.change(room, -1);
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().clearStatuses();
new PetClearPosture(pet, RoomUnitStatus.EAT, null, true);
pet.setPacketUpdate(true);
}, 1000);
@@ -97,12 +103,12 @@ public class InteractionPetDrink extends InteractionDefault {
private void change(Room room, int amount) {
int state = 0;
- if (this.getExtradata() == null || this.getExtradata().isEmpty()) {
- this.setExtradata("0");
+ if (this.getExtraData() == null || this.getExtraData().isEmpty()) {
+ this.setExtraData("0");
}
try {
- state = Integer.parseInt(this.getExtradata());
+ state = Integer.parseInt(this.getExtraData());
} catch (Exception e) {
LOGGER.error("Caught exception", e);
}
@@ -116,8 +122,8 @@ public class InteractionPetDrink extends InteractionDefault {
state = 0;
}
- this.setExtradata(state + "");
- this.needsUpdate(true);
+ this.setExtraData(state + "");
+ this.setSqlUpdateNeeded(true);
room.updateItemState(this);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
index 92bf9bc3..5e606bcf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetFood.java
@@ -6,9 +6,10 @@ 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.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import com.eu.habbo.threading.runnables.PetEatAction;
@@ -20,28 +21,28 @@ public class InteractionPetFood extends InteractionDefault {
super(set, baseItem);
}
- public InteractionPetFood(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPetFood(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- if (this.getExtradata().length() == 0)
- this.setExtradata("0");
+ if (this.getExtraData().length() == 0)
+ this.setExtraData("0");
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null) {
if (pet.getPetData().haveFoodItem(this)) {
if (pet.levelHunger >= 35) {
pet.setTask(PetTasks.EAT);
- pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
- pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
+ pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
+ pet.getRoomUnit().clearStatuses();
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
- pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, "0");
+ pet.getRoomUnit().addStatus(RoomUnitStatus.EAT, "0");
room.sendComposer(new UserUpdateComposer(roomUnit).compose());
Emulator.getThreading().run(new PetEatAction(pet, this));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
index fef842ea..4a13ee51 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetToy.java
@@ -6,8 +6,14 @@ 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.*;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.PetClearPosture;
import java.sql.ResultSet;
@@ -16,32 +22,32 @@ import java.sql.SQLException;
public class InteractionPetToy extends InteractionDefault {
public InteractionPetToy(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionPetToy(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionPetToy(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
- for (Pet pet : room.getPetsAt(oldLocation)) {
- pet.getRoomUnit().clearStatus();
+ for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) {
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
for (Pet pet : room.getPetsOnItem(this)) {
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@@ -50,30 +56,32 @@ public class InteractionPetToy extends InteractionDefault {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
- if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) {
- if (pet.getEnergy() <= 35) {
- return;
- }
+ if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) {
+ if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) {
+ if (pet.getEnergy() <= 35) {
+ return;
+ }
- pet.setTask(PetTasks.PLAY);
- pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
- pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
- pet.getRoomUnit().clearStatus();
- pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
- pet.setPacketUpdate(true);
- HabboItem item = this;
- Emulator.getThreading().run(() -> {
- pet.addHappiness(25);
- item.setExtradata("0");
- room.updateItem(item);
- pet.getRoomUnit().clearStatus();
- new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
+ pet.setTask(PetTasks.PLAY);
+ pet.getRoomUnit().walkTo(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
+ pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
+ pet.getRoomUnit().clearStatuses();
+ pet.getRoomUnit().addStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
pet.setPacketUpdate(true);
- }, ((long)(Emulator.getRandom().nextInt(20) * 500) + 2500));
- this.setExtradata("1");
- room.updateItemState(this);
+ RoomItem item = this;
+ Emulator.getThreading().run(() -> {
+ pet.addHappiness(25);
+ item.setExtraData("0");
+ room.updateItem(item);
+ pet.getRoomUnit().clearStatuses();
+ new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
+ pet.setPacketUpdate(true);
+ }, ((long) (Emulator.getRandom().nextInt(20) * 500) + 2500));
+ this.setExtraData("1");
+ room.updateItemState(this);
+ }
}
}
@@ -81,19 +89,19 @@ public class InteractionPetToy extends InteractionDefault {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java
index 9c16421f..acc70222 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTrampoline.java
@@ -6,7 +6,12 @@ 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.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.PetClearPosture;
import java.sql.ResultSet;
@@ -15,12 +20,12 @@ import java.sql.SQLException;
public class InteractionPetTrampoline extends InteractionDefault {
public InteractionPetTrampoline(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ this.setExtraData("0");
}
- public InteractionPetTrampoline(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ public InteractionPetTrampoline(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.setExtraData("0");
}
@Override
@@ -28,10 +33,10 @@ public class InteractionPetTrampoline extends InteractionDefault {
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
- for (Pet pet : room.getPetsAt(oldLocation)) {
+ for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) {
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
pet.setPacketUpdate(true);
}
@@ -39,7 +44,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
@Override
public void onPickUp(Room room) {
- this.setExtradata("0");
+ this.setExtraData("0");
for (Pet pet : room.getPetsOnItem(this)) {
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
@@ -51,26 +56,28 @@ public class InteractionPetTrampoline extends InteractionDefault {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
- if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) {
- if (pet.getEnergy() <= 35) {
- return;
- }
+ if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) {
+ if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) {
+ if (pet.getEnergy() <= 35) {
+ return;
+ }
- pet.clearPosture();
- pet.setTask(PetTasks.JUMP);
- pet.getRoomUnit().setStatus(RoomUnitStatus.JUMP, "");
- Emulator.getThreading().run(() -> {
- new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false);
- pet.getRoomUnit().setGoalLocation(room.getRandomWalkableTile());
- this.setExtradata("0");
+ pet.clearPosture();
+ pet.setTask(PetTasks.JUMP);
+ pet.getRoomUnit().addStatus(RoomUnitStatus.JUMP, "");
+ Emulator.getThreading().run(() -> {
+ new PetClearPosture(pet, RoomUnitStatus.JUMP, null, false);
+ pet.getRoomUnit().walkTo(room.getRandomWalkableTile());
+ this.setExtraData("0");
+ room.updateItemState(this);
+ }, 4000);
+ pet.addHappiness(25);
+
+ this.setExtraData("1");
room.updateItemState(this);
- }, 4000);
- pet.addHappiness(25);
-
- this.setExtradata("1");
- room.updateItemState(this);
+ }
}
}
@@ -78,10 +85,10 @@ public class InteractionPetTrampoline extends InteractionDefault {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null) {
- this.setExtradata("0");
+ this.setExtraData("0");
room.updateItem(this);
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
pet.setPacketUpdate(true);
@@ -90,7 +97,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
index 7ff78077..1b381e01 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
@@ -4,7 +4,13 @@ import com.eu.habbo.Emulator;
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.rooms.*;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.threading.runnables.PetClearPosture;
import java.sql.ResultSet;
@@ -15,21 +21,21 @@ public class InteractionPetTree extends InteractionDefault {
super(set, baseItem);
}
- public InteractionPetTree(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionPetTree(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
- for (Pet pet : room.getPetsAt(oldLocation)) {
- pet.getRoomUnit().clearStatus();
+ for (Pet pet : room.getRoomUnitManager().getPetsAt(oldLocation)) {
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@Override
public void onPickUp(Room room) {
for (Pet pet : room.getPetsOnItem(this)) {
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@@ -38,39 +44,41 @@ public class InteractionPetTree extends InteractionDefault {
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
- if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoalLocation())) {
- RoomUnitStatus task = switch (pet.getTask()) {
- case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE;
- case SWING -> RoomUnitStatus.SWING;
- case ROLL -> RoomUnitStatus.ROLL;
- default -> RoomUnitStatus.HANG;
- };
- if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) {
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
+ if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem())) {
+ if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getTargetPosition())) {
+ RoomUnitStatus task = switch (pet.getTask()) {
+ case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE;
+ case SWING -> RoomUnitStatus.SWING;
+ case ROLL -> RoomUnitStatus.ROLL;
+ default -> RoomUnitStatus.HANG;
+ };
+ if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) {
- pet.getRoomUnit().setCanWalk(false);
- pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
- pet.getRoomUnit().clearStatus();
- pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
- pet.setPacketUpdate(true);
- RoomUnitStatus finalTask = task;
- Emulator.getThreading().run(() -> {
- pet.addHappiness(25);
- pet.getRoomUnit().clearStatus();
- new PetClearPosture(pet, finalTask, null, true);
- if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentLocation())) {
- pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
- } else {
- pet.clearPosture();
- }
- pet.getRoomUnit().setCanWalk(true);
- pet.setPacketUpdate(true);
- }, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500));
- } else {
- pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
- pet.getRoomUnit().clearStatus();
- pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
- pet.setPacketUpdate(true);
+ pet.getRoomUnit().setCanWalk(false);
+ pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
+ pet.getRoomUnit().clearStatuses();
+ pet.getRoomUnit().addStatus(task, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
+ pet.setPacketUpdate(true);
+ RoomUnitStatus finalTask = task;
+ Emulator.getThreading().run(() -> {
+ pet.addHappiness(25);
+ pet.getRoomUnit().clearStatuses();
+ new PetClearPosture(pet, finalTask, null, true);
+ if (this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getCurrentPosition())) {
+ pet.getRoomUnit().addStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
+ } else {
+ pet.clearPosture();
+ }
+ pet.getRoomUnit().setCanWalk(true);
+ pet.setPacketUpdate(true);
+ }, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500));
+ } else {
+ pet.getRoomUnit().setRotation(RoomRotation.values()[this.getRotation()]);
+ pet.getRoomUnit().clearStatuses();
+ pet.getRoomUnit().addStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentPosition().getStackHeight() + "");
+ pet.setPacketUpdate(true);
+ }
}
}
}
@@ -79,17 +87,17 @@ public class InteractionPetTree extends InteractionDefault {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
if (pet != null) {
- pet.getRoomUnit().clearStatus();
+ pet.getRoomUnit().clearStatuses();
pet.setPacketUpdate(true);
}
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Pet pet = room.getPet(roomUnit);
+ Pet pet = room.getRoomUnitManager().getPetByRoomUnit(roomUnit);
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem());
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
index a016a1a2..19cadf05 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
@@ -5,7 +5,8 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import java.sql.ResultSet;
@@ -17,14 +18,14 @@ public class InteractionTotemHead extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTotemHead(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTotemHead(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public TotemType getTotemType() {
int extraData;
try {
- extraData = Integer.parseInt(this.getExtradata());
+ extraData = Integer.parseInt(this.getExtraData());
} catch(NumberFormatException ex) {
extraData = 0;
}
@@ -37,7 +38,7 @@ public class InteractionTotemHead extends InteractionDefault {
public TotemColor getTotemColor() {
int extraData;
try {
- extraData = Integer.parseInt(this.getExtradata());
+ extraData = Integer.parseInt(this.getExtraData());
}catch(NumberFormatException ex) {
extraData = 0;
}
@@ -50,31 +51,32 @@ public class InteractionTotemHead extends InteractionDefault {
private void update(Room room, RoomTile tile) {
InteractionTotemLegs legs = null;
- for(HabboItem item : room.getItemsAt(tile)) {
- if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
- legs = (InteractionTotemLegs)item;
+ for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) {
+ if(item instanceof InteractionTotemLegs) {
+ if (item.getCurrentZ() < this.getCurrentZ()) legs = (InteractionTotemLegs) item;
+ }
}
if(legs == null)
return;
- this.setExtradata(((4 * this.getTotemType().getType()) + legs.getTotemColor().getColor()) - 1 + "");
+ this.setExtraData(((4 * this.getTotemType().getType()) + legs.getTotemColor().getColor()) - 1 + "");
}
public void updateTotemState(Room room) {
- updateTotemState(room, room.getLayout().getTile(this.getX(), this.getY()));
+ updateTotemState(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
}
public void updateTotemState(Room room, RoomTile tile) {
- this.setExtradata(getTotemType().getType() - 1 + "");
+ this.setExtraData(getTotemType().getType() - 1 + "");
update(room, tile);
- this.needsUpdate(true);
+ this.setSqlUpdateNeeded(true);
room.updateItem(this);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) {
- if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ if (!((client != null && room != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
return;
TotemType newType = TotemType.fromInt(getTotemType().getType() + 1);
@@ -82,7 +84,7 @@ public class InteractionTotemHead extends InteractionDefault {
newType = TotemType.TROLL;
}
- this.setExtradata(newType.getType() - 1 + "");
+ this.setExtraData(newType.getType() - 1 + "");
updateTotemState(room);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
index f12a5193..db588c04 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
@@ -5,7 +5,8 @@ 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.RoomTile;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import java.sql.ResultSet;
@@ -16,14 +17,14 @@ public class InteractionTotemLegs extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTotemLegs(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTotemLegs(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public TotemType getTotemType() {
int extraData;
try {
- extraData = Integer.parseInt(this.getExtradata());
+ extraData = Integer.parseInt(this.getExtraData());
} catch(NumberFormatException ex) {
extraData = 0;
}
@@ -33,7 +34,7 @@ public class InteractionTotemLegs extends InteractionDefault {
public TotemColor getTotemColor() {
int extraData;
try {
- extraData = Integer.parseInt(this.getExtradata());
+ extraData = Integer.parseInt(this.getExtraData());
} catch(NumberFormatException ex) {
extraData = 0;
}
@@ -41,9 +42,10 @@ public class InteractionTotemLegs extends InteractionDefault {
}
private void updateHead(Room room, RoomTile tile) {
- for(HabboItem item : room.getItemsAt(tile)) {
- if(item instanceof InteractionTotemHead && item.getZ() > this.getZ())
- ((InteractionTotemHead)item).updateTotemState(room);
+ for(RoomItem item : room.getRoomItemManager().getItemsAt(tile)) {
+ if(item instanceof InteractionTotemHead) {
+ if (item.getCurrentZ() > this.getCurrentZ()) ((InteractionTotemHead) item).updateTotemState(room);
+ }
}
}
@@ -51,10 +53,10 @@ public class InteractionTotemLegs extends InteractionDefault {
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (room == null || !((client != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ if (room == null || !((client != null && room.getRoomRightsManager().hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
return;
- updateHead(room, room.getLayout().getTile(this.getX(), this.getY()));
+ updateHead(room, room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
index 6c9ddb3f..fae2bab2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
@@ -4,7 +4,9 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
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.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
@@ -15,14 +17,14 @@ public class InteractionTotemPlanet extends InteractionDefault {
super(set, baseItem);
}
- public InteractionTotemPlanet(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public InteractionTotemPlanet(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
public TotemPlanetType getPlanetType() {
int extraData;
try {
- extraData = Integer.parseInt(this.getExtradata());
+ extraData = Integer.parseInt(this.getExtraData());
} catch(NumberFormatException ex) {
extraData = 0;
}
@@ -31,7 +33,7 @@ public class InteractionTotemPlanet extends InteractionDefault {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
- if(client.getHabbo().getHabboInfo().getId() != this.getUserId()) {
+ if(client.getHabbo().getHabboInfo().getId() != this.getOwnerInfo().getId()) {
super.onClick(client, room, objects);
return;
}
@@ -39,11 +41,13 @@ public class InteractionTotemPlanet extends InteractionDefault {
InteractionTotemLegs legs = null;
InteractionTotemHead head = null;
- THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY()));
+ RoomTile tile = room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY());
+ THashSet items = room.getRoomItemManager().getItemsAt(tile);
- for(HabboItem item : items) {
- if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
- legs = (InteractionTotemLegs)item;
+ for(RoomItem item : items) {
+ if(item instanceof InteractionTotemLegs) {
+ if (item.getCurrentZ() < this.getCurrentZ()) legs = (InteractionTotemLegs) item;
+ }
}
if(legs == null) {
@@ -51,9 +55,10 @@ public class InteractionTotemPlanet extends InteractionDefault {
return;
}
- for(HabboItem item : items) {
- if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ())
- head = (InteractionTotemHead)item;
+ for(RoomItem item : items) {
+ if(item instanceof InteractionTotemHead) {
+ if (item.getCurrentZ() > legs.getCurrentZ()) head = (InteractionTotemHead) item;
+ }
}
if(head == null) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java
index b6027a06..1521880d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredSettings.java
@@ -1,63 +1,88 @@
package com.eu.habbo.habbohotel.items.interactions.wired;
-public class WiredSettings {
- private int[] intParams;
+import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.IWiredSettings;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+public class WiredSettings implements IWiredSettings {
+ @Getter
+ @Setter
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List integerParams;
+
+ @Getter
+ @Setter
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
private String stringParam;
- private int[] furniIds;
- private int stuffTypeSelectionCode;
+
+ @Getter
+ @Setter
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List itemIds;
+
+ @Getter
+ @Setter
+ @JsonInclude(JsonInclude.Include.NON_DEFAULT)
private int delay;
- public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode, int delay)
- {
- this.furniIds = furniIds;
- this.intParams = intParams;
- this.stringParam = stringParam;
- this.stuffTypeSelectionCode = stuffTypeSelectionCode;
- this.delay = delay;
+ @Getter
+ @Setter
+ @JsonInclude(JsonInclude.Include.NON_EMPTY)
+ private List matchParams;
+
+ @Getter
+ @Setter
+ @JsonIgnore
+ private int selectionType;
+
+ public WiredSettings() {
+ this.itemIds = new ArrayList<>();
+ this.integerParams = new ArrayList<>();
+ this.stringParam = "";
+ this.delay = 0;
+ this.matchParams = new ArrayList<>();
+ this.selectionType = 0;
}
- public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode)
- {
- this(intParams, stringParam, furniIds, stuffTypeSelectionCode, 0);
+ public HashSet getItems(Room room) {
+ HashSet items = new HashSet<>();
+
+ if(this.itemIds.size() == 0) {
+ return items;
+ }
+
+ for(int i = 0; i < this.itemIds.size(); i++) {
+ RoomItem item = room.getRoomItemManager().getRoomItemById(this.itemIds.get(i));
+
+ if(item == null || item.getRoomId() == 0) {
+ this.itemIds.remove(i);
+ if(!matchParams.isEmpty()) {
+ this.matchParams.removeIf(setting -> setting.getItem_id() == item.getId());
+ }
+ continue;
+ }
+
+ items.add(item);
+ }
+
+ return items;
}
- public int getStuffTypeSelectionCode() {
- return stuffTypeSelectionCode;
- }
-
- public void setStuffTypeSelectionCode(int stuffTypeSelectionCode) {
- this.stuffTypeSelectionCode = stuffTypeSelectionCode;
- }
-
- public int[] getFurniIds() {
- return furniIds;
- }
-
- public void setFurniIds(int[] furniIds) {
- this.furniIds = furniIds;
- }
-
- public String getStringParam() {
- return stringParam;
- }
-
- public void setStringParam(String stringParam) {
- this.stringParam = stringParam;
- }
-
- public int[] getIntParams() {
- return intParams;
- }
-
- public void setIntParams(int[] intParams) {
- this.intParams = intParams;
- }
-
- public int getDelay() {
- return delay;
- }
-
- public void setDelay(int delay) {
- this.delay = delay;
+ public void dispose() {
+ this.integerParams.clear();
+ this.itemIds.clear();
+ this.stringParam = "";
+ this.delay = 0;
+ this.matchParams.clear();
+ this.selectionType = 0;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java
deleted file mode 100644
index 81dd0284..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/WiredTriggerReset.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired;
-
-public interface WiredTriggerReset {
- void resetTimer();
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java
index 1774a6de..ab5860ef 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionDateRangeActive.java
@@ -3,12 +3,10 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -18,10 +16,8 @@ import java.sql.SQLException;
* a given range.
*/
public class WiredConditionDateRangeActive extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.DATE_RANGE;
-
- private int startDate; // the start of the date range
- private int endDate; // the end of the date range
+ public final int PARAM_START_DATE = 0;
+ public final int PARAM_END_DATE = 1;
/**
* Creates a new instance of this class.
@@ -36,58 +32,14 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
/**
* Creates a new instance of this class.
* @param id The ID of this item.
- * @param userId The ID of the user that owns this item.
+ * @param ownerInfo The info of the user that owns this item.
* @param item The item this instance is associated with.
* @param extradata Additional data associated with this item.
* @param limitedStack The amount of items in this stack (if this item is stackable).
* @param limitedSells The amount of items that can be sold from this stack (if this item is sellable).
*/
- public WiredConditionDateRangeActive(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- /**
- * Returns the {@link WiredConditionType} of this object.
- * @return the type of this wired condition
- */
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- /**
- * Sends information about this wired condition to the client.
- * @param message the message to send data with
- * @param room the room this wired condition is in
- */
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(2);
- message.appendInt(this.startDate);
- message.appendInt(this.endDate);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.startDate);
- message.appendInt(this.endDate);
- }
-
- /**
- * Saves the given {@link WiredSettings} object to this wired condition.
- * @param settings the settings to save
- * @return {@code true} if the settings were saved successfully, {@code false} otherwise
- * */
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 2) return false;
- this.startDate = settings.getIntParams()[0];
- this.endDate = settings.getIntParams()[1];
- return true;
+ public WiredConditionDateRangeActive(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
/**
@@ -101,72 +53,27 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
int time = Emulator.getIntUnixTimestamp();
- return this.startDate < time && this.endDate >= time;
+
+ int startDate = this.getWiredSettings().getIntegerParams().get(PARAM_START_DATE);
+ int endDate = this.getWiredSettings().getIntegerParams().get(PARAM_END_DATE);
+
+ return startDate < time && endDate >= time;
}
- /**
- * Gets the wired data for this wired condition in JSON format.
- * @return the wired data in JSON format
- */
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.startDate,
- this.endDate
- ));
- }
-
- /**
- * Loads the wired data for this wired condition from a database.
- * @param set the ResultSet object to get data from
- * @param room the room that this wired condition is in
- * @throws SQLException if an error occurs while getting data from the ResultSet object
- */
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.startDate = data.startDate;
- this.endDate = data.endDate;
- } else {
- String[] data = wiredData.split("\t");
-
- if (data.length == 2) {
- try {
- this.startDate = Integer.parseInt(data[0]);
- this.endDate = Integer.parseInt(data[1]);
- } catch (Exception ignored) {
- }
- }
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
/**
- * Called when this item is picked up. Resets the startDate and endDate member variables to 0.
+ * Returns the {@link WiredConditionType} of this object.
+ * @return the type of this wired condition
*/
@Override
- public void onPickUp() {
- this.startDate = 0;
- this.endDate = 0;
- }
-
- /**
- * A nested class for storing the wired data for this wired condition in JSON format.
- */
- static class JsonData {
- int startDate;
- int endDate;
-
- /**
- * Creates a new instance of this class.
- * @param startDate the start of the date range
- * @param endDate the end of the date range
- */
- public JsonData(int startDate, int endDate) {
- this.startDate = startDate;
- this.endDate = endDate;
- }
+ public WiredConditionType getType() {
+ return WiredConditionType.DATE_RANGE;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
index 752454a8..cd6e7266 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveFurni.java
@@ -1,166 +1,66 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.FURNI_HAS_FURNI;
-
- private boolean all;
- private final THashSet items;
+ public final int PARAM_ALL_FURNI = 0;
public WiredConditionFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.items = new THashSet<>();
}
- public WiredConditionFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new THashSet<>();
+ public WiredConditionFurniHaveFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
-
- if (this.items.isEmpty())
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
return true;
+ }
- if (this.all) {
- return this.items.stream().allMatch(item -> {
- double minZ = item.getZ() + Item.getCurrentHeight(item);
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
+ boolean allFurni = this.getWiredSettings().getIntegerParams().get(PARAM_ALL_FURNI) == 1;
+
+ if (allFurni) {
+ return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
+ double minZ = item.getCurrentZ() + Item.getCurrentHeight(item);
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> {
+ if (matchedItem == item) return false;
+ return matchedItem.getCurrentZ() >= minZ;
+ }));
});
} else {
- return this.items.stream().anyMatch(item -> {
- double minZ = item.getZ() + Item.getCurrentHeight(item);
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return occupiedTiles.stream().anyMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
+ return this.getWiredSettings().getItems(room).stream().anyMatch(item -> {
+ double minZ = item.getCurrentZ() + Item.getCurrentHeight(item);
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return occupiedTiles.stream().anyMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> {
+ if (matchedItem == item) return false;
+ return matchedItem.getCurrentZ() >= minZ;
+ }));
});
}
}
@Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.all,
- this.items.stream().map(HabboItem::getId).toList()
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.all = data.all;
-
- data.itemIds.stream().mapToInt(id -> id).mapToObj(room::getHabboItem).filter(Objects::nonNull).forEach(this.items::add);
-
- } else {
- String[] data = wiredData.split(":");
-
- if (data.length >= 1) {
- this.all = (data[0].equals("1"));
-
- if (data.length == 2) {
- String[] itemsSplit = data[1].split(";");
- Arrays.stream(itemsSplit).map(s -> room.getHabboItem(Integer.parseInt(s))).filter(Objects::nonNull).forEach(this.items::add);
- }
- }
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
- @Override
- public void onPickUp() {
- this.items.clear();
- this.all = false;
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.all ? 1 : 0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if (settings.getIntParams().length < 1) return false;
-
- this.all = settings.getIntParams()[0] == 1;
-
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
-
- if (item != null)
- this.items.add(item);
- }
-
- return true;
- }
- return false;
- }
-
- private void refresh() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- this.items.removeIf(i -> room.getHabboItem(i.getId()) == null);
- }
-
- static class JsonData {
- boolean all;
- List itemIds;
-
- public JsonData(boolean all, List itemIds) {
- this.all = all;
- this.itemIds = itemIds;
- }
+ return WiredConditionType.FURNI_HAS_FURNI;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java
deleted file mode 100644
index abae0d25..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveHabbo.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.pets.Pet;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
- protected THashSet items;
-
- public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- this.items = new THashSet<>();
- }
-
- public WiredConditionFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new THashSet<>();
- }
-
- @Override
- public void onPickUp() {
- this.items.clear();
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
-
- if (this.items.isEmpty())
- return true;
-
- Collection habbos = room.getHabbos();
- Collection bots = room.getCurrentBots().valueCollection();
- Collection pets = room.getCurrentPets().valueCollection();
-
- return this.items.stream().allMatch(item -> {
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
- bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
- pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
- });
- }
-
- @Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
-
- for(int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = wiredData.split(":");
-
- if (data.length >= 1) {
-
- String[] items = data[1].split(";");
-
- for (String s : items) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- int count = settings.getFurniIds().length;
-
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
-
- if (item != null)
- this.items.add(item);
- }
-
- return true;
- }
-
- return false;
- }
-
- private void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (room.getHabboItem(item.getId()) == null)
- items.add(item);
- }
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- }
-
- static class JsonData {
- List itemIds;
-
- public JsonData(List itemIds) {
- this.itemIds = itemIds;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java
new file mode 100644
index 00000000..498f74ff
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniHaveRoom.java
@@ -0,0 +1,50 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.bots.Bot;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.pets.Pet;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+import gnu.trove.set.hash.THashSet;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+
+public class WiredConditionFurniHaveRoom extends InteractionWiredCondition {
+ public WiredConditionFurniHaveRoom(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionFurniHaveRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if (this.getWiredSettings().getItemIds().isEmpty()) {
+ return true;
+ }
+
+ Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values();
+ Collection bots = room.getRoomUnitManager().getCurrentBots().values();
+ Collection pets = room.getRoomUnitManager().getCurrentPets().values();
+
+ return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) ||
+ bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) ||
+ pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition()));
+ });
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.FURNI_HAVE_HABBO;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
index 38b06c51..7e32cc42 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
@@ -1,161 +1,44 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.List;
-import java.util.stream.Collectors;
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.STUFF_IS;
-
- private final THashSet items = new THashSet<>();
-
public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void onPickUp() {
- this.items.clear();
+ public WiredConditionFurniTypeMatch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return true;
+ }
- if(items.isEmpty())
- return false;
+ if(stuff.length == 0) {
+ return true;
+ }
- if (stuff != null) {
- if (stuff.length >= 1) {
- if (stuff[0] instanceof HabboItem triggeringItem) {
- return this.items.stream().anyMatch(item -> item == triggeringItem);
- }
- }
+ if (stuff[0] instanceof RoomItem triggeringItem) {
+ return this.getWiredSettings().getItems(room).stream().anyMatch(item -> item == triggeringItem);
}
return false;
}
- @Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
-
- for(int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = wiredData.split(";");
-
- for (String s : data) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null) {
- this.items.add(item);
- }
- }
- }
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
- }
- }
-
- return true;
- }
-
- private void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (room.getHabboItem(item.getId()) == null)
- items.add(item);
- }
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- }
-
- static class JsonData {
- List itemIds;
-
- public JsonData(List itemIds) {
- this.itemIds = itemIds;
- }
+ return WiredConditionType.STUFF_IS;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java
index d9c1d1ad..243bc2f6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionGroupMember.java
@@ -2,74 +2,37 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionGroupMember extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_IN_GROUP;
-
public WiredConditionGroupMember(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionGroupMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionGroupMember(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (room.getGuildId() == 0)
+ if (room.getRoomInfo().getGuild().getId() == 0) {
return false;
+ }
- Habbo habbo = room.getHabbo(roomUnit);
-
- return habbo != null && habbo.getHabboStats().hasGuild(room.getGuildId());
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) {
-
- }
-
- @Override
- public void onPickUp() {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
+ return habbo != null && habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId());
}
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- return true;
+ return WiredConditionType.ACTOR_IN_GROUP;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java
deleted file mode 100644
index 839b7db4..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboCount.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboCount extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.USER_COUNT;
-
- private int lowerLimit = 0;
- private int upperLimit = 50;
-
- public WiredConditionHabboCount(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- int count = room.getUserCount();
-
- return count >= this.lowerLimit && count <= this.upperLimit;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.lowerLimit,
- this.upperLimit
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.lowerLimit = data.lowerLimit;
- this.upperLimit = data.upperLimit;
- } else {
- String[] data = wiredData.split(":");
-
- this.lowerLimit = Integer.parseInt(data[0]);
- this.upperLimit = Integer.parseInt(data[1]);
- }
- }
-
- @Override
- public void onPickUp() {
- this.lowerLimit = 0;
- this.upperLimit = 50;
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(2);
- message.appendInt(this.lowerLimit);
- message.appendInt(this.upperLimit);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 2) return false;
- this.lowerLimit = settings.getIntParams()[0];
- this.upperLimit = settings.getIntParams()[1];
-
- return true;
- }
-
- static class JsonData {
- int lowerLimit;
- int upperLimit;
-
- public JsonData(int lowerLimit, int upperLimit) {
- this.lowerLimit = lowerLimit;
- this.upperLimit = upperLimit;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java
deleted file mode 100644
index 52f951f7..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasEffect.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_EFFECT;
-
- protected int effectId = 0;
-
- public WiredConditionHabboHasEffect(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (roomUnit == null) return false;
- return roomUnit.getEffectId() == this.effectId;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.effectId
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.effectId = data.effectId;
- } else {
- this.effectId = Integer.parseInt(wiredData);
- }
- }
-
- @Override
- public void onPickUp() {
- this.effectId = 0;
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(true);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.effectId + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.effectId = settings.getIntParams()[0];
-
- return true;
- }
-
- static class JsonData {
- int effectId;
-
- public JsonData(int effectId) {
- this.effectId = effectId;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java
deleted file mode 100644
index 5f7f8b0f..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboHasHandItem.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import lombok.extern.slf4j.Slf4j;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-@Slf4j
-public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
-
- public static final WiredConditionType type = WiredConditionType.ACTOR_HAS_HANDITEM;
-
- private int handItem;
-
- public WiredConditionHabboHasHandItem(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboHasHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.handItem);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.handItem = settings.getIntParams()[0];
-
- return true;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (roomUnit == null) return false;
- return roomUnit.getHandItem() == this.handItem;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.handItem
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) {
- try {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.handItem = data.handItemId;
- } else {
- this.handItem = Integer.parseInt(wiredData);
- }
- } catch (Exception e) {
- log.error("Caught exception", e);
- }
- }
-
- @Override
- public void onPickUp() {
- this.handItem = 0;
- }
-
- static class JsonData {
- int handItemId;
-
- public JsonData(int handItemId) {
- this.handItemId = handItemId;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java
deleted file mode 100644
index 81831829..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionHabboWearsBadge.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboBadge;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_WEARS_BADGE;
-
- protected String badge = "";
-
- public WiredConditionHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) {
- for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) {
- if (badge.getCode().equalsIgnoreCase(this.badge)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.badge
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.badge = data.badge;
- } else {
- this.badge = wiredData;
- }
- }
-
- @Override
- public void onPickUp() {
- this.badge = "";
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.badge);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- this.badge = settings.getStringParam();
-
- return true;
- }
-
- static class JsonData {
- String badge;
-
- public JsonData(String badge) {
- this.badge = badge;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
index 9c75f4f3..439d7842 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
@@ -3,95 +3,40 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.TIME_LESS_THAN;
-
- private int cycles;
+ public final int PARAM_CYCLE = 0;
public WiredConditionLessTimeElapsed(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionLessTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionLessTimeElapsed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < this.cycles;
+ int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE);
+ return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 < cycles;
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.cycles
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- try {
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.cycles = data.cycles;
- } else {
- if (!wiredData.equals(""))
- this.cycles = Integer.parseInt(wiredData);
- }
- } catch (Exception ignored) {
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
- @Override
- public void onPickUp() {
- this.cycles = 0;
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.cycles);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.cycles = settings.getIntParams()[0];
- return true;
- }
-
- static class JsonData {
- int cycles;
-
- public JsonData(int cycles) {
- this.cycles = cycles;
- }
+ return WiredConditionType.TIME_LESS_THAN;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
index e3a68648..148fe15e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMatchStatePosition.java
@@ -1,18 +1,15 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
+import lombok.Getter;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -20,115 +17,54 @@ import java.util.ArrayList;
import java.util.List;
public class WiredConditionMatchStatePosition extends InteractionWiredCondition implements InteractionWiredMatchFurniSettings {
- public static final WiredConditionType type = WiredConditionType.MATCH_SSHOT;
-
- private final THashSet settings;
-
- private boolean state;
- private boolean position;
- private boolean direction;
+ public final int PARAM_STATE = 0;
+ public final int PARAM_ROTATION = 1;
+ public final int PARAM_POSITION = 2;
+ @Getter
+ private List matchSettings;
public WiredConditionMatchStatePosition(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.settings = new THashSet<>();
}
- public WiredConditionMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.settings = new THashSet<>();
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.settings.size());
-
- for (WiredMatchFurniSetting item : this.settings)
- message.appendInt(item.getItem_id());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(4);
- message.appendInt(this.state ? 1 : 0);
- message.appendInt(this.direction ? 1 : 0);
- message.appendInt(this.position ? 1 : 0);
- message.appendInt(10);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 3) return false;
- this.state = settings.getIntParams()[0] == 1;
- this.direction = settings.getIntParams()[1] == 1;
- this.position = settings.getIntParams()[2] == 1;
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room == null)
- return true;
-
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.settings.clear();
-
- for (int i = 0; i < count; i++) {
- int itemId = settings.getFurniIds()[i];
- HabboItem item = room.getHabboItem(itemId);
-
- if (item != null)
- this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()));
- }
-
- return true;
+ public WiredConditionMatchStatePosition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (this.settings.isEmpty())
+ if(this.getWiredSettings().getItemIds().isEmpty() && this.getWiredSettings().getMatchParams().isEmpty()) {
return true;
-
- THashSet s = new THashSet<>();
-
- for (WiredMatchFurniSetting setting : this.settings) {
- HabboItem item = room.getHabboItem(setting.getItem_id());
-
- if (item != null) {
- if (this.state) {
- if (!item.getExtradata().equals(setting.getState()))
- return false;
- }
-
- if (this.position) {
- if (!(setting.getX() == item.getX() && setting.getY() == item.getY()))
- return false;
- }
-
- if (this.direction) {
- if (setting.getRotation() != item.getRotation())
- return false;
- }
- } else {
- s.add(setting);
- }
}
- if (!s.isEmpty()) {
- for (WiredMatchFurniSetting setting : s) {
- this.settings.remove(setting);
+ boolean state = this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1;
+ boolean position = this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1;
+ boolean rotation = this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1;
+ this.matchSettings = this.getWiredSettings().getMatchParams();
+
+ for(RoomItem item : this.getWiredSettings().getItems(room)) {
+ WiredMatchFurniSetting furniSettings = this.matchSettings.stream().filter(settings -> settings.getItem_id() == item.getId()).findAny().orElse(null);
+
+ if(furniSettings == null) {
+ continue;
+ }
+
+ if(state) {
+ if(!item.getExtraData().equals(furniSettings.getState())) {
+ return false;
+ }
+ }
+
+ if(position) {
+ if (!(furniSettings.getX() == item.getCurrentPosition().getX() && furniSettings.getY() == item.getCurrentPosition().getY())) {
+ return false;
+ }
+ }
+
+ if(rotation) {
+ if (furniSettings.getRotation() != item.getRotation()) {
+ return false;
+ }
}
}
@@ -136,103 +72,43 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.state,
- this.position,
- this.direction,
- new ArrayList<>(this.settings)
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.state = data.state;
- this.position = data.position;
- this.direction = data.direction;
- this.settings.addAll(data.settings);
- } else {
- String[] data = wiredData.split(":");
-
- int itemCount = Integer.parseInt(data[0]);
-
- String[] items = data[1].split(";");
-
- for (int i = 0; i < itemCount; i++) {
- String[] stuff = items[i].split("-");
-
- if (stuff.length >= 5)
- this.settings.add(new WiredMatchFurniSetting(Integer.parseInt(stuff[0]), stuff[1], Integer.parseInt(stuff[2]), Integer.parseInt(stuff[3]), Integer.parseInt(stuff[4])));
- }
-
- this.state = data[2].equals("1");
- this.direction = data[3].equals("1");
- this.position = data[4].equals("1");
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ this.getWiredSettings().getIntegerParams().add(0);
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
@Override
- public void onPickUp() {
- this.settings.clear();
- this.direction = false;
- this.position = false;
- this.state = false;
- }
+ public void saveAdditionalData(Room room) {
+ List matchSettings = new ArrayList<>();
- private void refresh() {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- THashSet remove = new THashSet<>();
-
- for (WiredMatchFurniSetting setting : this.settings) {
- HabboItem item = room.getHabboItem(setting.getItem_id());
- if (item == null) {
- remove.add(setting);
- }
- }
-
- for (WiredMatchFurniSetting setting : remove) {
- this.settings.remove(setting);
- }
+ for (RoomItem item : this.getWiredSettings().getItems(room)) {
+ WiredMatchFurniSetting settings = new WiredMatchFurniSetting(item.getId(), item.getExtraData(), item.getRotation(), item.getCurrentPosition().getX(), item.getCurrentPosition().getY());
+ matchSettings.add(settings);
}
- }
- @Override
- public THashSet getMatchFurniSettings() {
- return this.settings;
+ this.getWiredSettings().setMatchParams(matchSettings);
}
@Override
public boolean shouldMatchState() {
- return this.state;
+ return this.getWiredSettings().getIntegerParams().get(PARAM_STATE) == 1;
}
@Override
public boolean shouldMatchRotation() {
- return this.direction;
+ return this.getWiredSettings().getIntegerParams().get(PARAM_ROTATION) == 1;
}
@Override
public boolean shouldMatchPosition() {
- return this.position;
+ return this.getWiredSettings().getIntegerParams().get(PARAM_POSITION) == 1;
}
- static class JsonData {
- boolean state;
- boolean position;
- boolean direction;
- List settings;
-
- public JsonData(boolean state, boolean position, boolean direction, List settings) {
- this.state = state;
- this.position = position;
- this.direction = direction;
- this.settings = settings;
- }
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.MATCH_SSHOT;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
index ea0b85f8..4b968654 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
@@ -3,95 +3,40 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
- private static final WiredConditionType type = WiredConditionType.TIME_MORE_THAN;
-
- private int cycles;
+ public final int PARAM_CYCLE = 0;
public WiredConditionMoreTimeElapsed(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionMoreTimeElapsed(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionMoreTimeElapsed(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > this.cycles;
+ int cycles = this.getWiredSettings().getIntegerParams().get(PARAM_CYCLE);
+ return (Emulator.getIntUnixTimestamp() - room.getLastTimerReset()) / 0.5 > cycles;
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.cycles
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- try {
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.cycles = data.cycles;
- } else {
- if (!wiredData.equals(""))
- this.cycles = Integer.parseInt(wiredData);
- }
- } catch (Exception ignored) {
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
- @Override
- public void onPickUp() {
- this.cycles = 0;
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.cycles);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.cycles = settings.getIntParams()[0];
- return true;
- }
-
- static class JsonData {
- int cycles;
-
- public JsonData(int cycles) {
- this.cycles = cycles;
- }
+ return WiredConditionType.TIME_MORE_THAN;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
index 05feda6b..7d6c9d76 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
@@ -1,182 +1,69 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.List;
-import java.util.stream.Collectors;
public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
-
- private boolean all;
- private final THashSet items;
+ public final int PARAM_ALL_FURNI = 0;
public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.items = new THashSet<>();
}
- public WiredConditionNotFurniHaveFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new THashSet<>();
+ public WiredConditionNotFurniHaveFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
-
- if (this.items.isEmpty())
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
return true;
+ }
- if(this.all) {
- return this.items.stream().allMatch(item -> {
- double minZ = item.getZ() + Item.getCurrentHeight(item);
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
+ boolean allFurni = this.getWiredSettings().getIntegerParams().get(PARAM_ALL_FURNI) == 1;
+
+ if(allFurni) {
+ return this.getWiredSettings().getItems(room).stream().allMatch(item -> {
+ double minZ = item.getCurrentZ() + Item.getCurrentHeight(item);
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> {
+ if (matchedItem == item) return false;
+ return matchedItem.getCurrentZ() >= minZ;
+ }));
});
}
else {
- return this.items.stream().anyMatch(item -> {
- double minZ = item.getZ() + Item.getCurrentHeight(item);
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return occupiedTiles.stream().noneMatch(tile -> room.getItemsAt(tile).stream().anyMatch(matchedItem -> matchedItem != item && matchedItem.getZ() >= minZ));
+ return this.getWiredSettings().getItems(room).stream().anyMatch(item -> {
+ double minZ = item.getCurrentZ() + Item.getCurrentHeight(item);
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return occupiedTiles.stream().noneMatch(tile -> room.getRoomItemManager().getItemsAt(tile).stream().anyMatch(matchedItem -> {
+ if (matchedItem == item) return false;
+ return matchedItem.getCurrentZ() >= minZ;
+ }));
});
}
}
@Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.all,
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.all = data.all;
-
- for (int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = wiredData.split(":");
-
- if (data.length >= 1) {
- this.all = (data[0].equals("1"));
-
- if (data.length == 2) {
- String[] items = data[1].split(";");
-
- for (String s : items) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
- @Override
- public void onPickUp() {
- this.all = false;
- this.items.clear();
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.all ? 1 : 0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.all = settings.getIntParams()[0] == 1;
-
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
-
- if (item != null)
- this.items.add(item);
- }
-
- return true;
- }
- return false;
- }
-
- private void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (room.getHabboItem(item.getId()) == null)
- items.add(item);
- }
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
+ return WiredConditionType.NOT_FURNI_HAVE_FURNI;
}
@Override
@@ -185,14 +72,4 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
//return this.all ? WiredConditionOperator.AND : WiredConditionOperator.OR;
return WiredConditionOperator.AND;
}
-
- static class JsonData {
- boolean all;
- List itemIds;
-
- public JsonData(boolean all, List itemIds) {
- this.all = all;
- this.itemIds = itemIds;
- }
- }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java
deleted file mode 100644
index 4410a39c..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveHabbo.java
+++ /dev/null
@@ -1,178 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.pets.Pet;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
-
- protected THashSet items;
-
- public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- this.items = new THashSet<>();
- }
-
- public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new THashSet<>();
- }
-
- @Override
- public void onPickUp() {
- this.items.clear();
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
-
- if (this.items.isEmpty())
- return true;
-
- Collection habbos = room.getHabbos();
- Collection bots = room.getCurrentBots().valueCollection();
- Collection pets = room.getCurrentPets().valueCollection();
-
- return this.items.stream().noneMatch(item -> {
- THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
- return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
- bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation())) ||
- pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentLocation()));
- });
- }
-
- @Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
-
- for(int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = wiredData.split(":");
-
- if (data.length >= 1) {
- String[] items = data[1].split(";");
-
- for (String s : items) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
-
- if (item != null)
- this.items.add(item);
- }
-
- return true;
- }
-
- return false;
- }
-
- private void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (room.getHabboItem(item.getId()) == null)
- items.add(item);
- }
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- }
-
- static class JsonData {
- List itemIds;
-
- public JsonData(List itemIds) {
- this.itemIds = itemIds;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java
new file mode 100644
index 00000000..bd60b14a
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveRoom.java
@@ -0,0 +1,50 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.bots.Bot;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.pets.Pet;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+import gnu.trove.set.hash.THashSet;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+
+public class WiredConditionNotFurniHaveRoom extends InteractionWiredCondition {
+ public WiredConditionNotFurniHaveRoom(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionNotFurniHaveRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return true;
+ }
+
+ Collection habbos = room.getRoomUnitManager().getCurrentHabbos().values();
+ Collection bots = room.getRoomUnitManager().getCurrentBots().values();
+ Collection pets = room.getRoomUnitManager().getCurrentPets().values();
+
+ return this.getWiredSettings().getItems(room).stream().noneMatch(item -> {
+ THashSet occupiedTiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+ return habbos.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) ||
+ bots.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition())) ||
+ pets.stream().anyMatch(character -> occupiedTiles.contains(character.getRoomUnit().getCurrentPosition()));
+ });
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.NOT_FURNI_HAVE_HABBO;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
index 36966574..932842aa 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
@@ -1,161 +1,48 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.List;
-import java.util.stream.Collectors;
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
-
- private final THashSet items = new THashSet<>();
+ private final THashSet items = new THashSet<>();
public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionNotFurniTypeMatch(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionNotFurniTypeMatch(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- this.refresh();
-
- if(items.isEmpty())
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
return true;
-
- if (stuff != null) {
- if (stuff.length >= 1) {
- if (stuff[0] instanceof HabboItem triggeringItem) {
- return this.items.stream().noneMatch(item -> item == triggeringItem);
- }
- }
}
- return true;
- }
-
- @Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- WiredConditionFurniTypeMatch.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniTypeMatch.JsonData.class);
-
- for(int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = set.getString("wired_data").split(";");
-
- for (String s : data) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null) {
- this.items.add(item);
- }
- }
+ if(stuff.length == 0) {
+ return true;
}
- }
- @Override
- public void onPickUp() {
- this.items.clear();
+ if (stuff[0] instanceof RoomItem triggeringItem) {
+ return this.getWiredSettings().getItems(room).stream().noneMatch(item -> item == triggeringItem);
+ }
+
+ return false;
}
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
- }
- }
-
- return true;
- }
-
- private void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (room.getHabboItem(item.getId()) == null)
- items.add(item);
- }
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
- }
-
- static class JsonData {
- List itemIds;
-
- public JsonData(List itemIds) {
- this.itemIds = itemIds;
- }
+ return WiredConditionType.NOT_STUFF_IS;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java
deleted file mode 100644
index d9fe194c..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboCount.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboCount extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_USER_COUNT;
-
- private int lowerLimit = 10;
- private int upperLimit = 20;
-
- public WiredConditionNotHabboCount(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboCount(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- int count = room.getUserCount();
-
- return count < this.lowerLimit || count > this.upperLimit;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.lowerLimit,
- this.upperLimit
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- WiredConditionHabboCount.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionHabboCount.JsonData.class);
- this.lowerLimit = data.lowerLimit;
- this.upperLimit = data.upperLimit;
- } else {
- String[] data = wiredData.split(":");
- this.lowerLimit = Integer.parseInt(data[0]);
- this.upperLimit = Integer.parseInt(data[1]);
- }
- }
-
- @Override
- public void onPickUp() {
- this.upperLimit = 0;
- this.lowerLimit = 20;
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(2);
- message.appendInt(this.lowerLimit);
- message.appendInt(this.upperLimit);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 2) return false;
- this.lowerLimit = settings.getIntParams()[0];
- this.upperLimit = settings.getIntParams()[1];
-
- return true;
- }
-
- static class JsonData {
- int lowerLimit;
- int upperLimit;
-
- public JsonData(int lowerLimit, int upperLimit) {
- this.lowerLimit = lowerLimit;
- this.upperLimit = upperLimit;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java
deleted file mode 100644
index 749245f8..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboHasEffect.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
- private static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_EFFECT;
-
- protected int effectId;
-
- public WiredConditionNotHabboHasEffect(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboHasEffect(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (roomUnit == null) return false;
- return roomUnit.getEffectId() != this.effectId;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.effectId
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.effectId = data.effectId;
- } else {
- this.effectId = Integer.parseInt(wiredData);
- }
- }
-
- @Override
- public void onPickUp() {
- this.effectId = 0;
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.effectId + "");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.effectId = settings.getIntParams()[0];
-
- return true;
- }
-
- static class JsonData {
- int effectId;
-
- public JsonData(int effectId) {
- this.effectId = effectId;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java
deleted file mode 100644
index 96d293ce..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotHabboWearsBadge.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboBadge;
-import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_BADGE;
-
- protected String badge = "";
-
- public WiredConditionNotHabboWearsBadge(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredConditionNotHabboWearsBadge(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) {
- for (HabboBadge b : habbo.getInventory().getBadgesComponent().getWearingBadges()) {
- if (b.getCode().equalsIgnoreCase(this.badge))
- return false;
- }
- }
- return true;
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.badge
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.badge = data.badge;
- } else {
- this.badge = wiredData;
- }
- }
-
- @Override
- public void onPickUp() {
- this.badge = "";
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.badge);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- this.badge = settings.getStringParam();
-
- return true;
- }
-
- static class JsonData {
- String badge;
-
- public JsonData(String badge) {
- this.badge = badge;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java
index 2a6a0458..1b4450a1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInGroup.java
@@ -2,74 +2,36 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionNotInGroup extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_GROUP;
-
public WiredConditionNotInGroup(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionNotInGroup(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionNotInGroup(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (room.getGuildId() == 0)
+ if (room.getRoomInfo().getGuild().getId() == 0)
return false;
- Habbo habbo = room.getHabbo(roomUnit);
-
- return habbo == null || !habbo.getHabboStats().hasGuild(room.getGuildId());
- }
-
- @Override
- public String getWiredData() {
- return "";
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) {
-
- }
-
- @Override
- public void onPickUp() {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
+ return habbo == null || !habbo.getHabboStats().hasGuild(room.getRoomInfo().getGuild().getId());
}
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- return true;
+ return WiredConditionType.NOT_ACTOR_IN_GROUP;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
index fdd025cf..e8ada995 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotInTeam.java
@@ -3,104 +3,57 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionNotInTeam extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_IN_TEAM;
-
- private GameTeamColors teamColor = GameTeamColors.RED;
+ public final int PARAM_TEAM = 0;
+ private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED;
public WiredConditionNotInTeam(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionNotInTeam(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionNotInTeam(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
+ int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM);
+
+ if(teamValue < 1 || teamValue > 4) {
+ return false;
+ }
+
+ GameTeamColors teamColor = GameTeamColors.values()[teamValue];
+
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
- return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor); // user is not part of any team
+ return habbo.getHabboInfo().getGamePlayer() == null || !habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor);
}
return true;
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.teamColor
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) {
- try {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.teamColor = data.teamColor;
- } else {
- if (!wiredData.equals(""))
- this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
- }
- } catch (Exception e) {
- this.teamColor = GameTeamColors.RED;
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(1);
+ this.getWiredSettings().getIntegerParams().add(1);
+ this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type);
}
}
- @Override
- public void onPickUp() {
- this.teamColor = GameTeamColors.RED;
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.teamColor.type);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]];
-
- return true;
- }
-
- static class JsonData {
- GameTeamColors teamColor;
-
- public JsonData(GameTeamColors teamColor) {
- this.teamColor = teamColor;
- }
+ return WiredConditionType.NOT_ACTOR_IN_TEAM;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
index d6b11988..b708916e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotMatchStatePosition.java
@@ -2,21 +2,20 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStatePosition {
- public static final WiredConditionType type = WiredConditionType.NOT_MATCH_SSHOT;
-
public WiredConditionNotMatchStatePosition(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionNotMatchStatePosition(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionNotMatchStatePosition(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
@@ -26,6 +25,6 @@ public class WiredConditionNotMatchStatePosition extends WiredConditionMatchStat
@Override
public WiredConditionType getType() {
- return type;
+ return WiredConditionType.NOT_MATCH_SSHOT;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java
new file mode 100644
index 00000000..6c9260c4
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomCount.java
@@ -0,0 +1,30 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionNotRoomCount extends WiredConditionRoomCount {
+ public WiredConditionNotRoomCount(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionNotRoomCount(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ return !super.execute(roomUnit, room, stuff);
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.NOT_USER_COUNT;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java
new file mode 100644
index 00000000..185eff52
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomHasEffect.java
@@ -0,0 +1,30 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionNotRoomHasEffect extends WiredConditionRoomHasEffect {
+ public WiredConditionNotRoomHasEffect(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionNotRoomHasEffect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ return !super.execute(roomUnit, room, stuff);
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.NOT_ACTOR_WEARS_EFFECT;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java
new file mode 100644
index 00000000..c58c97c2
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotRoomWearsBadge.java
@@ -0,0 +1,34 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionNotRoomWearsBadge extends WiredConditionRoomWearsBadge {
+ public static final WiredConditionType type = WiredConditionType.NOT_ACTOR_WEARS_BADGE;
+
+ protected String badge = "";
+
+ public WiredConditionNotRoomWearsBadge(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionNotRoomWearsBadge(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ return !super.execute(roomUnit, room, stuff);
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.NOT_ACTOR_WEARS_BADGE;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
index 21ea027e..322a82d9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotTriggerOnFurni.java
@@ -2,7 +2,8 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import java.sql.ResultSet;
@@ -15,21 +16,13 @@ public class WiredConditionNotTriggerOnFurni extends WiredConditionTriggerOnFurn
super(set, baseItem);
}
- public WiredConditionNotTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionNotTriggerOnFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (roomUnit == null)
- return false;
-
- this.refresh();
-
- if (this.items.isEmpty())
- return true;
-
- return !triggerOnFurni(roomUnit, room);
+ return !super.execute(roomUnit, room, stuff);
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java
new file mode 100644
index 00000000..bd80c4a8
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomCount.java
@@ -0,0 +1,46 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionRoomCount extends InteractionWiredCondition {
+ public final int PARAM_LOWER_LIMIT = 0;
+ public final int PARAM_UPPER_LIMIT = 1;
+
+ public WiredConditionRoomCount(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionRoomCount(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ int lowerLimit = this.getWiredSettings().getIntegerParams().get(PARAM_LOWER_LIMIT);
+ int upperLimit = this.getWiredSettings().getIntegerParams().get(PARAM_UPPER_LIMIT);
+ int userCount = room.getRoomUnitManager().getRoomHabbosCount();
+
+ return userCount >= lowerLimit && userCount <= upperLimit;
+ }
+
+ @Override
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ this.getWiredSettings().getIntegerParams().add(0);
+ }
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.USER_COUNT;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java
new file mode 100644
index 00000000..63d97b87
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasEffect.java
@@ -0,0 +1,47 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionRoomHasEffect extends InteractionWiredCondition {
+ public final int PARAM_EFFECT_ID = 0;
+
+ public WiredConditionRoomHasEffect(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionRoomHasEffect(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if (roomUnit == null || !(roomUnit instanceof RoomAvatar roomAvatar)) {
+ return false;
+ }
+
+ int effectId = this.getWiredSettings().getIntegerParams().get(PARAM_EFFECT_ID);
+
+ return roomAvatar.getEffectId() == effectId;
+ }
+
+ @Override
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ }
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.ACTOR_WEARS_EFFECT;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java
new file mode 100644
index 00000000..7cbcd262
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomHasHandItem.java
@@ -0,0 +1,49 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+import lombok.extern.slf4j.Slf4j;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@Slf4j
+public class WiredConditionRoomHasHandItem extends InteractionWiredCondition {
+ public final int PARAM_HAND_ITEM_ID = 0;
+
+ public WiredConditionRoomHasHandItem(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionRoomHasHandItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if (!(roomUnit instanceof RoomAvatar roomAvatar)) {
+ return false;
+ }
+
+ int handItemId = this.getWiredSettings().getIntegerParams().get(PARAM_HAND_ITEM_ID);
+
+ return roomAvatar.getHandItem() == handItemId;
+ }
+
+ @Override
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ }
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.ACTOR_HAS_HANDITEM;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java
new file mode 100644
index 00000000..415a4c3e
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionRoomWearsBadge.java
@@ -0,0 +1,52 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
+
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboBadge;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredConditionType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class WiredConditionRoomWearsBadge extends InteractionWiredCondition {
+ public WiredConditionRoomWearsBadge(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredConditionRoomWearsBadge(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if(this.getWiredSettings().getStringParam().isEmpty()) {
+ return true;
+ }
+
+ String badgeCode = this.getWiredSettings().getStringParam();
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
+
+ if(habbo == null) {
+ return false;
+ }
+
+ synchronized (habbo.getInventory().getBadgesComponent().getWearingBadges()) {
+ for (HabboBadge badge : habbo.getInventory().getBadgesComponent().getWearingBadges()) {
+ if (badge.getCode().equalsIgnoreCase(badgeCode)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.ACTOR_WEARS_BADGE;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java
index d78a616b..fe4763a2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTeamMember.java
@@ -3,37 +3,42 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredConditionTeamMember extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.ACTOR_IN_TEAM;
-
- private GameTeamColors teamColor = GameTeamColors.RED;
+ public final int PARAM_TEAM = 0;
+ private final GameTeamColors DEFAULT_TEAM = GameTeamColors.RED;
public WiredConditionTeamMember(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionTeamMember(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionTeamMember(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
+ int teamValue = this.getWiredSettings().getIntegerParams().get(PARAM_TEAM);
+
+ if(teamValue < 1 || teamValue > 4) {
+ return false;
+ }
+
+ GameTeamColors teamColor = GameTeamColors.values()[teamValue];
+
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getGamePlayer() != null) {
- return habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(this.teamColor);
+ return habbo.getHabboInfo().getGamePlayer().getTeamColor().equals(teamColor);
}
}
@@ -41,68 +46,16 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.teamColor
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) {
- try {
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.teamColor = data.teamColor;
- } else {
- if (!wiredData.equals(""))
- this.teamColor = GameTeamColors.values()[Integer.parseInt(wiredData)];
- }
- } catch (Exception e) {
- this.teamColor = GameTeamColors.RED;
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(1);
+ this.getWiredSettings().getIntegerParams().add(1);
+ this.getWiredSettings().getIntegerParams().add(DEFAULT_TEAM.type);
}
}
- @Override
- public void onPickUp() {
- this.teamColor = GameTeamColors.RED;
- }
-
@Override
public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(1);
- message.appendInt(this.teamColor.type);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- if(settings.getIntParams().length < 1) return false;
- this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]];
-
- return true;
- }
-
- static class JsonData {
- GameTeamColors teamColor;
-
- public JsonData(GameTeamColors teamColor) {
- this.teamColor = teamColor;
- }
+ return WiredConditionType.ACTOR_IN_TEAM;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
index a8d9aae7..92a564a3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionTriggerOnFurni.java
@@ -1,157 +1,39 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
-import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.List;
-import java.util.stream.Collectors;
public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
- public static final WiredConditionType type = WiredConditionType.TRIGGER_ON_FURNI;
-
- protected THashSet items = new THashSet<>();
-
public WiredConditionTriggerOnFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredConditionTriggerOnFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredConditionTriggerOnFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (roomUnit == null)
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return true;
+ }
+
+ if(roomUnit == null) {
return false;
-
- this.refresh();
-
- if (this.items.isEmpty())
- return false;
-
- return triggerOnFurni(roomUnit, room);
- }
-
- protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) {
- THashSet itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
- return this.items.stream().anyMatch(itemsAtUser::contains);
- }
-
- @Override
- public String getWiredData() {
- this.refresh();
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
- this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
- ));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items.clear();
- String wiredData = set.getString("wired_data");
-
- if (wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
-
- for(int id : data.itemIds) {
- HabboItem item = room.getHabboItem(id);
-
- if (item != null) {
- this.items.add(item);
- }
- }
- } else {
- String[] data = wiredData.split(";");
-
- for (String s : data) {
- HabboItem item = room.getHabboItem(Integer.parseInt(s));
-
- if (item != null) {
- this.items.add(item);
- }
- }
- }
- }
-
- @Override
- public void onPickUp() {
- this.items.clear();
- }
-
- @Override
- public WiredConditionType getType() {
- return type;
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- this.refresh();
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
-
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString("");
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(0);
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings) {
- int count = settings.getFurniIds().length;
- if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
-
- this.items.clear();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- for (int i = 0; i < count; i++) {
- HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
-
- if (item != null) {
- this.items.add(item);
- }
- }
}
- return true;
- }
-
- protected void refresh() {
- THashSet items = new THashSet<>();
-
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
- if (room == null) {
- items.addAll(this.items);
- } else {
- for (HabboItem item : this.items) {
- if (item.getRoomId() != room.getId())
- items.add(item);
- }
- }
-
- this.items.removeAll(items);
+ THashSet itemsAtUser = room.getRoomItemManager().getItemsAt(roomUnit.getCurrentPosition());
+ return this.getWiredSettings().getItems(room).stream().anyMatch(itemsAtUser::contains);
}
@Override
@@ -159,11 +41,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
return WiredConditionOperator.AND;
}
- static class JsonData {
- List itemIds;
-
- public JsonData(List itemIds) {
- this.itemIds = itemIds;
- }
+ @Override
+ public WiredConditionType getType() {
+ return WiredConditionType.TRIGGER_ON_FURNI;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java
index 14e83480..7455518f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectAlert.java
@@ -3,8 +3,9 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
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.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -14,16 +15,16 @@ public class WiredEffectAlert extends WiredEffectWhisper {
super(set, baseItem);
}
- public WiredEffectAlert(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredEffectAlert(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
- habbo.alert(this.message
+ habbo.alert(this.getWiredSettings().getStringParam()
.replace("%online%", Emulator.getGameEnvironment().getHabboManager().getOnlineCount() + "")
.replace("%username%", habbo.getHabboInfo().getUsername())
.replace("%roomsloaded%", Emulator.getGameEnvironment().getRoomManager().loadedRoomsCount() + ""));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
index b0e1ff48..cef31e8d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotClothes.java
@@ -2,152 +2,47 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-import java.util.regex.Pattern;
public class WiredEffectBotClothes extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_CLOTHES;
-
- private String botName = "";
- private String botLook = "";
-
public WiredEffectBotClothes(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredEffectBotClothes(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredEffectBotClothes(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName + ((char) 9) + "" + this.botLook);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
- message.appendInt(0);
- }
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ String[] stringParams = this.getWiredSettings().getStringParam().split("\t");
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- String dataString = settings.getStringParam();
- int delay = settings.getDelay();
+ String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
+ String botLook = stringParams[1];
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
+ List bots = room.getRoomUnitManager().getBotsByName(botName);
- String splitBy = "\t";
- if(!dataString.contains(splitBy))
- throw new WiredSaveException("Malformed data string");
+ if(bots.size() == 0) {
+ return false;
+ }
- String[] data = dataString.split(Pattern.quote(splitBy));
-
- if (data.length != 2)
- throw new WiredSaveException("Malformed data string. Invalid data length");
-
- this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.botLook = data[1];
- this.setDelay(delay);
+ Bot bot = bots.get(0);
+ bot.setFigure(botLook);
return true;
}
@Override
public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- List bots = room.getBots(this.botName);
-
- if (bots.size() == 1) {
- Bot bot = bots.get(0);
- bot.setFigure(this.botLook);
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.botLook, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.botName = data.bot_name;
- this.botLook = data.look;
- }
- else {
- String[] data = wiredData.split(((char) 9) + "");
-
- if (data.length >= 3) {
- this.setDelay(Integer.parseInt(data[0]));
- this.botName = data[1];
- this.botLook = data[2];
- }
-
- this.needsUpdate(true);
- }
- }
-
- @Override
- public void onPickUp() {
- this.botLook = "";
- this.botName = "";
- this.setDelay(0);
- }
-
- public String getBotName() {
- return this.botName;
- }
-
- public void setBotName(String botName) {
- this.botName = botName;
- }
-
- public String getBotLook() {
- return this.botLook;
- }
-
- public void setBotLook(String botLook) {
- this.botLook = botLook;
- }
-
- static class JsonData {
- String bot_name;
- String look;
- int delay;
-
- public JsonData(String bot_name, String look, int delay) {
- this.bot_name = bot_name;
- this.look = look;
- this.delay = delay;
- }
+ return WiredEffectType.BOT_CLOTHES;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java
deleted file mode 100644
index 5d8d17c9..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowHabbo.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_FOLLOW_AVATAR;
-
- private String botName = "";
- private int mode = 0;
-
- public WiredEffectBotFollowHabbo(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectBotFollowHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName);
- message.appendInt(1);
- message.appendInt(this.mode);
- message.appendInt(1);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid");
-
- int mode = settings.getIntParams()[0];
-
- if(mode != 0 && mode != 1)
- throw new WiredSaveException("Mode is invalid");
-
- String botName = settings.getStringParam().replace("\t", "");
- botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.botName = botName;
- this.mode = mode;
- this.setDelay(delay);
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- List bots = room.getBots(this.botName);
-
- if (habbo != null && bots.size() == 1) {
- Bot bot = bots.get(0);
-
- if (this.mode == 1) {
- bot.startFollowingHabbo(habbo);
- } else {
- bot.stopFollowingHabbo();
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.mode = data.mode;
- this.botName = data.bot_name;
- }
- else {
- String[] data = wiredData.split(((char) 9) + "");
-
- if (data.length == 3) {
- this.setDelay(Integer.parseInt(data[0]));
- this.mode = (data[1].equalsIgnoreCase("1") ? 1 : 0);
- this.botName = data[2];
- }
-
- this.needsUpdate(true);
- }
- }
-
- @Override
- public void onPickUp() {
- this.botName = "";
- this.mode = 0;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-
- static class JsonData {
- String bot_name;
- int mode;
- int delay;
-
- public JsonData(String bot_name, int mode, int delay) {
- this.bot_name = bot_name;
- this.mode = mode;
- this.delay = delay;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java
new file mode 100644
index 00000000..f7f29026
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotFollowRoom.java
@@ -0,0 +1,61 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.effects;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.bots.Bot;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
+import com.eu.habbo.threading.runnables.BotFollowHabbo;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+public class WiredEffectBotFollowRoom extends InteractionWiredEffect {
+ public final int PARAM_MODE = 0;
+
+ public WiredEffectBotFollowRoom(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredEffectBotFollowRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
+ List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam());
+
+ if (habbo != null && bots.size() == 1) {
+ Bot bot = bots.get(0);
+
+ if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) {
+ bot.setFollowingHabboId(habbo.getHabboInfo().getId());
+ Emulator.getThreading().run(new BotFollowHabbo(bot, habbo, habbo.getRoomUnit().getRoom()));
+ } else {
+ bot.setFollowingHabboId(0);
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ }
+ }
+
+ @Override
+ public WiredEffectType getType() {
+ return WiredEffectType.BOT_FOLLOW_AVATAR;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
index c82b0eda..9fd302a5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotGiveHandItem.java
@@ -2,19 +2,17 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
@@ -24,102 +22,46 @@ import java.util.ArrayList;
import java.util.List;
public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_GIVE_HANDITEM;
-
- private String botName = "";
- private int itemId;
-
+ public final int PARAM_ITEM_ID = 0;
public WiredEffectBotGiveHandItem(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredEffectBotGiveHandItem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName);
- message.appendInt(1);
- message.appendInt(this.itemId);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing item id");
-
- int itemId = settings.getIntParams()[0];
-
- if(itemId < 0)
- itemId = 0;
-
- String botName = settings.getStringParam();
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.itemId = itemId;
- this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.setDelay(delay);
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
+ public WiredEffectBotGiveHandItem(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
- List bots = room.getBots(this.botName);
+ if(!(roomUnit instanceof RoomAvatar roomAvatar)) {
+ return false;
+ }
+
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomAvatar);
+ List bots = room.getRoomUnitManager().getBotsByName(this.getWiredSettings().getStringParam());
+ int itemId = this.getWiredSettings().getIntegerParams().get(PARAM_ITEM_ID);
if (habbo != null && bots.size() == 1) {
Bot bot = bots.get(0);
List tasks = new ArrayList<>();
- tasks.add(new RoomUnitGiveHanditem(roomUnit, room, this.itemId));
+ tasks.add(new RoomUnitGiveHanditem(roomAvatar, room, itemId));
tasks.add(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, 0));
tasks.add(() -> {
- if(roomUnit.getRoom() != null && roomUnit.getRoom().getId() == room.getId() && roomUnit.getCurrentLocation().distance(bot.getRoomUnit().getCurrentLocation()) < 2) {
- WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
+ if(roomAvatar.getRoom() != null) {
+ if (roomAvatar.getRoom().getRoomInfo().getId() == room.getRoomInfo().getId() && roomAvatar.getCurrentPosition().distance(bot.getRoomUnit().getCurrentPosition()) < 2) {
+ WiredHandler.handle(WiredTriggerType.BOT_REACHED_AVTR, bot.getRoomUnit(), room, new Object[]{});
+ }
}
});
- RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomUnit.getX(), roomUnit.getY(), true);
+ RoomTile tile = bot.getRoomUnit().getClosestAdjacentTile(roomAvatar.getCurrentPosition().getX(), roomAvatar.getCurrentPosition().getY(), true);
if(tile != null) {
- bot.getRoomUnit().setGoalLocation(tile);
+ bot.getRoomUnit().walkTo(tile);
}
- Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, this.itemId));
+ Emulator.getThreading().run(new RoomUnitGiveHanditem(bot.getRoomUnit(), room, itemId));
Emulator.getThreading().run(new RoomUnitWalkToLocation(bot.getRoomUnit(), tile, room, tasks, tasks));
return true;
@@ -129,54 +71,14 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.itemId, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.itemId = data.item_id;
- this.botName = data.bot_name;
- }
- else {
- String[] data = wiredData.split(((char) 9) + "");
-
- if (data.length == 3) {
- this.setDelay(Integer.parseInt(data[0]));
- this.itemId = Integer.parseInt(data[1]);
- this.botName = data[2];
- }
-
- this.needsUpdate(true);
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().isEmpty()) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
@Override
- public void onPickUp() {
- this.botName = "";
- this.itemId = 0;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-
- static class JsonData {
- String bot_name;
- int item_id;
- int delay;
-
- public JsonData(String bot_name, int item_id, int delay) {
- this.bot_name = bot_name;
- this.item_id = item_id;
- this.delay = delay;
- }
+ public WiredEffectType getType() {
+ return WiredEffectType.BOT_GIVE_HANDITEM;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
index 11681d45..8377b39c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalk.java
@@ -2,117 +2,59 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-import java.util.regex.Pattern;
public class WiredEffectBotTalk extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_TALK;
-
- private int mode;
- private String botName = "";
- private String message = "";
+ public final int PARAM_MODE = 0;
public WiredEffectBotTalk(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
- public WiredEffectBotTalk(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName + "" + ((char) 9) + "" + this.message);
- message.appendInt(1);
- message.appendInt(this.mode);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid");
- int mode = settings.getIntParams()[0];
-
- if(mode != 0 && mode != 1)
- throw new WiredSaveException("Mode is invalid");
-
- String dataString = settings.getStringParam();
-
- String splitBy = "\t";
- if(!dataString.contains(splitBy))
- throw new WiredSaveException("Malformed data string");
-
- String[] data = dataString.split(Pattern.quote(splitBy));
-
- if (data.length != 2)
- throw new WiredSaveException("Malformed data string. Invalid data length");
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.setDelay(delay);
- this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.mode = mode;
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
+ public WiredEffectBotTalk(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- String message = this.message;
+ String[] stringParams = this.getWiredSettings().getStringParam().split("\t");
- Habbo habbo = room.getHabbo(roomUnit);
+ String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
+ String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
+
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
if (habbo != null) {
message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
.replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "")
.replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
.replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
- .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName())
- .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
- .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName)
- .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName())
- .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + "");
+ .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername())
+ .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "")
+ .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName)
+ .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName())
+ .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
}
- List bots = room.getBots(this.botName);
+ List bots = room.getRoomUnitManager().getBotsByName(botName);
if (bots.size() == 1) {
Bot bot = bots.get(0);
if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) {
- if (this.mode == 1) {
+ if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) {
bot.shout(message);
} else {
bot.talk(message);
@@ -124,83 +66,19 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
}
@Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.mode = data.mode;
- this.botName = data.bot_name;
- this.message = data.message;
- }
- else {
- String[] data = wiredData.split(((char) 9) + "");
-
- if (data.length == 4) {
- this.setDelay(Integer.parseInt(data[0]));
- this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0;
- this.botName = data[2];
- this.message = data[3];
- }
-
- this.needsUpdate(true);
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().size() == 0) {
+ this.getWiredSettings().getIntegerParams().add(0);
}
}
@Override
- public void onPickUp() {
- this.mode = 0;
- this.botName = "";
- this.message = "";
- this.setDelay(0);
- }
-
- public int getMode() {
- return this.mode;
- }
-
- public void setMode(int mode) {
- this.mode = mode;
- }
-
- public String getBotName() {
- return this.botName;
- }
-
- public void setBotName(String botName) {
- this.botName = botName;
- }
-
- public String getMessage() {
- return this.message;
- }
-
- public void setMessage(String message) {
- this.message = message;
+ public WiredEffectType getType() {
+ return WiredEffectType.BOT_TALK;
}
@Override
protected long requiredCooldown() {
return 500;
}
-
- static class JsonData {
- String bot_name;
- int mode;
- String message;
- int delay;
-
- public JsonData(String bot_name, int mode, String message, int delay) {
- this.bot_name = bot_name;
- this.mode = mode;
- this.message = message;
- this.delay = delay;
- }
- }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java
deleted file mode 100644
index 2c3b0698..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToHabbo.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package com.eu.habbo.habbohotel.items.interactions.wired.effects;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_TALK_TO_AVATAR;
-
- private int mode;
- private String botName = "";
- private String message = "";
-
- public WiredEffectBotTalkToHabbo(ResultSet set, Item baseItem) throws SQLException {
- super(set, baseItem);
- }
-
- public WiredEffectBotTalkToHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- message.appendBoolean(false);
- message.appendInt(5);
- message.appendInt(0);
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName + "" + ((char) 9) + "" + this.message);
- message.appendInt(1);
- message.appendInt(this.mode);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
-
- if (this.requiresTriggeringUser()) {
- List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
- });
- message.appendInt(invalidTriggers.size());
- for (Integer i : invalidTriggers) {
- message.appendInt(i);
- }
- } else {
- message.appendInt(0);
- }
- }
-
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing mode");
- int mode = settings.getIntParams()[0];
-
- if(mode != 0 && mode != 1)
- throw new WiredSaveException("Mode is invalid");
-
- String dataString = settings.getStringParam();
- String splitBy = "\t";
- if(!dataString.contains(splitBy))
- throw new WiredSaveException("Malformed data string");
-
- String[] data = dataString.split(Pattern.quote(splitBy));
-
- if (data.length != 2)
- throw new WiredSaveException("Malformed data string. Invalid data length");
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.botName = data[0].substring(0, Math.min(data[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.message = data[1].substring(0, Math.min(data[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.mode = mode;
- this.setDelay(delay);
-
- return true;
- }
-
- @Override
- public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- String m = this.message;
- m = m.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
- .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "")
- .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
- .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
- .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getOwnerName())
- .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.itemCount() + "")
- .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), this.botName)
- .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getName())
- .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getUserCount() + "");
-
- List bots = room.getBots(this.botName);
-
- if (bots.size() != 1) {
- return false;
- }
-
- Bot bot = bots.get(0);
-
- if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ m })) {
- if (this.mode == 1) {
- bot.whisper(m, habbo);
- } else {
- bot.talk(habbo.getHabboInfo().getUsername() + ": " + m);
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public String getWiredData() {
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, this.mode, this.message, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.mode = data.mode;
- this.botName = data.bot_name;
- this.message = data.message;
- }
- else {
- String[] data = wiredData.split(((char) 9) + "");
-
- if (data.length == 4) {
- this.setDelay(Integer.parseInt(data[0]));
- this.mode = data[1].equalsIgnoreCase("1") ? 1 : 0;
- this.botName = data[2];
- this.message = data[3];
- }
-
- this.needsUpdate(true);
- }
- }
-
- @Override
- public void onPickUp() {
- this.botName = "";
- this.message = "";
- this.mode = 0;
- this.setDelay(0);
- }
-
- @Override
- public boolean requiresTriggeringUser() {
- return true;
- }
-
- static class JsonData {
- String bot_name;
- int mode;
- String message;
- int delay;
-
- public JsonData(String bot_name, int mode, String message, int delay) {
- this.bot_name = bot_name;
- this.mode = mode;
- this.message = message;
- this.delay = delay;
- }
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java
new file mode 100644
index 00000000..a74dd952
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTalkToRoom.java
@@ -0,0 +1,83 @@
+package com.eu.habbo.habbohotel.items.interactions.wired.effects;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.bots.Bot;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
+import com.eu.habbo.habbohotel.wired.WiredHandler;
+import com.eu.habbo.habbohotel.wired.WiredTriggerType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+public class WiredEffectBotTalkToRoom extends InteractionWiredEffect {
+ public final int PARAM_MODE = 0;
+
+ public WiredEffectBotTalkToRoom(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public WiredEffectBotTalkToRoom(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ String[] stringParams = this.getWiredSettings().getStringParam().split("\t");
+
+ String botName = stringParams[0].substring(0, Math.min(stringParams[0].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
+ String message = stringParams[1].substring(0, Math.min(stringParams[1].length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
+
+ Habbo habbo = room.getRoomUnitManager().getHabboByRoomUnit(roomUnit);
+
+ if (habbo != null) {
+ message = message.replace(Emulator.getTexts().getValue("wired.variable.username", "%username%"), habbo.getHabboInfo().getUsername())
+ .replace(Emulator.getTexts().getValue("wired.variable.credits", "%credits%"), habbo.getHabboInfo().getCredits() + "")
+ .replace(Emulator.getTexts().getValue("wired.variable.pixels", "%pixels%"), habbo.getHabboInfo().getPixels() + "")
+ .replace(Emulator.getTexts().getValue("wired.variable.points", "%points%"), habbo.getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.primary.type")) + "")
+ .replace(Emulator.getTexts().getValue("wired.variable.owner", "%owner%"), room.getRoomInfo().getOwnerInfo().getUsername())
+ .replace(Emulator.getTexts().getValue("wired.variable.item_count", "%item_count%"), room.getRoomItemManager().getCurrentItems().size() + "")
+ .replace(Emulator.getTexts().getValue("wired.variable.name", "%name%"), botName)
+ .replace(Emulator.getTexts().getValue("wired.variable.roomname", "%roomname%"), room.getRoomInfo().getName())
+ .replace(Emulator.getTexts().getValue("wired.variable.user_count", "%user_count%"), room.getRoomUnitManager().getRoomHabbosCount() + "");
+
+ List bots = room.getRoomUnitManager().getBotsByName(botName);
+
+ if (bots.size() != 1) {
+ return false;
+ }
+
+ Bot bot = bots.get(0);
+
+ if(!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, bot.getRoomUnit(), room, new Object[]{ message })) {
+ if (this.getWiredSettings().getIntegerParams().get(PARAM_MODE) == 1) {
+ bot.whisper(message, habbo);
+ } else {
+ bot.talk(habbo.getHabboInfo().getUsername() + ": " + message);
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void loadDefaultIntegerParams() {
+ if(this.getWiredSettings().getIntegerParams().size() == 0) {
+ this.getWiredSettings().getIntegerParams().add(0);
+ }
+ }
+
+ @Override
+ public WiredEffectType getType() {
+ return WiredEffectType.BOT_TALK_TO_AVATAR;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
index 69be9e5e..7c2d7607 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
@@ -2,63 +2,84 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer;
import com.eu.habbo.threading.runnables.RoomUnitTeleport;
import com.eu.habbo.threading.runnables.SendRoomUnitEffectComposer;
-import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class WiredEffectBotTeleport extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_TELEPORT;
-
- private THashSet items;
- private String botName = "";
-
public WiredEffectBotTeleport(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.items = new THashSet<>();
}
- public WiredEffectBotTeleport(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new THashSet<>();
+ public WiredEffectBotTeleport(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ }
+
+ @Override
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return false;
+ }
+
+ String botName = this.getWiredSettings().getStringParam();
+ List bots = room.getRoomUnitManager().getBotsByName(botName);
+
+ if (bots.size() == 0) {
+ return false;
+ }
+
+ Bot bot = bots.get(0);
+
+ int i = Emulator.getRandom().nextInt(this.getWiredSettings().getItemIds().size()) + 1;
+ int j = 1;
+
+ for (RoomItem item : this.getWiredSettings().getItems(room)) {
+ if (item.getRoomId() != 0) {
+ Room room1 = bot.getRoomUnit().getRoom();
+ if (item.getRoomId() == room1.getRoomInfo().getId()) {
+ if (i == j) {
+ teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
+ return true;
+ } else {
+ j++;
+ }
+ }
+ }
+ }
+
+ return true;
}
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
- if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting())
+ if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting() || !(roomUnit instanceof RoomBot roomBot))
return;
- Room room = roomUnit.getRoom();
+ Room room = roomBot.getRoom();
if (room == null) {
return;
}
- // makes a temporary effect
+ room.sendComposer(new AvatarEffectMessageComposer(roomBot, 4).compose());
+ Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomBot), (long) WiredHandler.TELEPORT_DELAY + 1000);
- roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
- room.sendComposer(new AvatarEffectMessageComposer(roomUnit, 4).compose());
- Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), (long) WiredHandler.TELEPORT_DELAY + 1000);
-
- if (tile == roomUnit.getCurrentLocation()) {
+ if (tile == roomBot.getCurrentPosition()) {
return;
}
@@ -79,180 +100,12 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
}
}
- Emulator.getThreading().run(() -> roomUnit.setWiredTeleporting(true), Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
- Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
- }
-
- @Override
- public void serializeWiredData(ServerMessage message, Room room) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
- }
-
- for (HabboItem item : items) {
- this.items.remove(item);
- }
-
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
-
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
- message.appendInt(0);
- }
-
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- String botName = settings.getStringParam();
- int itemsCount = settings.getFurniIds().length;
-
- if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
- throw new WiredSaveException("Too many furni selected");
- }
-
- List newItems = new ArrayList<>();
-
- for (int i = 0; i < itemsCount; i++) {
- int itemId = settings.getFurniIds()[i];
- HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
-
- if(it == null)
- throw new WiredSaveException(String.format("Item %s not found", itemId));
-
- newItems.add(it);
- }
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.items.clear();
- this.items.addAll(newItems);
- this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.setDelay(delay);
-
- return true;
+ Emulator.getThreading().run(() -> roomBot.setWiredTeleporting(true), Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
+ Emulator.getThreading().run(new RoomUnitTeleport(roomBot, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomBot.getEffectId()), WiredHandler.TELEPORT_DELAY);
}
@Override
public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- if (this.items.isEmpty())
- return false;
-
- List bots = room.getBots(this.botName);
-
- if (bots.size() != 1) {
- return false;
- }
-
- Bot bot = bots.get(0);
-
- int i = Emulator.getRandom().nextInt(this.items.size()) + 1;
- int j = 1;
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
- if (i == j) {
- teleportUnitToTile(bot.getRoomUnit(), room.getLayout().getTile(item.getX(), item.getY()));
- return true;
- } else {
- j++;
- }
- }
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- ArrayList itemIds = new ArrayList<>();
-
- if (this.items != null) {
- for (HabboItem item : this.items) {
- if (item.getRoomId() != 0) {
- itemIds.add(item.getId());
- }
- }
- }
-
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items = new THashSet<>();
-
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.botName = data.bot_name;
-
- for(int itemId : data.items) {
- HabboItem item = room.getHabboItem(itemId);
-
- if (item != null)
- this.items.add(item);
- }
- }
- else {
- String[] wiredDataSplit = set.getString("wired_data").split("\t");
-
- if (wiredDataSplit.length >= 2) {
- this.setDelay(Integer.parseInt(wiredDataSplit[0]));
- String[] data = wiredDataSplit[1].split(";");
-
- if (data.length > 1) {
- this.botName = data[0];
-
- for (int i = 1; i < data.length; i++) {
- HabboItem item = room.getHabboItem(Integer.parseInt(data[i]));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
-
- this.needsUpdate(true);
- }
- }
-
- @Override
- public void onPickUp() {
- this.botName = "";
- this.items.clear();
- this.setDelay(0);
- }
-
- static class JsonData {
- String bot_name;
- List items;
- int delay;
-
- public JsonData(String bot_name, List items, int delay) {
- this.bot_name = bot_name;
- this.items = items;
- this.delay = delay;
- }
+ return WiredEffectType.BOT_TELEPORT;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
index c1b4da34..07f50e2c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotWalkToFurni.java
@@ -2,209 +2,70 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
-import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
-import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
- public static final WiredEffectType type = WiredEffectType.BOT_MOVE;
-
- private List items;
- private String botName = "";
-
public WiredEffectBotWalkToFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.items = new ArrayList<>();
}
- public WiredEffectBotWalkToFurni(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
- this.items = new ArrayList<>();
+ public WiredEffectBotWalkToFurni(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
}
@Override
- public void serializeWiredData(ServerMessage message, Room room) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items) {
- if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
+ public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return false;
}
- for (HabboItem item : items) {
- this.items.remove(item);
+ String botName = this.getWiredSettings().getStringParam();
+ List bots = room.getRoomUnitManager().getBotsByName(botName);
+
+ if (bots.size() == 0) {
+ return false;
}
- message.appendBoolean(false);
- message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
- message.appendInt(this.items.size());
- for (HabboItem item : this.items)
- message.appendInt(item.getId());
+ Bot bot = bots.get(0);
+ this.getWiredSettings().getItems(room).removeIf(item -> {
+ if (item == null || item.getRoomId() != this.getRoomId()) return true;
+ Room room1 = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
+ return room1.getRoomItemManager().getRoomItemById(item.getId()) == null;
+ });
- message.appendInt(this.getBaseItem().getSpriteId());
- message.appendInt(this.getId());
- message.appendString(this.botName);
- message.appendInt(0);
- message.appendInt(0);
- message.appendInt(this.getType().getCode());
- message.appendInt(this.getDelay());
- message.appendInt(0);
- }
+ // Bots shouldn't walk to the tile they are already standing on
+ List possibleItems = this.getWiredSettings().getItems(room).stream()
+ .filter(item -> !room.getBotsOnItem(item).contains(bot))
+ .collect(Collectors.toList());
- @Override
- public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
- String botName = settings.getStringParam();
- int itemsCount = settings.getFurniIds().length;
+ // Get a random tile of possible tiles to walk to
+ if (possibleItems.size() > 0) {
+ RoomItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size()));
- if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
- throw new WiredSaveException("Too many furni selected");
+ if (item.getRoomId() != 0) {
+ Room room1 = bot.getRoomUnit().getRoom();
+ if (item.getRoomId() == room1.getRoomInfo().getId()) {
+ bot.getRoomUnit().walkTo(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
+ }
+ }
}
- List newItems = new ArrayList<>();
-
- for (int i = 0; i < itemsCount; i++) {
- int itemId = settings.getFurniIds()[i];
- HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
-
- if(it == null)
- throw new WiredSaveException(String.format("Item %s not found", itemId));
-
- newItems.add(it);
- }
-
- int delay = settings.getDelay();
-
- if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
- throw new WiredSaveException("Delay too long");
-
- this.items.clear();
- this.items.addAll(newItems);
- this.botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
- this.setDelay(delay);
-
return true;
}
@Override
public WiredEffectType getType() {
- return type;
- }
-
- @Override
- public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- List bots = room.getBots(this.botName);
-
- if (this.items.isEmpty() || bots.size() != 1) {
- return true;
- }
-
- Bot bot = bots.get(0);
- this.items.removeIf(item -> item == null || item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null);
-
- // Bots shouldn't walk to the tile they are already standing on
- List possibleItems = this.items.stream()
- .filter(item -> !room.getBotsOnItem(item).contains(bot))
- .collect(Collectors.toList());
-
- // Get a random tile of possible tiles to walk to
- if (possibleItems.size() > 0) {
- HabboItem item = possibleItems.get(Emulator.getRandom().nextInt(possibleItems.size()));
-
- if (item.getRoomId() != 0 && item.getRoomId() == bot.getRoom().getId()) {
- bot.getRoomUnit().setGoalLocation(room.getLayout().getTile(item.getX(), item.getY()));
- }
- }
-
- return true;
- }
-
- @Override
- public String getWiredData() {
- ArrayList itemIds = new ArrayList<>();
-
- if (this.items != null) {
- for (HabboItem item : this.items) {
- if (item.getRoomId() != 0) {
- itemIds.add(item.getId());
- }
- }
- }
-
- return WiredHandler.getGsonBuilder().create().toJson(new JsonData(this.botName, itemIds, this.getDelay()));
- }
-
- @Override
- public void loadWiredData(ResultSet set, Room room) throws SQLException {
- this.items = new ArrayList<>();
-
- String wiredData = set.getString("wired_data");
-
- if(wiredData.startsWith("{")) {
- JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
- this.setDelay(data.delay);
- this.botName = data.bot_name;
-
- for(int itemId : data.items) {
- HabboItem item = room.getHabboItem(itemId);
-
- if (item != null)
- this.items.add(item);
- }
- }
- else {
- String[] wiredDataSplit = set.getString("wired_data").split("\t");
-
- if (wiredDataSplit.length >= 2) {
- this.setDelay(Integer.parseInt(wiredDataSplit[0]));
- String[] data = wiredDataSplit[1].split(";");
-
- if (data.length > 1) {
- this.botName = data[0];
-
- for (int i = 1; i < data.length; i++) {
- HabboItem item = room.getHabboItem(Integer.parseInt(data[i]));
-
- if (item != null)
- this.items.add(item);
- }
- }
- }
-
- this.needsUpdate(true);
- }
- }
-
- @Override
- public void onPickUp() {
- this.items.clear();
- this.botName = "";
- this.setDelay(0);
- }
-
- static class JsonData {
- String bot_name;
- List items;
- int delay;
-
- public JsonData(String bot_name, List items, int delay) {
- this.bot_name = bot_name;
- this.items = items;
- this.delay = delay;
- }
+ return WiredEffectType.BOT_MOVE;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
index c0383efb..91e4b76a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
@@ -1,29 +1,30 @@
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
-import com.eu.habbo.habbohotel.rooms.*;
-import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.rooms.FurnitureMovementError;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.rooms.RoomTileState;
+import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
+import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
+import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
-import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.HashMap;
public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
+ public final int PARAM_START_DIRECTION = 0;
+ public final int PARAM_BLOCKED_ACTION = 1;
public static final int ACTION_WAIT = 0;
public static final int ACTION_TURN_RIGHT_45 = 1;
public static final int ACTION_TURN_RIGHT_90 = 2;
@@ -32,83 +33,102 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
public static final int ACTION_TURN_BACK = 5;
public static final int ACTION_TURN_RANDOM = 6;
- public static final WiredEffectType type = WiredEffectType.MOVE_DIRECTION;
+ private int defaultDirectionValue;
- private final THashMap items = new THashMap<>(0);
- private RoomUserRotation startRotation = RoomUserRotation.NORTH;
- private int blockedAction = 0;
+ private int defaultBlockActionValue;
+
+ private boolean requiresUpdate = false;
+ private final HashMap itemsSettings;
public WiredEffectChangeFurniDirection(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
+ this.itemsSettings = new HashMap<>();
}
- public WiredEffectChangeFurniDirection(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
- super(id, userId, item, extradata, limitedStack, limitedSells);
+ public WiredEffectChangeFurniDirection(int id, HabboInfo ownerInfo, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, ownerInfo, item, extradata, limitedStack, limitedSells);
+ this.itemsSettings = new HashMap<>();
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) {
- THashSet items = new THashSet<>();
-
- for (HabboItem item : this.items.keySet()) {
- if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
- items.add(item);
+ if(this.getWiredSettings().getItemIds().isEmpty()) {
+ return false;
}
- for (HabboItem item : items) {
- this.items.remove(item);
+ int startDirectionValue = this.getWiredSettings().getIntegerParams().get(PARAM_START_DIRECTION);
+ int blockActionValue = this.getWiredSettings().getIntegerParams().get(PARAM_BLOCKED_ACTION);
+
+ if(startDirectionValue < 0 || startDirectionValue > 7 || (startDirectionValue % 2) != 0) {
+ return false;
}
- if (this.items.isEmpty()) return false;
+ if(blockActionValue < 0 || blockActionValue > 6) {
+ return false;
+ }
- for (Map.Entry entry : this.items.entrySet()) {
- HabboItem item = entry.getKey();
- RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue());
+ if(this.defaultDirectionValue != startDirectionValue) {
+ this.defaultDirectionValue = startDirectionValue;
+ this.requiresUpdate = true;
+ }
+ RoomRotation startDirection = RoomRotation.fromValue(startDirectionValue);
+
+ if(this.requiresUpdate) {
+ for (WiredChangeDirectionSetting setting : this.itemsSettings.values()) {
+ setting.setDirection(startDirection);
+ }
+ this.requiresUpdate = false;
+ }
+
+ for(RoomItem item : this.getWiredSettings().getItems(room)) {
+ WiredChangeDirectionSetting setting = this.itemsSettings.computeIfAbsent(item, k ->
+ new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection)
+ );
+
+ RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), setting.getDirection().getValue());
int count = 1;
- while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || room.furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) {
- entry.getValue().setDirection(this.nextRotation(entry.getValue().getDirection()));
+ while ((targetTile == null || targetTile.getState() == RoomTileState.INVALID || !room.getLayout().tileWalkable(targetTile) || room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) != FurnitureMovementError.NONE) && count < 8) {
+ setting.setDirection(this.nextDirection(setting.getDirection()));
- RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), entry.getValue().getDirection().getValue());
+ RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), setting.getDirection().getValue());
if (tile != null && tile.getState() != RoomTileState.INVALID) {
targetTile = tile;
}
count++;
}
- }
- for (Map.Entry entry : this.items.entrySet()) {
- HabboItem item = entry.getKey();
- int newDirection = entry.getValue().getDirection().getValue();
+ int newDirectionValue = setting.getDirection().getValue();
- RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), newDirection);
+ RoomTile newTargetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), newDirectionValue);
- if(item.getRotation() != entry.getValue().getRotation()) {
- if(room.furnitureFitsAt(targetTile, item, entry.getValue().getRotation(), false) != FurnitureMovementError.NONE)
+ if(item.getRotation() != setting.getRotation()) {
+ if(room.getRoomItemManager().furnitureFitsAt(newTargetTile, item, setting.getRotation(), false) != FurnitureMovementError.NONE)
continue;
- room.moveFurniTo(entry.getKey(), targetTile, entry.getValue().getRotation(), null, true);
+ room.getRoomItemManager().moveItemTo(item, newTargetTile, setting.getRotation(), null, true, true);
}
boolean hasRoomUnits = false;
- THashSet newOccupiedTiles = room.getLayout().getTilesAt(targetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
+
+ THashSet newOccupiedTiles = room.getLayout().getTilesAt(newTargetTile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for(RoomTile tile : newOccupiedTiles) {
- for (RoomUnit _roomUnit : room.getRoomUnits(tile)) {
+ for (RoomUnit _roomUnit : room.getRoomUnitManager().getRoomUnitsAt(tile)) {
hasRoomUnits = true;
- if(_roomUnit.getCurrentLocation() == targetTile) {
- Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{entry.getKey()}));
+ if(_roomUnit.getCurrentPosition() == newTargetTile) {
+ Emulator.getThreading().run(() -> WiredHandler.handle(WiredTriggerType.COLLISION, _roomUnit, room, new Object[]{item}));
break;
}
}
}
- if (targetTile != null && targetTile.getState() != RoomTileState.INVALID && room.furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
+ if (newTargetTile != null && newTargetTile.getState() != RoomTileState.INVALID && room.getRoomItemManager().furnitureFitsAt(targetTile, item, item.getRotation(), false) == FurnitureMovementError.NONE) {
if (!hasRoomUnits) {
- RoomTile oldLocation = room.getLayout().getTile(entry.getKey().getX(), entry.getKey().getY());
- double oldZ = entry.getKey().getZ();
- if(room.moveFurniTo(entry.getKey(), targetTile, item.getRotation(), null, false) == FurnitureMovementError.NONE) {
- room.sendComposer(new FloorItemOnRollerComposer(entry.getKey(), null, oldLocation, oldZ, targetTile, entry.getKey().getZ(), 0, room).compose());
+ RoomTile oldLocation = room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY());
+ double oldZ = item.getCurrentZ();
+ if (room.getRoomItemManager().moveItemTo(item, newTargetTile, item.getRotation(), null, false, true) == FurnitureMovementError.NONE) {
+ room.sendComposer(new FloorItemOnRollerComposer(item, null, oldLocation, oldZ, targetTile, item.getCurrentZ(), 0, room).compose());
}
}
}
@@ -118,161 +138,23 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
}
@Override
- public String getWiredData() {
- ArrayList