Merge branch 'supernova' into 'ms4/supernova'

Supernova

See merge request morningstar/Arcturus-Community!78
This commit is contained in:
John 2023-12-08 13:17:58 +00:00
commit 02cfeeac38
840 changed files with 12577 additions and 18693 deletions

View File

@ -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)

19
pom.xml
View File

@ -104,6 +104,25 @@
<version>2.8.9</version>
</dependency>
<!-- JACKSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.15.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<!-- MySQL Connector -->
<dependency>
<groupId>mysql</groupId>

View File

@ -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)

View File

@ -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());

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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";
}
}

View File

@ -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());

View File

@ -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<String> 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<String> 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<String> 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<String> 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);
}
}
}

View File

@ -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<String, String> 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));

View File

@ -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<Runnable> 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);
}
}

View File

@ -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"));

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -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());

View File

@ -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<HabboItem> itemsList = new THashSet<>();
HashSet<RoomItem> 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<String> itemIds = new THashSet<>();
for (HabboItem ix : purchasedEvent.itemsList) {
for (RoomItem ix : purchasedEvent.itemsList) {
itemIds.add(ix.getId() + "");
}

View File

@ -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<Item, Integer> 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<String, String> 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) {

View File

@ -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;

View File

@ -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();

View File

@ -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;
}

View File

@ -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" +

View File

@ -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);

View File

@ -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("<b>");
data.append(Emulator.getTexts().getValue("generic.bot.name"));

View File

@ -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];
}

View File

@ -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);

View File

@ -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<PermissionCommand> commands = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getCommands();
List<String> 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");
}

View File

@ -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]);

View File

@ -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" +

View File

@ -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);

View File

@ -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;

View File

@ -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<Bot> bots = new TIntObjectHashMap<>();

View File

@ -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<HabboItem> items = new TIntObjectHashMap<>();
TIntObjectMap<RoomItem> items = new TIntObjectHashMap<>();
items.putAll(habbo.getInventory().getItemsComponent().getItems());
habbo.getInventory().getItemsComponent().getItems().clear();
Emulator.getThreading().run(new QueryDeleteHabboItems(items));

View File

@ -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<Pet> pets = new TIntObjectHashMap<>(habbo.getInventory().getPetsComponent().getPets());

View File

@ -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);

View File

@ -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<String, String> 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());

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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

View File

@ -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"));
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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());
}

View File

@ -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])

View File

@ -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<HabboItem> items = new ArrayList<>();
ArrayList<RoomItem> 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<HabboItem> deleted = new TIntObjectHashMap<>();
TIntObjectHashMap<RoomItem> deleted = new TIntObjectHashMap<>();
items.forEach(item -> {
gameClient.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
deleted.put(item.getId(), item);

View File

@ -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<Habbo> 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<Habbo> 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);

View File

@ -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<PermissionRight> rights = gameClient.getHabbo().getHabboInfo().getPermissionGroup().getRights();
Set<String> 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");
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -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());

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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()));
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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<Map.Entry<RoomUnitStatus, String>> 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<RoomUnitStatus, String> status : statuses) {
message.append(status.getKey().toString()).append("\r");
}
gameClient.sendResponse(message);
gameClient.getHabbo().alert(new String[]{message.toString()});
return true;
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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()));
}

View File

@ -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 ? "<b>" + getTextsValue("command.cmd_userinfo.current_activity") + "</b>\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 ? "<b>" + getTextsValue("command.cmd_userinfo.current_activity") + "</b>\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<Map.Entry<Integer, String>> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3);

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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();
}

View File

@ -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) {

View File

@ -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;

View File

@ -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]));

View File

@ -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);
}
}

View File

@ -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);
});

View File

@ -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())]);

View File

@ -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";

View File

@ -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));
}

View File

@ -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);
}
}

Some files were not shown because too many files have changed in this diff Show More