mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Code optimisations and readability
This commit is contained in:
parent
f973f7885d
commit
ab5bd82ed3
@ -45,6 +45,8 @@ import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
public class CatalogManager {
|
||||
|
||||
@ -256,7 +258,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, LinkedList<Integer>> set : limiteds.entrySet()) {
|
||||
@ -289,7 +291,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
pages.forEachValue((object) -> {
|
||||
@ -330,7 +332,7 @@ public class CatalogManager {
|
||||
));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,10 +343,7 @@ public class CatalogManager {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM catalog_items")) {
|
||||
CatalogItem item;
|
||||
while (set.next()) {
|
||||
if (set.getString("item_ids").equals("0"))
|
||||
continue;
|
||||
|
||||
if (set.getInt("amount") < 1)
|
||||
if (set.getString("item_ids").equals("0") || set.getInt("amount") < 1)
|
||||
continue;
|
||||
|
||||
if (set.getString("catalog_name").contains("HABBO_CLUB_")) {
|
||||
@ -377,7 +376,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
for (CatalogPage page : this.catalogPages.valueCollection()) {
|
||||
@ -402,7 +401,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +417,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -433,7 +432,7 @@ public class CatalogManager {
|
||||
this.vouchers.add(new Voucher(set));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -457,7 +456,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -477,7 +476,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -492,7 +491,7 @@ public class CatalogManager {
|
||||
this.clothing.put(set.getInt("id"), new ClothItem(set));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -571,7 +570,7 @@ public class CatalogManager {
|
||||
|
||||
return statement.executeUpdate() >= 1;
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -728,7 +727,7 @@ public class CatalogManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
if (catalogPage != null) {
|
||||
@ -792,8 +791,6 @@ public class CatalogManager {
|
||||
|
||||
|
||||
public void purchaseItem(CatalogPage page, CatalogItem item, Habbo habbo, int amount, String extradata, boolean free) {
|
||||
Item cBaseItem = null;
|
||||
|
||||
if (item == null || habbo.getHabboStats().isPurchasingFurniture()) {
|
||||
habbo.getClient().sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose());
|
||||
return;
|
||||
@ -1054,23 +1051,19 @@ public class CatalogManager {
|
||||
UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges);
|
||||
Emulator.getPluginManager().fireEvent(purchasedEvent);
|
||||
|
||||
if (!free && !habbo.getClient().getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS)) {
|
||||
if (purchasedEvent.getTotalCredits() > 0) {
|
||||
habbo.getClient().getHabbo().getHabboInfo().addCredits(-purchasedEvent.getTotalCredits());
|
||||
habbo.getClient().sendResponse(new CreditBalanceComposer(habbo.getClient().getHabbo()));
|
||||
}
|
||||
if (!free && !habbo.getClient().getHabbo().hasPermission(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().hasPermission(Permission.ACC_INFINITE_POINTS)) {
|
||||
if (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 (!free && !habbo.getClient().getHabbo().hasPermission(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).collect(Collectors.toList()));
|
||||
unseenItems.put(UnseenItemsComposer.AddHabboItemCategory.OWNED_FURNI, purchasedEvent.itemsList.stream().map(HabboItem::getId).toList());
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new UserCatalogFurnitureBoughtEvent(habbo, item, purchasedEvent.itemsList));
|
||||
|
||||
|
@ -26,8 +26,11 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
|
||||
@Slf4j
|
||||
|
||||
public class MarketPlace {
|
||||
|
||||
//Configuration. Loaded from database & updated accordingly.
|
||||
@ -36,6 +39,9 @@ public class MarketPlace {
|
||||
//Currency to use.
|
||||
public static int MARKETPLACE_CURRENCY = 0;
|
||||
|
||||
private MarketPlace() {
|
||||
}
|
||||
|
||||
|
||||
public static THashSet<MarketPlaceOffer> getOwnOffers(Habbo habbo) {
|
||||
THashSet<MarketPlaceOffer> offers = new THashSet<>();
|
||||
@ -47,7 +53,7 @@ public class MarketPlace {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return offers;
|
||||
@ -105,7 +111,7 @@ public class MarketPlace {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
habbo.getClient().sendResponse(new MarketplaceCancelOfferResultComposer(offer, false));
|
||||
}
|
||||
}
|
||||
@ -169,7 +175,7 @@ public class MarketPlace {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return offers;
|
||||
@ -199,7 +205,7 @@ public class MarketPlace {
|
||||
message.appendInt(1);
|
||||
message.appendInt(itemId);
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +220,7 @@ public class MarketPlace {
|
||||
number = set.getInt("number");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return number;
|
||||
@ -232,7 +238,7 @@ public class MarketPlace {
|
||||
avg = set.getInt("avg");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return calculateCommision(avg);
|
||||
@ -241,58 +247,59 @@ public class MarketPlace {
|
||||
|
||||
public static void buyItem(int offerId, GameClient client) {
|
||||
GetMarketplaceOffersEvent.cachedResults.clear();
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM marketplace_items WHERE id = ? LIMIT 1")) {
|
||||
statement.setInt(1, offerId);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
|
||||
itemStatement.setInt(1, set.getInt("item_id"));
|
||||
try (ResultSet itemSet = itemStatement.executeQuery()) {
|
||||
itemSet.first();
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT * FROM marketplace_items WHERE id = ? LIMIT 1")) {
|
||||
statement.setInt(1, offerId);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
|
||||
itemStatement.setInt(1, set.getInt("item_id"));
|
||||
try (ResultSet itemSet = itemStatement.executeQuery()) {
|
||||
itemSet.first();
|
||||
|
||||
if (itemSet.getRow() > 0) {
|
||||
int price = MarketPlace.calculateCommision(set.getInt("price"));
|
||||
if (set.getInt("state") != 1) {
|
||||
sendErrorMessage(client, set.getInt("item_id"), offerId);
|
||||
} else if ((MARKETPLACE_CURRENCY == 0 && price > client.getHabbo().getHabboInfo().getCredits()) || (MARKETPLACE_CURRENCY > 0 && price > client.getHabbo().getHabboInfo().getCurrencyAmount(MARKETPLACE_CURRENCY))) {
|
||||
client.sendResponse(new MarketplaceBuyOfferResultComposer(MarketplaceBuyOfferResultComposer.NOT_ENOUGH_CREDITS, 0, offerId, price));
|
||||
} else {
|
||||
try (PreparedStatement updateOffer = connection.prepareStatement("UPDATE marketplace_items SET state = 2, sold_timestamp = ? WHERE id = ?")) {
|
||||
updateOffer.setInt(1, Emulator.getIntUnixTimestamp());
|
||||
updateOffer.setInt(2, offerId);
|
||||
updateOffer.execute();
|
||||
}
|
||||
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(set.getInt(DatabaseConstants.USER_ID));
|
||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet);
|
||||
if (itemSet.getRow() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
MarketPlaceItemSoldEvent event = new MarketPlaceItemSoldEvent(habbo, client.getHabbo(), item, set.getInt("price"));
|
||||
if (Emulator.getPluginManager().fireEvent(event).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
event.price = calculateCommision(event.price);
|
||||
int price = MarketPlace.calculateCommision(set.getInt("price"));
|
||||
if (set.getInt("state") != 1) {
|
||||
sendErrorMessage(client, set.getInt("item_id"), offerId);
|
||||
} else if ((MARKETPLACE_CURRENCY == 0 && price > client.getHabbo().getHabboInfo().getCredits()) || (MARKETPLACE_CURRENCY > 0 && price > client.getHabbo().getHabboInfo().getCurrencyAmount(MARKETPLACE_CURRENCY))) {
|
||||
client.sendResponse(new MarketplaceBuyOfferResultComposer(MarketplaceBuyOfferResultComposer.NOT_ENOUGH_CREDITS, 0, offerId, price));
|
||||
} else {
|
||||
try (PreparedStatement updateOffer = connection.prepareStatement("UPDATE marketplace_items SET state = 2, sold_timestamp = ? WHERE id = ?")) {
|
||||
updateOffer.setInt(1, Emulator.getIntUnixTimestamp());
|
||||
updateOffer.setInt(2, offerId);
|
||||
updateOffer.execute();
|
||||
}
|
||||
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(set.getInt(DatabaseConstants.USER_ID));
|
||||
HabboItem item = Emulator.getGameEnvironment().getItemManager().loadHabboItem(itemSet);
|
||||
|
||||
item.setUserId(client.getHabbo().getHabboInfo().getId());
|
||||
item.needsUpdate(true);
|
||||
Emulator.getThreading().run(item);
|
||||
MarketPlaceItemSoldEvent event = new MarketPlaceItemSoldEvent(habbo, client.getHabbo(), item, set.getInt("price"));
|
||||
if (Emulator.getPluginManager().fireEvent(event).isCancelled()) {
|
||||
return;
|
||||
}
|
||||
event.price = calculateCommision(event.price);
|
||||
|
||||
client.getHabbo().getInventory().getItemsComponent().addItem(item);
|
||||
item.setUserId(client.getHabbo().getHabboInfo().getId());
|
||||
item.needsUpdate(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
if (MARKETPLACE_CURRENCY == 0) {
|
||||
client.getHabbo().giveCredits(-event.price);
|
||||
} else {
|
||||
client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price);
|
||||
}
|
||||
client.getHabbo().getInventory().getItemsComponent().addItem(item);
|
||||
|
||||
client.sendResponse(new CreditBalanceComposer(client.getHabbo()));
|
||||
client.sendResponse(new UnseenItemsComposer(item));
|
||||
client.sendResponse(new FurniListInvalidateComposer());
|
||||
client.sendResponse(new MarketplaceBuyOfferResultComposer(MarketplaceBuyOfferResultComposer.REFRESH, 0, offerId, price));
|
||||
if (MARKETPLACE_CURRENCY == 0) {
|
||||
client.getHabbo().giveCredits(-event.price);
|
||||
} else {
|
||||
client.getHabbo().givePoints(MARKETPLACE_CURRENCY, -event.price);
|
||||
}
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getInventory().getOffer(offerId).setState(MarketPlaceState.SOLD);
|
||||
}
|
||||
}
|
||||
client.sendResponse(new CreditBalanceComposer(client.getHabbo()));
|
||||
client.sendResponse(new UnseenItemsComposer(item));
|
||||
client.sendResponse(new FurniListInvalidateComposer());
|
||||
client.sendResponse(new MarketplaceBuyOfferResultComposer(MarketplaceBuyOfferResultComposer.REFRESH, 0, offerId, price));
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getInventory().getOffer(offerId).setState(MarketPlaceState.SOLD);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,7 +307,7 @@ public class MarketPlace {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,15 +315,15 @@ public class MarketPlace {
|
||||
public static void sendErrorMessage(GameClient client, int baseItemId, int offerId) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT marketplace_items.*, COUNT( * ) AS count\n" +
|
||||
"""
|
||||
FROM marketplace_items
|
||||
INNER JOIN items ON marketplace_items.item_id = items.id
|
||||
INNER JOIN items_base ON items.item_id = items_base.id
|
||||
WHERE items_base.sprite_id = (
|
||||
SELECT items_base.sprite_id
|
||||
FROM items_base
|
||||
WHERE items_base.id = ? LIMIT 1)
|
||||
ORDER BY price ASC
|
||||
LIMIT 1""", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
|
||||
FROM marketplace_items
|
||||
INNER JOIN items ON marketplace_items.item_id = items.id
|
||||
INNER JOIN items_base ON items.item_id = items_base.id
|
||||
WHERE items_base.sprite_id = (
|
||||
SELECT items_base.sprite_id
|
||||
FROM items_base
|
||||
WHERE items_base.id = ? LIMIT 1)
|
||||
ORDER BY price
|
||||
LIMIT 1""", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
|
||||
statement.setInt(1, baseItemId);
|
||||
try (ResultSet countSet = statement.executeQuery()) {
|
||||
countSet.last();
|
||||
@ -328,7 +335,7 @@ public class MarketPlace {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +402,7 @@ public class MarketPlace {
|
||||
statement.setInt(2, offer.getOfferId());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ public class LayCommand extends Command {
|
||||
if (gameClient.getHabbo().getRoomUnit() == null || !gameClient.getHabbo().getRoomUnit().canForcePosture())
|
||||
return true;
|
||||
|
||||
gameClient.getHabbo().getRoomUnit().cmdLay = true;
|
||||
gameClient.getHabbo().getRoomUnit().setCmdLay(true);
|
||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo());
|
||||
gameClient.getHabbo().getRoomUnit().cmdSit = true;
|
||||
gameClient.getHabbo().getRoomUnit().setCmdSit(true);
|
||||
gameClient.getHabbo().getRoomUnit().setBodyRotation(RoomUserRotation.values()[gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() - gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue() % 2]);
|
||||
|
||||
RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation();
|
||||
|
@ -12,12 +12,12 @@ 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().cmdTeleport) {
|
||||
gameClient.getHabbo().getRoomUnit().cmdTeleport = false;
|
||||
if (gameClient.getHabbo().getRoomUnit().isCmdTeleport()) {
|
||||
gameClient.getHabbo().getRoomUnit().setCmdTeleport(false);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.disabled"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
} else {
|
||||
gameClient.getHabbo().getRoomUnit().cmdTeleport = true;
|
||||
gameClient.getHabbo().getRoomUnit().setCmdTeleport(true);
|
||||
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_teleport.enabled"), RoomChatMessageBubbles.ALERT);
|
||||
return true;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
public class ForumThreadComment implements Runnable, ISerialize {
|
||||
|
||||
@ -76,7 +78,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return foundComment;
|
||||
@ -115,7 +117,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
|
||||
Emulator.getPluginManager().fireEvent(new GuildForumThreadCommentCreated(createdComment));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return createdComment;
|
||||
@ -172,7 +174,7 @@ public class ForumThreadComment implements Runnable, ISerialize {
|
||||
|
||||
this.needsUpdate = false;
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class InteractionBackgroundToner extends HabboItem {
|
||||
return;
|
||||
}
|
||||
|
||||
if (client.getHabbo().getRoomUnit().cmdSit && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
|
||||
if (client.getHabbo().getRoomUnit().isCmdSit() && client.getHabbo().getRoomUnit().getEffectId() == 1337) {
|
||||
new BackgroundAnimation(this, room).run();
|
||||
return;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
|
||||
|
||||
if (this.forceRotation()) {
|
||||
roomUnit.setRotation(RoomUserRotation.fromValue(this.getRotation()));
|
||||
roomUnit.canRotate = false;
|
||||
roomUnit.setCanRotate(false);
|
||||
}
|
||||
this.roomUnitId = roomUnit.getId();
|
||||
|
||||
@ -79,7 +79,7 @@ public class InteractionGymEquipment extends InteractionEffectTile implements IC
|
||||
}
|
||||
|
||||
if (this.forceRotation()) {
|
||||
roomUnit.canRotate = true;
|
||||
roomUnit.setCanRotate(true);
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M)) {
|
||||
|
@ -55,7 +55,7 @@ public class InteractionHopper extends HabboItem {
|
||||
RoomTile loc = HabboItem.getSquareInFront(room.getLayout(), this);
|
||||
if (loc != null) {
|
||||
if (this.canUseTeleport(client, loc, room)) {
|
||||
client.getHabbo().getRoomUnit().isTeleporting = true;
|
||||
client.getHabbo().getRoomUnit().setTeleporting(true);
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
|
||||
@ -92,7 +92,7 @@ public class InteractionHopper extends HabboItem {
|
||||
if (client.getHabbo().getRoomUnit().getY() != front.getY())
|
||||
return false;
|
||||
|
||||
if (client.getHabbo().getRoomUnit().isTeleporting)
|
||||
if (client.getHabbo().getRoomUnit().isTeleporting())
|
||||
return false;
|
||||
|
||||
if (!room.getHabbosAt(this.getX(), this.getY()).isEmpty())
|
||||
|
@ -45,30 +45,29 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
super.onClick(client, room, objects);
|
||||
|
||||
if (client != null) {
|
||||
if (!room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))
|
||||
return;
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))
|
||||
return;
|
||||
|
||||
if (objects.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (objects.length > 0) {
|
||||
if (objects[0] instanceof Integer && room != null) {
|
||||
HabboItem topItem = room.getTopItemAt(this.getX(), this.getY());
|
||||
if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
|
||||
return;
|
||||
}
|
||||
if (objects[0] instanceof Integer && room != null) {
|
||||
HabboItem topItem = room.getTopItemAt(this.getX(), this.getY());
|
||||
if (topItem != null && !topItem.equals(this)) { // multiheight items cannot change height even if there is a stackable item on top - no items allowed on top
|
||||
return;
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
|
||||
if (this.getExtradata().length() == 0)
|
||||
this.setExtradata("0");
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length > 0) {
|
||||
this.setExtradata("" + (Integer.parseInt(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length));
|
||||
this.needsUpdate(true);
|
||||
|
||||
if (this.getExtradata().length() == 0)
|
||||
this.setExtradata("0");
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length > 0) {
|
||||
this.setExtradata("" + (Integer.parseInt(this.getExtradata()) + 1) % (this.getBaseItem().getMultiHeights().length));
|
||||
this.needsUpdate(true);
|
||||
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
|
||||
room.updateItemState(this);
|
||||
//room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.parseInt(this.getExtradata())] * 256.0D).compose());
|
||||
}
|
||||
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,7 +83,7 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
continue;
|
||||
|
||||
if (this.getBaseItem().allowSit() || unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||
unit.sitUpdate = true;
|
||||
unit.setSitUpdate(true);
|
||||
unit.statusUpdate(true);
|
||||
} else {
|
||||
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
||||
@ -94,7 +93,6 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
}
|
||||
}
|
||||
|
||||
//room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,21 +103,19 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if (roomUnit != null) {
|
||||
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
||||
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
if (roomUnit != null
|
||||
&& (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
|
||||
&& roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,21 +125,19 @@ public class InteractionMultiHeight extends HabboItem {
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
if (roomUnit != null) {
|
||||
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
|
||||
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
if (roomUnit != null
|
||||
&& (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
|
||||
&& roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
|
||||
Habbo habbo = room.getHabbo(roomUnit);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
return;
|
||||
}
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
}
|
||||
}
|
||||
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0) {
|
||||
room.giveEffect(habbo, 0, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,13 +208,13 @@ public class InteractionTeleport extends HabboItem {
|
||||
}
|
||||
|
||||
public void startTeleport(Room room, Habbo habbo, int delay) {
|
||||
if (habbo.getRoomUnit().isTeleporting) {
|
||||
if (habbo.getRoomUnit().isTeleporting()) {
|
||||
walkable = this.getBaseItem().allowWalk();
|
||||
return;
|
||||
}
|
||||
|
||||
this.roomUnitID = -1;
|
||||
habbo.getRoomUnit().isTeleporting = true;
|
||||
habbo.getRoomUnit().setTeleporting(true);
|
||||
Emulator.getThreading().run(new TeleportActionOne(this, room, habbo.getClient()), delay);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class InteractionTeleportTile extends InteractionTeleport {
|
||||
if (!canUseTeleport(habbo.getClient(), room))
|
||||
return;
|
||||
|
||||
if (!habbo.getRoomUnit().isTeleporting) {
|
||||
if (!habbo.getRoomUnit().isTeleporting()) {
|
||||
habbo.getRoomUnit().setGoalLocation(habbo.getRoomUnit().getCurrentLocation());
|
||||
this.startTeleport(room, habbo, 1000);
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class InteractionWater extends InteractionDefault {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
if(roomUnit == null) return;
|
||||
roomUnit.isSwimming = true;
|
||||
roomUnit.setSwimming(true);
|
||||
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
@ -90,7 +90,7 @@ public class InteractionWater extends InteractionDefault {
|
||||
|
||||
@Override
|
||||
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
roomUnit.isSwimming = false;
|
||||
roomUnit.setSwimming(false);
|
||||
|
||||
super.onWalkOff(roomUnit, room, objects);
|
||||
|
||||
|
@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.games.GameTeamColors;
|
||||
import com.eu.habbo.habbohotel.games.football.FootballGame;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionPushable;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTeamItem;
|
||||
import com.eu.habbo.habbohotel.items.interactions.games.football.goals.InteractionFootballGoal;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -33,7 +32,7 @@ public class InteractionFootball extends InteractionPushable {
|
||||
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 2 && this.getExtradata().equals("1"))
|
||||
return 0;
|
||||
|
||||
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 1)
|
||||
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 1)
|
||||
return 6;
|
||||
|
||||
return 1;
|
||||
@ -41,7 +40,7 @@ public class InteractionFootball extends InteractionPushable {
|
||||
|
||||
@Override
|
||||
public int getWalkOffVelocity(RoomUnit roomUnit, Room room) {
|
||||
if (roomUnit.getPath().size() == 0 && roomUnit.tilesWalked() == 0)
|
||||
if (roomUnit.getPath().isEmpty() && roomUnit.tilesWalked() == 0)
|
||||
return 6;
|
||||
|
||||
return 1;
|
||||
@ -85,16 +84,11 @@ public class InteractionFootball extends InteractionPushable {
|
||||
@Override
|
||||
public int getNextRollDelay(int currentStep, int totalSteps) {
|
||||
|
||||
if(totalSteps > 4) {
|
||||
if(currentStep <= 4) {
|
||||
return 125;
|
||||
}
|
||||
if (totalSteps > 4 && currentStep <= 4) {
|
||||
return 125;
|
||||
}
|
||||
|
||||
return 500;
|
||||
|
||||
/*int t = 2500;
|
||||
return (totalSteps == 1) ? 500 : 100 * ((t = t / t - 1) * t * t * t * t + 1) + (currentStep * 100);*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -177,16 +171,13 @@ public class InteractionFootball extends InteractionPushable {
|
||||
int ballDirection = Rotation.Calculate(from.getX(), from.getY(), to.getX(), to.getY());
|
||||
int goalRotation = topItem.getRotation();
|
||||
|
||||
switch (goalRotation) {
|
||||
case 0:
|
||||
return ballDirection > 2 && ballDirection < 6;
|
||||
case 2:
|
||||
return ballDirection > 4;
|
||||
case 4:
|
||||
return ballDirection > 6 || ballDirection < 2;
|
||||
case 6:
|
||||
return ballDirection > 0 && ballDirection < 4;
|
||||
}
|
||||
return switch (goalRotation) {
|
||||
case 0 -> ballDirection > 2 && ballDirection < 6;
|
||||
case 2 -> ballDirection > 4;
|
||||
case 4 -> ballDirection > 6 || ballDirection < 2;
|
||||
case 6 -> ballDirection > 0 && ballDirection < 4;
|
||||
default -> topItem.getBaseItem().allowStack();
|
||||
};
|
||||
}
|
||||
|
||||
return topItem.getBaseItem().allowStack();
|
||||
@ -214,7 +205,7 @@ public class InteractionFootball extends InteractionPushable {
|
||||
FootballGame game = (FootballGame) room.getGame(FootballGame.class);
|
||||
if (game == null) {
|
||||
try {
|
||||
game = FootballGame.class.getDeclaredConstructor(new Class[]{Room.class}).newInstance(room);
|
||||
game = FootballGame.class.getDeclaredConstructor(Room.class).newInstance(room);
|
||||
room.addGame(game);
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
@ -222,16 +213,13 @@ public class InteractionFootball extends InteractionPushable {
|
||||
}
|
||||
HabboItem currentTopItem = room.getTopItemAt(from.getX(), from.getY(), this);
|
||||
HabboItem topItem = room.getTopItemAt(to.getX(), to.getY(), this);
|
||||
if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && ((topItem instanceof InteractionFootballGoal))) {
|
||||
GameTeamColors color = ((InteractionGameTeamItem) topItem).teamColor;
|
||||
if ((topItem != null) && ((currentTopItem == null) || (currentTopItem.getId() != topItem.getId())) && topItem instanceof InteractionFootballGoal interactionFootballGoal) {
|
||||
GameTeamColors color = interactionFootballGoal.teamColor;
|
||||
game.onScore(kicker, color);
|
||||
}
|
||||
|
||||
this.setExtradata(Math.abs(currentStep - (totalSteps + 1)) + "");
|
||||
room.sendComposer(new OneWayDoorStatusMessageComposer(this).compose());
|
||||
|
||||
/*this.setExtradata(nextRoll <= 200 ? "8" : (nextRoll <= 250 ? "7" : (nextRoll <= 300 ? "6" : (nextRoll <= 350 ? "5" : (nextRoll <= 400 ? "4" : (nextRoll <= 450 ? "3" : (nextRoll <= 500 ? "2" : "1")))))));
|
||||
room.sendComposer(new ItemStateComposer(this).compose());*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,8 +20,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionPetBreedingNest extends HabboItem {
|
||||
public Pet petOne = null;
|
||||
public Pet petTwo = null;
|
||||
private Pet petOne = null;
|
||||
private Pet petTwo = null;
|
||||
|
||||
public InteractionPetBreedingNest(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
@ -59,19 +59,17 @@ public class InteractionPetBreedingNest extends HabboItem {
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet != null) {
|
||||
if (!this.boxFull()) {
|
||||
this.addPet(pet);
|
||||
if (pet != null && !this.boxFull()) {
|
||||
this.addPet(pet);
|
||||
|
||||
if (this.boxFull()) {
|
||||
Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId());
|
||||
Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId());
|
||||
if (this.boxFull()) {
|
||||
Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId());
|
||||
Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId());
|
||||
|
||||
if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) {
|
||||
ownerPetTwo.getClient().sendResponse(new ConfirmBreedingRequestComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername()));
|
||||
this.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
}
|
||||
if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1) {
|
||||
ownerPetTwo.getClient().sendResponse(new ConfirmBreedingRequestComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername()));
|
||||
this.setExtradata("1");
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,14 +146,12 @@ public class InteractionPetBreedingNest extends HabboItem {
|
||||
habbo.getHabboInfo().getCurrentRoom().updateItem(this);
|
||||
|
||||
HabboItem box = this;
|
||||
Pet petOne = this.petOne;
|
||||
Pet petTwo = this.petTwo;
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient());
|
||||
|
||||
//habbo.getClient().sendResponse(new PetPackageNameValidationComposer(box.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
|
||||
habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ());
|
||||
offspring.needsUpdate = true;
|
||||
offspring.setNeedsUpdate(true);
|
||||
offspring.run();
|
||||
InteractionPetBreedingNest.this.freePets();
|
||||
habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box);
|
||||
|
@ -74,14 +74,14 @@ public class InteractionPetDrink extends InteractionDefault {
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.EAT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.addThirst(-75);
|
||||
this.change(room, -1);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
new PetClearPosture(pet, RoomUnitStatus.EAT, null, true);
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}, 1000);
|
||||
|
||||
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId()), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetFeeding"), 75);
|
||||
|
@ -33,7 +33,7 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
|
||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@ -42,7 +42,7 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
|
||||
for (Pet pet : room.getPetsOnItem(this)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
HabboItem item = this;
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.addHappiness(25);
|
||||
@ -70,7 +70,7 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
room.updateItem(item);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}, ((long)(Emulator.getRandom().nextInt(20) * 500) + 2500));
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
@ -87,7 +87,7 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
|
||||
|
||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
|
||||
|
||||
for (Pet pet : room.getPetsOnItem(this)) {
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public class InteractionPetTrampoline extends InteractionDefault {
|
||||
this.setExtradata("0");
|
||||
room.updateItem(this);
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.JUMP);
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,14 +23,14 @@ public class InteractionPetTree extends InteractionDefault {
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
for (Pet pet : room.getPetsOnItem(this)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ public class InteractionPetTree extends InteractionDefault {
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().setStatus(task, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
RoomUnitStatus finalTask = task;
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.addHappiness(25);
|
||||
@ -64,13 +64,13 @@ public class InteractionPetTree extends InteractionDefault {
|
||||
pet.clearPosture();
|
||||
}
|
||||
pet.getRoomUnit().setCanWalk(true);
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}, (long) 2500 + (Emulator.getRandom().nextInt(20) * 500));
|
||||
} else {
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.HANG, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class InteractionPetTree extends InteractionDefault {
|
||||
|
||||
if (pet != null) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
|
||||
if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
|
||||
if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting())
|
||||
return;
|
||||
|
||||
Room room = roomUnit.getRoom();
|
||||
@ -79,7 +79,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> roomUnit.isWiredTeleporting = true, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(() -> roomUnit.setWiredTeleporting(true), Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
|
||||
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
|
||||
if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
|
||||
if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting())
|
||||
return;
|
||||
|
||||
Room room = roomUnit.getRoom();
|
||||
@ -78,7 +78,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(() -> { roomUnit.setWiredTeleporting(true); }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
|
||||
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import java.text.SimpleDateFormat;
|
||||
@Getter
|
||||
public class ModToolBan implements Runnable {
|
||||
|
||||
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private final int userId;
|
||||
private final String ip;
|
||||
private final String machineId;
|
||||
|
@ -41,7 +41,7 @@ public class GnomePet extends Pet implements IPetLook {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
if (this.isNeedsUpdate()) {
|
||||
super.run();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET gnome_data = ? WHERE id = ? LIMIT 1")) {
|
||||
|
@ -36,7 +36,7 @@ public class HorsePet extends RideablePet {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
if (this.isNeedsUpdate()) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET hair_style = ?, hair_color = ?, saddle = ?, ride = ?, saddle_item_id = ? WHERE id = ?")) {
|
||||
statement.setInt(1, this.hairStyle);
|
||||
statement.setInt(2, this.hairColor);
|
||||
|
@ -57,10 +57,8 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
this.put(10, new Pair<>("Cinereus", 3));
|
||||
}
|
||||
};
|
||||
public static final ArrayList<Pair<String, Integer>> indexedBody = new ArrayList<>(MonsterplantPet.bodyRarity.values());
|
||||
public static final ArrayList<Pair<String, Integer>> indexedColors = new ArrayList<>(MonsterplantPet.colorRarity.values());
|
||||
public static final int growTime = (30 * 60);
|
||||
public static final int timeToLive = (3 * 24 * 60 * 60); //3 days
|
||||
public static final int GROW_TIME = (30 * 60);
|
||||
public static final int TIME_TO_LIVE = (3 * 24 * 60 * 60); //3 days
|
||||
private final int nose;
|
||||
private final int noseColor;
|
||||
private final int eyes;
|
||||
@ -70,7 +68,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
public String look;
|
||||
private final int type;
|
||||
private final int hue;
|
||||
private int deathTimestamp = Emulator.getIntUnixTimestamp() + timeToLive;
|
||||
private int deathTimestamp = Emulator.getIntUnixTimestamp() + TIME_TO_LIVE;
|
||||
private boolean canBreed = true;
|
||||
private boolean publiclyBreedable = false;
|
||||
private int growthStage = 0;
|
||||
@ -122,7 +120,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
if (this.isNeedsUpdate()) {
|
||||
super.run();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ?, mp_is_dead = ? WHERE id = ?")) {
|
||||
@ -156,15 +154,15 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath"));
|
||||
|
||||
this.hasDied = true;
|
||||
this.needsUpdate = true;
|
||||
this.setNeedsUpdate(true);
|
||||
}
|
||||
|
||||
this.roomUnit.clearStatus();
|
||||
this.roomUnit.setStatus(RoomUnitStatus.RIP, "");
|
||||
this.packetUpdate = true;
|
||||
this.setPacketUpdate(true);
|
||||
} else {
|
||||
int difference = Emulator.getIntUnixTimestamp() - this.created + 1;
|
||||
if (difference >= growTime) {
|
||||
if (difference >= GROW_TIME) {
|
||||
this.growthStage = 7;
|
||||
boolean clear = false;
|
||||
for (RoomUnitStatus s : this.roomUnit.getStatus().keySet()) {
|
||||
@ -176,22 +174,22 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
|
||||
if (clear) {
|
||||
this.roomUnit.clearStatus();
|
||||
this.packetUpdate = true;
|
||||
this.setPacketUpdate(true);
|
||||
}
|
||||
} else {
|
||||
int g = (int) Math.ceil(difference / (growTime / 7.0));
|
||||
int g = (int) Math.ceil(difference / (GROW_TIME / 7.0));
|
||||
|
||||
if (g > this.growthStage) {
|
||||
this.growthStage = g;
|
||||
this.roomUnit.clearStatus();
|
||||
this.roomUnit.setStatus(RoomUnitStatus.fromString("grw" + this.growthStage), "");
|
||||
this.packetUpdate = true;
|
||||
this.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Emulator.getRandom().nextInt(1000) < 10) {
|
||||
super.updateGesture(Emulator.getIntUnixTimestamp());
|
||||
this.packetUpdate = true;
|
||||
this.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -271,7 +269,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.max(0, growTime - (Emulator.getIntUnixTimestamp() - this.created));
|
||||
return Math.max(0, GROW_TIME - (Emulator.getIntUnixTimestamp() - this.created));
|
||||
}
|
||||
|
||||
public boolean isFullyGrown() {
|
||||
@ -368,7 +366,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy() {
|
||||
return MonsterplantPet.timeToLive;
|
||||
return MonsterplantPet.TIME_TO_LIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -384,7 +382,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
public synchronized void scratched(Habbo habbo) {
|
||||
if (this.mayScratch()) {
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
|
||||
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
||||
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.TIME_TO_LIVE);
|
||||
this.addHappiness(10);
|
||||
this.addExperience(10);
|
||||
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
|
||||
|
@ -24,6 +24,8 @@ import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
public class Pet implements ISerialize, Runnable {
|
||||
|
||||
@ -34,15 +36,13 @@ public class Pet implements ISerialize, Runnable {
|
||||
@Setter
|
||||
public int levelHunger;
|
||||
|
||||
/**
|
||||
* Whether the pet needs to be updated.
|
||||
*/
|
||||
public boolean needsUpdate = false;
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
/**
|
||||
* Whether the pet needs to be sent as a packet update.
|
||||
*/
|
||||
public boolean packetUpdate = false;
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean packetUpdate = false;
|
||||
@Getter
|
||||
protected int id;
|
||||
@Getter
|
||||
@ -162,10 +162,10 @@ public class Pet implements ISerialize, Runnable {
|
||||
/**
|
||||
* Creates a new pet with the given type, race, color, name, and owner.
|
||||
*
|
||||
* @param type the type of the pet
|
||||
* @param race the race of the pet
|
||||
* @param color the color of the pet
|
||||
* @param name the name of the pet
|
||||
* @param type the type of the pet
|
||||
* @param race the race of the pet
|
||||
* @param color the color of the pet
|
||||
* @param name the name of the pet
|
||||
* @param userId the ID of the user that owns the pet
|
||||
*/
|
||||
public Pet(int type, int race, String color, String name, int userId) {
|
||||
@ -281,7 +281,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate) {
|
||||
if (this.isNeedsUpdate()) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
|
||||
if (this.id > 0) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happyness = ?, created = ? WHERE id = ?")) {
|
||||
@ -323,16 +323,16 @@ public class Pet implements ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
this.needsUpdate = false;
|
||||
this.setNeedsUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a cycle of updates for the pet. This includes updates to their walking, tasks, happiness, hunger, thirst, and energy levels.
|
||||
* It also includes updates to their gestures and random actions, as well as vocalizing if they are not muted.
|
||||
* Performs a cycle of updates for the pet. This includes updates to their walking, tasks, happiness, hunger, thirst, and energy levels.
|
||||
* It also includes updates to their gestures and random actions, as well as vocalizing if they are not muted.
|
||||
*/
|
||||
public void cycle() {
|
||||
this.idleCommandTicks++;
|
||||
@ -341,7 +341,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
if (this.roomUnit != null && this.task != PetTasks.RIDE) {
|
||||
if (time - this.gestureTickTimeout > 5 && this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) {
|
||||
this.roomUnit.removeStatus(RoomUnitStatus.GESTURE);
|
||||
this.packetUpdate = true;
|
||||
this.setPacketUpdate(true);
|
||||
}
|
||||
|
||||
if (time - this.postureTimeout > 1 && this.task == null) {
|
||||
@ -373,7 +373,6 @@ public class Pet implements ISerialize, Runnable {
|
||||
if (this.levelThirst > 0)
|
||||
this.levelThirst--;
|
||||
|
||||
//this.addEnergy(5);
|
||||
|
||||
this.addHappiness(1);
|
||||
|
||||
@ -430,27 +429,25 @@ public class Pet implements ISerialize, Runnable {
|
||||
this.randomActionTickTimeout = time + (10 * Emulator.getRandom().nextInt(60));
|
||||
}
|
||||
|
||||
if (!this.muted) {
|
||||
if (this.chatTimeout <= time) {
|
||||
if (this.energy <= 30) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.TIRED));
|
||||
if (this.energy <= 10)
|
||||
this.findNest();
|
||||
} else if (this.happiness > 85) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_HAPPY));
|
||||
} else if (this.happiness < 15) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_SAD));
|
||||
} else if (this.levelHunger > 50) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.HUNGRY));
|
||||
this.eat();
|
||||
} else if (this.levelThirst > 50) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.THIRSTY));
|
||||
this.drink();
|
||||
}
|
||||
|
||||
int timeOut = Emulator.getRandom().nextInt(30);
|
||||
this.chatTimeout = time + (timeOut < 3 ? 30 : timeOut);
|
||||
if (!this.muted && this.chatTimeout <= time) {
|
||||
if (this.energy <= 30) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.TIRED));
|
||||
if (this.energy <= 10)
|
||||
this.findNest();
|
||||
} else if (this.happiness > 85) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_HAPPY));
|
||||
} else if (this.happiness < 15) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_SAD));
|
||||
} else if (this.levelHunger > 50) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.HUNGRY));
|
||||
this.eat();
|
||||
} else if (this.levelThirst > 50) {
|
||||
this.say(this.petData.randomVocal(PetVocalsType.THIRSTY));
|
||||
this.drink();
|
||||
}
|
||||
|
||||
int timeOut = Emulator.getRandom().nextInt(30);
|
||||
this.chatTimeout = time + (timeOut < 3 ? 30 : timeOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -459,8 +456,8 @@ public class Pet implements ISerialize, Runnable {
|
||||
* Handles a pet command.
|
||||
*
|
||||
* @param command The command to handle.
|
||||
* @param habbo The user who issued the command.
|
||||
* @param data The data for the command.
|
||||
* @param habbo The user who issued the command.
|
||||
* @param data The data for the command.
|
||||
*/
|
||||
public void handleCommand(PetCommand command, Habbo habbo, String[] data) {
|
||||
this.idleCommandTicks = 0;
|
||||
@ -520,7 +517,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
this.roomUnit.setStatus(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (!keys.isEmpty()) this.packetUpdate = true;
|
||||
if (!keys.isEmpty()) this.setPacketUpdate(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -602,7 +599,8 @@ public class Pet implements ISerialize, Runnable {
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||
try {
|
||||
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} else {
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
}
|
||||
@ -615,11 +613,9 @@ public class Pet implements ISerialize, Runnable {
|
||||
*/
|
||||
public void eat() {
|
||||
HabboItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods());
|
||||
{
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
}
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,19 +626,19 @@ public class Pet implements ISerialize, Runnable {
|
||||
*/
|
||||
public boolean findToy() {
|
||||
HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys());
|
||||
{
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||
try {
|
||||
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||
} catch (Exception ignored) {}
|
||||
return true;
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||
try {
|
||||
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
return true;
|
||||
}
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -656,18 +652,19 @@ public class Pet implements ISerialize, Runnable {
|
||||
public boolean findPetItem(PetTasks task, Class<? extends HabboItem> type) {
|
||||
HabboItem item = this.petData.randomToyHabboItem(this.room.getRoomSpecialTypes().getItemsOfType(type));
|
||||
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
this.setTask(task);
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||
try {
|
||||
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||
} catch (Exception ignored) {}
|
||||
return true;
|
||||
if (item != null) {
|
||||
this.roomUnit.setCanWalk(true);
|
||||
this.setTask(task);
|
||||
if (this.getRoomUnit().getCurrentLocation().distance(this.room.getLayout().getTile(item.getX(), item.getY())) == 0) {
|
||||
try {
|
||||
item.onWalkOn(this.getRoomUnit(), this.getRoom(), null);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
return true;
|
||||
}
|
||||
this.roomUnit.setGoalLocation(this.room.getLayout().getTile(item.getX(), item.getY()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -710,7 +707,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
if (this.room != null) {
|
||||
this.room.sendComposer(new PetExperienceComposer(this, amount).compose());
|
||||
|
||||
if(this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) {
|
||||
if (this.level < PetManager.experiences.length + 1 && this.experience >= PetManager.experiences[this.level - 1]) {
|
||||
this.levelUp();
|
||||
}
|
||||
}
|
||||
@ -720,20 +717,20 @@ public class Pet implements ISerialize, Runnable {
|
||||
* Levels up the pet if it has enough experience.
|
||||
*/
|
||||
protected void levelUp() {
|
||||
if (this.level >= PetManager.experiences.length + 1)
|
||||
return;
|
||||
if (this.level >= PetManager.experiences.length + 1)
|
||||
return;
|
||||
|
||||
if (this.experience > PetManager.experiences[this.level - 1]) {
|
||||
this.experience = PetManager.experiences[this.level - 1];
|
||||
}
|
||||
this.level++;
|
||||
this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP));
|
||||
this.addHappiness(100);
|
||||
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp");
|
||||
this.gestureTickTimeout = Emulator.getIntUnixTimestamp();
|
||||
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp"));
|
||||
this.room.sendComposer(new PetLevelUpdatedComposer(this).compose());
|
||||
if (this.experience > PetManager.experiences[this.level - 1]) {
|
||||
this.experience = PetManager.experiences[this.level - 1];
|
||||
}
|
||||
this.level++;
|
||||
this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP));
|
||||
this.addHappiness(100);
|
||||
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp");
|
||||
this.gestureTickTimeout = Emulator.getIntUnixTimestamp();
|
||||
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp"));
|
||||
this.room.sendComposer(new PetLevelUpdatedComposer(this).compose());
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the pet's thirst level by a given amount.
|
||||
@ -785,7 +782,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
this.addHappiness(10);
|
||||
this.addExperience(10);
|
||||
this.addRespect();
|
||||
this.needsUpdate = true;
|
||||
this.setNeedsUpdate(true);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getHabboStats().decreasePetRespectPointsToGive();
|
||||
@ -808,6 +805,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
|
||||
/**
|
||||
* Removes this pet from the room.
|
||||
*
|
||||
* @param dontSendPackets if true, packets will not be sent to update clients
|
||||
*/
|
||||
public void removeFromRoom(boolean dontSendPackets) {
|
||||
@ -823,7 +821,7 @@ public class Pet implements ISerialize, Runnable {
|
||||
|
||||
this.roomUnit = null;
|
||||
this.room = null;
|
||||
this.needsUpdate = true;
|
||||
this.setNeedsUpdate(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ public class PetManager {
|
||||
client.getHabbo().getHabboInfo().getId()
|
||||
);
|
||||
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -421,7 +421,7 @@ public class PetManager {
|
||||
public Pet createPet(int type, int race, String name, GameClient client) {
|
||||
if (this.petData.containsKey(type)) {
|
||||
Pet pet = new Pet(type, race, "FFFFFF", name, client.getHabbo().getHabboInfo().getId());
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -445,7 +445,7 @@ public class PetManager {
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomUnit());
|
||||
pet.getRoomUnit().setPathFinderRoom(room);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -464,7 +464,7 @@ public class PetManager {
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomUnit());
|
||||
pet.getRoomUnit().setPathFinderRoom(room);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
|
||||
return pet;
|
||||
@ -484,7 +484,7 @@ public class PetManager {
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomUnit());
|
||||
pet.getRoomUnit().setPathFinderRoom(room);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
|
||||
return pet;
|
||||
|
@ -20,11 +20,11 @@ public class ActionDown extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
if (pet.getTask() != PetTasks.DOWN && !pet.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
|
||||
pet.getRoomUnit().cmdLay = true;
|
||||
pet.getRoomUnit().setCmdLay(true);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.getRoomUnit().cmdLay = false;
|
||||
pet.getRoomUnit().setCmdLay(false);
|
||||
pet.clearPosture();
|
||||
}, this.minimumActionDuration);
|
||||
|
||||
|
@ -21,11 +21,11 @@ public class ActionSit extends PetAction {
|
||||
@Override
|
||||
public boolean apply(Pet pet, Habbo habbo, String[] data) {
|
||||
if (pet.getTask() != PetTasks.SIT && !pet.getRoomUnit().hasStatus(RoomUnitStatus.SIT)) {
|
||||
pet.getRoomUnit().cmdSit = true;
|
||||
pet.getRoomUnit().setCmdSit(true);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.SIT, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.getRoomUnit().cmdSit = false;
|
||||
pet.getRoomUnit().setCmdSit(false);
|
||||
pet.clearPosture();
|
||||
}, this.minimumActionDuration);
|
||||
|
||||
|
@ -83,9 +83,10 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
private static final String CAUGHT_SQL_EXCEPTION = "Caught SQL exception";
|
||||
private static final String CAUGHT_EXCEPTION = "Caught exception";
|
||||
|
||||
public static final Comparator<Room> SORT_SCORE = (o1, o2) -> o2.getScore() - o1.getScore();
|
||||
@ -754,7 +755,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
public void updateRoomUnit(RoomUnit roomUnit) {
|
||||
HabboItem item = this.getTopItemAt(roomUnit.getX(), roomUnit.getY());
|
||||
|
||||
if ((item == null && !roomUnit.cmdSit) || (item != null && !item.getBaseItem().allowSit()))
|
||||
if ((item == null && !roomUnit.isCmdSit()) || (item != null && !item.getBaseItem().allowSit()))
|
||||
roomUnit.removeStatus(RoomUnitStatus.SIT);
|
||||
|
||||
double oldZ = roomUnit.getZ();
|
||||
@ -794,12 +795,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
double z = habbo.getRoomUnit().getCurrentLocation().getStackHeight();
|
||||
boolean updated = false;
|
||||
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().cmdSit) || (item != null && !item.getBaseItem().allowSit()))) {
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT) && ((item == null && !habbo.getRoomUnit().isCmdSit()) || (item != null && !item.getBaseItem().allowSit()))) {
|
||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().cmdLay) || (item != null && !item.getBaseItem().allowLay()))) {
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) && ((item == null && !habbo.getRoomUnit().isCmdLay()) || (item != null && !item.getBaseItem().allowLay()))) {
|
||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.LAY);
|
||||
updated = true;
|
||||
}
|
||||
@ -845,7 +846,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
});
|
||||
|
||||
if (!roomUnits.isEmpty()) {
|
||||
this.sendComposer(new UserUpdateComposer(roomUnits, true).compose());
|
||||
this.sendComposer(new UserUpdateComposer(roomUnits).compose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1215,10 +1216,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.giveEffect(habbo, 0, -1);
|
||||
}
|
||||
|
||||
if (habbo.getRoomUnit().isKicked) {
|
||||
habbo.getRoomUnit().kickCount++;
|
||||
if (habbo.getRoomUnit().isKicked()) {
|
||||
habbo.getRoomUnit().setKickCount(habbo.getRoomUnit().getKickCount() + 1);
|
||||
|
||||
if (habbo.getRoomUnit().kickCount >= 5) {
|
||||
if (habbo.getRoomUnit().getKickCount() >= 5) {
|
||||
this.scheduledTasks.add(() -> Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, room));
|
||||
continue;
|
||||
}
|
||||
@ -1330,9 +1331,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
pet.cycle();
|
||||
|
||||
if (pet.packetUpdate) {
|
||||
if (pet.isPacketUpdate()) {
|
||||
updatedUnit.add(pet.getRoomUnit());
|
||||
pet.packetUpdate = false;
|
||||
pet.setPacketUpdate(false);
|
||||
}
|
||||
|
||||
if (pet.getRoomUnit().isWalking() && pet.getRoomUnit().getPath().size() == 1 && pet.getRoomUnit().hasStatus(RoomUnitStatus.GESTURE)) {
|
||||
@ -1518,7 +1519,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
if (unit.hasStatus(RoomUnitStatus.SIT)) {
|
||||
unit.sitUpdate = true;
|
||||
unit.setSitUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1581,7 +1582,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
if (!updatedUnit.isEmpty()) {
|
||||
this.sendComposer(new UserUpdateComposer(updatedUnit, true).compose());
|
||||
this.sendComposer(new UserUpdateComposer(updatedUnit).compose());
|
||||
}
|
||||
|
||||
this.traxManager.cycle();
|
||||
@ -1629,13 +1630,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.animateWalk) {
|
||||
if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.isAnimateWalk()) {
|
||||
unit.removeStatus(RoomUnitStatus.MOVE);
|
||||
|
||||
update = true;
|
||||
}
|
||||
|
||||
if (!unit.isWalking() && !unit.cmdSit) {
|
||||
if (!unit.isWalking() && !unit.isCmdSit()) {
|
||||
RoomTile thisTile = this.getLayout().getTile(unit.getX(), unit.getY());
|
||||
HabboItem topItem = this.getTallestChair(thisTile);
|
||||
|
||||
@ -1644,18 +1645,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
unit.removeStatus(RoomUnitStatus.SIT);
|
||||
update = true;
|
||||
}
|
||||
} else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.sitUpdate)) {
|
||||
} else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) {
|
||||
this.dance(unit, DanceType.NONE);
|
||||
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + "");
|
||||
unit.setZ(topItem.getZ());
|
||||
unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]);
|
||||
unit.sitUpdate = false;
|
||||
unit.setSitUpdate(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!unit.isWalking() && !unit.cmdLay) {
|
||||
if (!unit.isWalking() && !unit.isCmdLay()) {
|
||||
HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY());
|
||||
|
||||
if (topItem == null || !topItem.getBaseItem().allowLay()) {
|
||||
@ -1819,7 +1820,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet));
|
||||
}
|
||||
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.run();
|
||||
}
|
||||
|
||||
@ -2249,7 +2250,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
habbo.getClient().sendResponse(new GenericErrorComposer(GenericErrorComposer.KICKED_OUT_OF_THE_ROOM));
|
||||
}
|
||||
|
||||
habbo.getRoomUnit().isKicked = true;
|
||||
habbo.getRoomUnit().setKicked(true);
|
||||
habbo.getRoomUnit().setGoalLocation(this.layout.getDoorTile());
|
||||
|
||||
if (habbo.getRoomUnit().getPath() == null || habbo.getRoomUnit().getPath().size() <= 1 || this.isPublicRoom()) {
|
||||
@ -2271,7 +2272,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.currentHabbos.remove(habbo.getHabboInfo().getId());
|
||||
}
|
||||
|
||||
if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting) {
|
||||
if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting()) {
|
||||
this.sendComposer(new UserRemoveMessageComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
|
||||
@ -2415,7 +2416,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
.setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
|
||||
}
|
||||
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
this.furniOwnerNames.put(pet.getUserId(), this.getHabbo(pet.getUserId()).getHabboInfo().getUsername());
|
||||
this.addPet(pet);
|
||||
this.sendComposer(new RoomPetComposer(pet).compose());
|
||||
@ -2559,7 +2560,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
public void habboEntered(Habbo habbo) {
|
||||
habbo.getRoomUnit().animateWalk = false;
|
||||
habbo.getRoomUnit().setAnimateWalk(false);
|
||||
|
||||
synchronized (this.currentBots) {
|
||||
if (habbo.getHabboInfo().getId() != this.getOwnerId())
|
||||
@ -3566,7 +3567,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
|
||||
this.dance(habbo, DanceType.NONE);
|
||||
habbo.getRoomUnit().cmdSit = true;
|
||||
habbo.getRoomUnit().setCmdSit(true);
|
||||
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
|
||||
habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + "");
|
||||
this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
||||
@ -3577,7 +3578,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
|
||||
HabboItem item = this.getTopItemAt(habbo.getRoomUnit().getX(), habbo.getRoomUnit().getY());
|
||||
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
|
||||
habbo.getRoomUnit().cmdStand = true;
|
||||
habbo.getRoomUnit().setCmdStand(true);
|
||||
habbo.getRoomUnit().setBodyRotation(RoomUserRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
|
||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.SIT);
|
||||
this.sendComposer(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
||||
@ -3614,7 +3615,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
duration += Emulator.getIntUnixTimestamp();
|
||||
}
|
||||
|
||||
if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming) {
|
||||
if ((this.allowEffects || ignoreChecks) && !roomUnit.isSwimming()) {
|
||||
roomUnit.setEffectId(effectId, duration);
|
||||
this.sendComposer(new AvatarEffectMessageComposer(roomUnit).compose());
|
||||
}
|
||||
@ -4193,7 +4194,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if ((!stackHelper.isPresent() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT)) {
|
||||
if ((stackHelper.isEmpty() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack()) || (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT)) {
|
||||
item.setRotation(oldRotation);
|
||||
return FurnitureMovementError.CANT_STACK;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame;
|
||||
import com.eu.habbo.habbohotel.guilds.Guild;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWired;
|
||||
import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorFilterComparator;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorFilterField;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorManager;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
@ -58,11 +57,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
public class RoomManager {
|
||||
|
||||
private static final int page = 0;
|
||||
//Configuration. Loaded from database & updated accordingly.
|
||||
public static int MAXIMUM_ROOMS_USER = 25;
|
||||
public static int MAXIMUM_ROOMS_HC = 35;
|
||||
@ -72,6 +73,7 @@ public class RoomManager {
|
||||
private final THashMap<Integer, RoomCategory> roomCategories;
|
||||
private final List<String> mapNames;
|
||||
private final ConcurrentHashMap<Integer, Room> activeRooms;
|
||||
@Getter
|
||||
private final ArrayList<Class<? extends Game>> gameTypes;
|
||||
|
||||
public RoomManager() {
|
||||
@ -102,7 +104,7 @@ public class RoomManager {
|
||||
this.mapNames.add(set.getString("name"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +118,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return layout;
|
||||
@ -130,7 +132,7 @@ public class RoomManager {
|
||||
this.roomCategories.put(set.getInt("id"), new RoomCategory(set));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +148,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +173,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
@ -249,7 +251,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
@ -288,7 +290,7 @@ public class RoomManager {
|
||||
this.activeRooms.put(room.getId(), room);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return room;
|
||||
@ -298,7 +300,8 @@ public class RoomManager {
|
||||
public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId, int tradeType) {
|
||||
Room room = null;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category, trade_mode) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(
|
||||
"INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category, trade_mode) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, ownerId);
|
||||
statement.setString(2, ownerName);
|
||||
statement.setString(3, name);
|
||||
@ -313,7 +316,7 @@ public class RoomManager {
|
||||
room = this.loadRoom(set.getInt(1));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return room;
|
||||
@ -338,7 +341,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +391,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return layout;
|
||||
@ -422,7 +425,7 @@ public class RoomManager {
|
||||
statement.setInt(2, room.getId());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -443,7 +446,7 @@ public class RoomManager {
|
||||
return this.activeRooms.get(roomId);
|
||||
}
|
||||
|
||||
public ArrayList<Room> getActiveRooms() {
|
||||
public List<Room> getActiveRooms() {
|
||||
return new ArrayList<>(this.activeRooms.values());
|
||||
}
|
||||
|
||||
@ -471,12 +474,11 @@ public class RoomManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled()) {
|
||||
if (habbo.getHabboInfo().getCurrentRoom() == null) {
|
||||
habbo.getClient().sendResponse(new CloseConnectionMessageComposer());
|
||||
habbo.getHabboInfo().setLoadingRoom(0);
|
||||
return;
|
||||
}
|
||||
if (Emulator.getPluginManager().fireEvent(new UserEnterRoomEvent(habbo, room)).isCancelled()
|
||||
&& habbo.getHabboInfo().getCurrentRoom() == null) {
|
||||
habbo.getClient().sendResponse(new CloseConnectionMessageComposer());
|
||||
habbo.getHabboInfo().setLoadingRoom(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (room.isBanned(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER) && !habbo.hasPermission(Permission.ACC_ENTERANYROOM)) {
|
||||
@ -579,7 +581,7 @@ public class RoomManager {
|
||||
habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
|
||||
} else {
|
||||
habbo.getRoomUnit().setCanLeaveRoomByDoor(false);
|
||||
habbo.getRoomUnit().isTeleporting = true;
|
||||
habbo.getRoomUnit().setTeleporting(true);
|
||||
HabboItem topItem = room.getTopItemAt(doorLocation.getX(), doorLocation.getY());
|
||||
if (topItem != null) {
|
||||
habbo.getRoomUnit().setRotation(RoomUserRotation.values()[topItem.getRotation()]);
|
||||
@ -599,7 +601,7 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
habbo.getRoomUnit().clearStatus();
|
||||
habbo.getRoomUnit().cmdTeleport = false;
|
||||
habbo.getRoomUnit().setCmdTeleport(false);
|
||||
|
||||
habbo.getClient().sendResponse(new OpenConnectionMessageComposer());
|
||||
|
||||
@ -654,20 +656,22 @@ public class RoomManager {
|
||||
return;
|
||||
}
|
||||
|
||||
habbo.getRoomUnit().removeStatus(RoomUnitStatus.FLAT_CONTROL);
|
||||
habbo.getHabboInfo().setLoadingRoom(0);
|
||||
habbo.getHabboInfo().setCurrentRoom(room);
|
||||
habbo.getRoomUnit().setPathFinderRoom(room);
|
||||
habbo.getRoomUnit().setHandItem(0);
|
||||
habbo.getRoomUnit()
|
||||
.removeStatus(RoomUnitStatus.FLAT_CONTROL)
|
||||
.setPathFinderRoom(room)
|
||||
.setHandItem(0)
|
||||
.setRightsLevel(RoomRightLevels.NONE);
|
||||
|
||||
habbo.getHabboInfo().setLoadingRoom(0)
|
||||
.setCurrentRoom(room);
|
||||
|
||||
habbo.getRoomUnit().setRightsLevel(RoomRightLevels.NONE);
|
||||
room.refreshRightsForHabbo(habbo);
|
||||
if (habbo.getRoomUnit().isKicked && !habbo.getRoomUnit().canWalk()) {
|
||||
if (habbo.getRoomUnit().isKicked() && !habbo.getRoomUnit().canWalk()) {
|
||||
habbo.getRoomUnit().setCanWalk(true);
|
||||
}
|
||||
habbo.getRoomUnit().isKicked = false;
|
||||
habbo.getRoomUnit().setKicked(false);
|
||||
|
||||
if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting) {
|
||||
if (habbo.getRoomUnit().getCurrentLocation() == null && !habbo.getRoomUnit().isTeleporting()) {
|
||||
RoomTile doorTile = room.getLayout().getTile(room.getLayout().getDoorX(), room.getLayout().getDoorY());
|
||||
|
||||
if (doorTile != null) {
|
||||
@ -697,19 +701,12 @@ public class RoomManager {
|
||||
visibleHabbos = event.getVisibleHabbos();
|
||||
}
|
||||
|
||||
for (Habbo habboToSendEnter : habbosToSendEnter) {
|
||||
GameClient client = habboToSendEnter.getClient();
|
||||
if (client != null) {
|
||||
client.sendResponse(new RoomUsersComposer(habbo).compose());
|
||||
client.sendResponse(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
||||
}
|
||||
}
|
||||
habbosToSendEnter.stream().map(Habbo::getClient).filter(Objects::nonNull).forEach(client -> {
|
||||
client.sendResponse(new RoomUsersComposer(habbo).compose());
|
||||
client.sendResponse(new UserUpdateComposer(habbo.getRoomUnit()).compose());
|
||||
});
|
||||
|
||||
for (Habbo h : visibleHabbos) {
|
||||
if (!h.getRoomUnit().isInvisible()) {
|
||||
habbos.add(h);
|
||||
}
|
||||
}
|
||||
habbos = visibleHabbos.stream().filter(h -> !h.getRoomUnit().isInvisible()).toList();
|
||||
|
||||
synchronized (room.roomUnitLock) {
|
||||
habbo.getClient().sendResponse(new RoomUsersComposer(habbos));
|
||||
@ -731,63 +728,48 @@ public class RoomManager {
|
||||
|
||||
habbo.getClient().sendResponse(new RoomUsersComposer(room.getCurrentBots().valueCollection(), true));
|
||||
if (!room.getCurrentBots().isEmpty()) {
|
||||
TIntObjectIterator<Bot> botIterator = room.getCurrentBots().iterator();
|
||||
for (int i = room.getCurrentBots().size(); i-- > 0; ) {
|
||||
try {
|
||||
botIterator.advance();
|
||||
} catch (NoSuchElementException e) {
|
||||
break;
|
||||
}
|
||||
Bot bot = botIterator.value();
|
||||
if (!bot.getRoomUnit().getDanceType().equals(DanceType.NONE)) {
|
||||
habbo.getClient().sendResponse(new DanceMessageComposer(bot.getRoomUnit()));
|
||||
}
|
||||
room.getCurrentBots().valueCollection().stream()
|
||||
.filter(b -> !b.getRoomUnit().getDanceType().equals(DanceType.NONE))
|
||||
.forEach(b -> habbo.getClient().sendResponse(new DanceMessageComposer(b.getRoomUnit())));
|
||||
|
||||
habbo.getClient().sendResponse(new UserUpdateComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ()));
|
||||
}
|
||||
room.getCurrentBots().valueCollection()
|
||||
.forEach(b -> habbo.getClient().sendResponse(new UserUpdateComposer(b.getRoomUnit(), b.getRoomUnit().getZ())));
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new RoomEntryInfoMessageComposer(room, room.isOwner(habbo)));
|
||||
|
||||
habbo.getClient().sendResponse(new RoomVisualizationSettingsComposer(room));
|
||||
|
||||
habbo.getClient().sendResponse(new GetGuestRoomResultComposer(room, habbo.getClient().getHabbo(), false, true));
|
||||
|
||||
habbo.getClient().sendResponse(new ItemsComposer(room));
|
||||
{
|
||||
final THashSet<HabboItem> floorItems = new THashSet<>();
|
||||
final THashSet<HabboItem> floorItems = new THashSet<>();
|
||||
|
||||
THashSet<HabboItem> allFloorItems = new THashSet<>(room.getFloorItems());
|
||||
THashSet<HabboItem> allFloorItems = new THashSet<>(room.getFloorItems());
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) {
|
||||
RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems));
|
||||
if (roomFloorItemsLoadEvent.hasChangedFloorItems()) {
|
||||
allFloorItems = roomFloorItemsLoadEvent.getFloorItems();
|
||||
}
|
||||
if (Emulator.getPluginManager().isRegistered(RoomFloorItemsLoadEvent.class, true)) {
|
||||
RoomFloorItemsLoadEvent roomFloorItemsLoadEvent = Emulator.getPluginManager().fireEvent(new RoomFloorItemsLoadEvent(habbo, allFloorItems));
|
||||
if (roomFloorItemsLoadEvent.hasChangedFloorItems()) {
|
||||
allFloorItems = roomFloorItemsLoadEvent.getFloorItems();
|
||||
}
|
||||
}
|
||||
|
||||
allFloorItems.forEach(object -> {
|
||||
if (room.isHideWired() && object instanceof InteractionWired)
|
||||
return true;
|
||||
|
||||
floorItems.add(object);
|
||||
if (floorItems.size() == 250) {
|
||||
habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems));
|
||||
floorItems.clear();
|
||||
}
|
||||
|
||||
allFloorItems.forEach(object -> {
|
||||
if (room.isHideWired() && object instanceof InteractionWired)
|
||||
return true;
|
||||
return true;
|
||||
});
|
||||
|
||||
floorItems.add(object);
|
||||
if (floorItems.size() == 250) {
|
||||
habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems));
|
||||
floorItems.clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems));
|
||||
floorItems.clear();
|
||||
}
|
||||
habbo.getClient().sendResponse(new ObjectsMessageComposer(room.getFurniOwnerNames(), floorItems));
|
||||
floorItems.clear();
|
||||
|
||||
if (!room.getCurrentPets().isEmpty()) {
|
||||
habbo.getClient().sendResponse(new RoomPetComposer(room.getCurrentPets()));
|
||||
for (Pet pet : room.getCurrentPets().valueCollection()) {
|
||||
habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit()));
|
||||
}
|
||||
room.getCurrentPets().valueCollection().forEach(pet -> habbo.getClient().sendResponse(new UserUpdateComposer(pet.getRoomUnit())));
|
||||
}
|
||||
|
||||
if (!habbo.getHabboStats().allowTalk()) {
|
||||
@ -802,69 +784,66 @@ public class RoomManager {
|
||||
|
||||
THashMap<Integer, String> guildBadges = new THashMap<>();
|
||||
for (Habbo roomHabbo : habbos) {
|
||||
{
|
||||
if (roomHabbo.getRoomUnit().getDanceType().getType() > 0) {
|
||||
habbo.getClient().sendResponse(new DanceMessageComposer(roomHabbo.getRoomUnit()));
|
||||
if (roomHabbo.getRoomUnit().getDanceType().getType() > 0) {
|
||||
habbo.getClient().sendResponse(new DanceMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().getHandItem() > 0) {
|
||||
habbo.getClient().sendResponse(new CarryObjectMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().getEffectId() > 0) {
|
||||
habbo.getClient().sendResponse(new AvatarEffectMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().isIdle()) {
|
||||
habbo.getClient().sendResponse(new SleepMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
|
||||
roomHabbo.getClient().sendResponse(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.IGNORED));
|
||||
}
|
||||
|
||||
if (!roomHabbo.getHabboStats().allowTalk()) {
|
||||
habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.MUTED));
|
||||
} else if (habbo.getHabboStats().userIgnored(roomHabbo.getHabboInfo().getId())) {
|
||||
habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.IGNORED));
|
||||
}
|
||||
|
||||
if (roomHabbo.getHabboStats().getGuild() != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().getGuild())) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().getGuild());
|
||||
|
||||
if (guild != null) {
|
||||
guildBadges.put(roomHabbo.getHabboStats().getGuild(), guild.getBadge());
|
||||
}
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().getHandItem() > 0) {
|
||||
habbo.getClient().sendResponse(new CarryObjectMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) {
|
||||
try {
|
||||
habbo.getClient().sendResponse(new UserRemoveMessageComposer(roomHabbo.getRoomUnit()));
|
||||
habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) roomHabbo.getHabboStats().getCache().get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().getCache().get("pet_race"), (String) roomHabbo.getHabboStats().getCache().get("pet_color"), roomHabbo));
|
||||
} catch (Exception ignored) {
|
||||
|
||||
if (roomHabbo.getRoomUnit().getEffectId() > 0) {
|
||||
habbo.getClient().sendResponse(new AvatarEffectMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().isIdle()) {
|
||||
habbo.getClient().sendResponse(new SleepMessageComposer(roomHabbo.getRoomUnit()));
|
||||
}
|
||||
|
||||
if (roomHabbo.getHabboStats().userIgnored(habbo.getHabboInfo().getId())) {
|
||||
roomHabbo.getClient().sendResponse(new IgnoreResultMessageComposer(habbo, IgnoreResultMessageComposer.IGNORED));
|
||||
}
|
||||
|
||||
if (!roomHabbo.getHabboStats().allowTalk()) {
|
||||
habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.MUTED));
|
||||
} else if (habbo.getHabboStats().userIgnored(roomHabbo.getHabboInfo().getId())) {
|
||||
habbo.getClient().sendResponse(new IgnoreResultMessageComposer(roomHabbo, IgnoreResultMessageComposer.IGNORED));
|
||||
}
|
||||
|
||||
if (roomHabbo.getHabboStats().getGuild() != 0 && !guildBadges.containsKey(roomHabbo.getHabboStats().getGuild())) {
|
||||
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(roomHabbo.getHabboStats().getGuild());
|
||||
|
||||
if (guild != null) {
|
||||
guildBadges.put(roomHabbo.getHabboStats().getGuild(), guild.getBadge());
|
||||
}
|
||||
}
|
||||
|
||||
if (roomHabbo.getRoomUnit().getRoomUnitType().equals(RoomUnitType.PET)) {
|
||||
try {
|
||||
habbo.getClient().sendResponse(new UserRemoveMessageComposer(roomHabbo.getRoomUnit()));
|
||||
habbo.getClient().sendResponse(new RoomUserPetComposer(((PetData) roomHabbo.getHabboStats().getCache().get("pet_type")).getType(), (Integer) roomHabbo.getHabboStats().getCache().get("pet_race"), (String) roomHabbo.getHabboStats().getCache().get("pet_color"), roomHabbo));
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
habbo.getClient().sendResponse(new HabboGroupBadgesMessageComposer(guildBadges));
|
||||
|
||||
if (room.hasRights(habbo) || (room.hasGuild() && room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS))) {
|
||||
if (!room.getHabboQueue().isEmpty()) {
|
||||
for (Habbo waiting : room.getHabboQueue().valueCollection()) {
|
||||
habbo.getClient().sendResponse(new DoorbellMessageComposer(waiting.getHabboInfo().getUsername()));
|
||||
}
|
||||
if ((room.hasRights(habbo)
|
||||
|| (room.hasGuild()
|
||||
&& room.getGuildRightLevel(habbo).isEqualOrGreaterThan(RoomRightLevels.GUILD_RIGHTS)))
|
||||
&& !room.getHabboQueue().isEmpty()) {
|
||||
for (Habbo waiting : room.getHabboQueue().valueCollection()) {
|
||||
habbo.getClient().sendResponse(new DoorbellMessageComposer(waiting.getHabboInfo().getUsername()));
|
||||
}
|
||||
}
|
||||
|
||||
if (room.getPollId() > 0) {
|
||||
if (!PollManager.donePoll(habbo.getClient().getHabbo(), room.getPollId())) {
|
||||
Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(room.getPollId());
|
||||
if (room.getPollId() > 0 && !PollManager.donePoll(habbo.getClient().getHabbo(), room.getPollId())) {
|
||||
Poll poll = Emulator.getGameEnvironment().getPollManager().getPoll(room.getPollId());
|
||||
|
||||
if (poll != null) {
|
||||
habbo.getClient().sendResponse(new PollOfferComposer(poll));
|
||||
}
|
||||
if (poll != null) {
|
||||
habbo.getClient().sendResponse(new PollOfferComposer(poll));
|
||||
}
|
||||
}
|
||||
|
||||
@ -895,7 +874,7 @@ public class RoomManager {
|
||||
if (!habbo.getHabboStats().visitedRoom(room.getId()))
|
||||
habbo.getHabboStats().addVisitRoom(room.getId());
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -914,7 +893,7 @@ public class RoomManager {
|
||||
habbo.getClient().sendResponse(new CloseConnectionMessageComposer());
|
||||
}
|
||||
habbo.getHabboInfo().setCurrentRoom(null);
|
||||
habbo.getRoomUnit().isKicked = false;
|
||||
habbo.getRoomUnit().setKicked(false);
|
||||
|
||||
if (room.getOwnerId() != habbo.getHabboInfo().getId()) {
|
||||
AchievementManager.progressAchievement(room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), (int) Math.floor((Emulator.getIntUnixTimestamp() - habbo.getHabboStats().roomEnterTimestamp) / 60000.0));
|
||||
@ -948,7 +927,7 @@ public class RoomManager {
|
||||
statement.setInt(3, room.getId());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -968,52 +947,24 @@ public class RoomManager {
|
||||
return new TreeMap<>(tagCount).keySet();
|
||||
}
|
||||
|
||||
public ArrayList<Room> getPublicRooms() {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
if (room.isPublicRoom()) {
|
||||
rooms.add(room);
|
||||
}
|
||||
}
|
||||
rooms.sort(Room.SORT_ID);
|
||||
return rooms;
|
||||
public List<Room> getPublicRooms() {
|
||||
return this.activeRooms.values().stream().filter(Room::isPublicRoom).sorted(Room.SORT_ID).toList();
|
||||
}
|
||||
|
||||
public ArrayList<Room> getPopularRooms(int count) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
if (room.getUserCount() > 0) {
|
||||
if (!room.isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB) rooms.add(room);
|
||||
}
|
||||
}
|
||||
|
||||
if (rooms.isEmpty()) {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
Collections.sort(rooms);
|
||||
|
||||
return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count))));
|
||||
public List<Room> getPopularRooms(int count) {
|
||||
return this.activeRooms.values().stream()
|
||||
.filter(room -> room.getUserCount() > 0 && (!room.isPublicRoom() || RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB))
|
||||
.sorted()
|
||||
.limit(count)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public ArrayList<Room> getPopularRooms(int count, int category) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
if (!room.isPublicRoom() && room.getCategory() == category) {
|
||||
rooms.add(room);
|
||||
}
|
||||
}
|
||||
|
||||
if (rooms.isEmpty()) {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
Collections.sort(rooms);
|
||||
|
||||
return new ArrayList<>(rooms.subList(0, (Math.min(rooms.size(), count))));
|
||||
public List<Room> getPopularRooms(int count, int category) {
|
||||
return this.activeRooms.values().stream()
|
||||
.filter(room -> !room.isPublicRoom() && room.getCategory() == category)
|
||||
.sorted()
|
||||
.limit(count)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Map<Integer, List<Room>> getPopularRoomsByCategory(int count) {
|
||||
@ -1043,14 +994,8 @@ public class RoomManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithName(String name) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
if (room.getName().toLowerCase().contains(name.toLowerCase())) {
|
||||
rooms.add(room);
|
||||
}
|
||||
}
|
||||
public List<Room> getRoomsWithName(String name) {
|
||||
List<Room> rooms = new ArrayList<>(activeRooms.values().stream().filter(room -> room.getName().equalsIgnoreCase(name)).toList());
|
||||
|
||||
if (rooms.size() < 25) {
|
||||
rooms.addAll(this.getOfflineRoomsWithName(name));
|
||||
@ -1077,13 +1022,13 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithTag(String tag) {
|
||||
public List<Room> getRoomsWithTag(String tag) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
@ -1100,7 +1045,7 @@ public class RoomManager {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getGroupRoomsWithName(String name) {
|
||||
public List<Room> getGroupRoomsWithName(String name) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (Room room : this.activeRooms.values()) {
|
||||
@ -1137,13 +1082,13 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsFriendsNow(Habbo habbo) {
|
||||
public List<Room> getRoomsFriendsNow(Habbo habbo) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) {
|
||||
@ -1162,7 +1107,7 @@ public class RoomManager {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsFriendsOwn(Habbo habbo) {
|
||||
public List<Room> getRoomsFriendsOwn(Habbo habbo) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) {
|
||||
@ -1182,7 +1127,7 @@ public class RoomManager {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) {
|
||||
public List<Room> getRoomsVisited(Habbo habbo, boolean includeSelf, int limit) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM room_enter_log INNER JOIN rooms ON room_enter_log.room_id = rooms.id WHERE user_id = ? AND timestamp >= ? AND rooms.owner_id != ? GROUP BY rooms.id AND timestamp ORDER BY timestamp DESC LIMIT " + limit)) {
|
||||
@ -1203,7 +1148,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
Collections.sort(rooms);
|
||||
@ -1211,7 +1156,7 @@ public class RoomManager {
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsFavourite(Habbo habbo) {
|
||||
public List<Room> getRoomsFavourite(Habbo habbo) {
|
||||
final ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
habbo.getHabboStats().getFavoriteRooms().forEach(value -> {
|
||||
@ -1246,7 +1191,7 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
Collections.sort(rooms);
|
||||
@ -1254,7 +1199,7 @@ public class RoomManager {
|
||||
return rooms.subList(0, (Math.min(rooms.size(), limit)));
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithRights(Habbo habbo) {
|
||||
public List<Room> getRoomsWithRights(Habbo habbo) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT rooms.* FROM rooms INNER JOIN room_rights ON room_rights.room_id = rooms.id WHERE room_rights.user_id = ? ORDER BY rooms.id DESC LIMIT 30")) {
|
||||
@ -1269,13 +1214,13 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithFriendsIn(Habbo habbo, int limit) {
|
||||
public List<Room> getRoomsWithFriendsIn(Habbo habbo, int limit) {
|
||||
final ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
for (MessengerBuddy buddy : habbo.getMessenger().getFriends().values()) {
|
||||
@ -1311,13 +1256,13 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsWithAdminRights(Habbo habbo) {
|
||||
public List<Room> getRoomsWithAdminRights(Habbo habbo) {
|
||||
ArrayList<Room> rooms = new ArrayList<>();
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
@ -1333,71 +1278,34 @@ public class RoomManager {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return rooms;
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsInGroup() {
|
||||
public List<Room> getRoomsInGroup() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsPromoted() {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : this.getActiveRooms()) {
|
||||
if (room.isPromoted()) {
|
||||
r.add(room);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
public List<Room> getRoomsPromoted() {
|
||||
return activeRooms.values().stream().filter(Room::isPromoted).toList();
|
||||
}
|
||||
|
||||
public ArrayList<Room> getRoomsStaffPromoted() {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : this.getActiveRooms()) {
|
||||
if (room.isStaffPromotedRoom()) {
|
||||
r.add(room);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
public List<Room> getRoomsStaffPromoted() {
|
||||
return activeRooms.values().stream().filter(Room::isStaffPromotedRoom).toList();
|
||||
}
|
||||
|
||||
public List<Room> filterRoomsByOwner(List<Room> rooms, String filter) {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (room.getOwnerName().equalsIgnoreCase(filter))
|
||||
r.add(room);
|
||||
}
|
||||
|
||||
return r;
|
||||
return rooms.stream().filter(r -> r.getOwnerName().equalsIgnoreCase(filter)).toList();
|
||||
}
|
||||
|
||||
public List<Room> filterRoomsByName(List<Room> rooms, String filter) {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (room.getName().toLowerCase().contains(filter.toLowerCase()))
|
||||
r.add(room);
|
||||
}
|
||||
|
||||
return r;
|
||||
return rooms.stream().filter(room -> room.getName().toLowerCase().contains(filter.toLowerCase())).toList();
|
||||
}
|
||||
|
||||
public List<Room> filterRoomsByNameAndDescription(List<Room> rooms, String filter) {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (room.getName().toLowerCase().contains(filter.toLowerCase()) || room.getDescription().toLowerCase().contains(filter.toLowerCase()))
|
||||
r.add(room);
|
||||
}
|
||||
|
||||
return r;
|
||||
return rooms.stream().filter(room -> room.getName().toLowerCase().contains(filter.toLowerCase()) || room.getDescription().toLowerCase().contains(filter.toLowerCase())).toList();
|
||||
}
|
||||
|
||||
public List<Room> filterRoomsByTag(List<Room> rooms, String filter) {
|
||||
@ -1417,17 +1325,9 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
public List<Room> filterRoomsByGroup(List<Room> rooms, String filter) {
|
||||
ArrayList<Room> r = new ArrayList<>();
|
||||
|
||||
for (Room room : rooms) {
|
||||
if (room.getGuildId() == 0)
|
||||
continue;
|
||||
|
||||
if (Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()).getName().toLowerCase().contains(filter.toLowerCase()))
|
||||
r.add(room);
|
||||
}
|
||||
|
||||
return r;
|
||||
return rooms.stream().filter(room -> room.getGuildId() != 0)
|
||||
.filter(room -> Emulator.getGameEnvironment().getGuildManager().getGuild(room.getGuildId()).getName().toLowerCase().contains(filter.toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public synchronized void dispose() {
|
||||
@ -1454,7 +1354,7 @@ public class RoomManager {
|
||||
statement.setString(10, map);
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
return this.loadCustomLayout(room);
|
||||
@ -1498,11 +1398,9 @@ public class RoomManager {
|
||||
|
||||
room.addRoomBan(roomBan);
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getCurrentRoom() == room) {
|
||||
room.removeHabbo(habbo, true);
|
||||
habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED));
|
||||
}
|
||||
if (habbo != null && habbo.getHabboInfo().getCurrentRoom() == room) {
|
||||
room.removeHabbo(habbo, true);
|
||||
habbo.getClient().sendResponse(new CantConnectMessageComposer(CantConnectMessageComposer.ROOM_ERROR_BANNED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1514,10 +1412,6 @@ public class RoomManager {
|
||||
gameTypes.remove(gameClass);
|
||||
}
|
||||
|
||||
public ArrayList<Class<? extends Game>> getGameTypes() {
|
||||
return gameTypes;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum RoomBanTypes {
|
||||
|
@ -29,35 +29,60 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class RoomUnit {
|
||||
|
||||
public boolean isWiredTeleporting = false;
|
||||
public boolean isLeavingTeleporter = false;
|
||||
public boolean isSwimming = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isWiredTeleporting = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isLeavingTeleporter = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isSwimming = false;
|
||||
@Getter
|
||||
private final ConcurrentHashMap<RoomUnitStatus, String> status;
|
||||
private final THashMap<String, Object> cacheable;
|
||||
public boolean canRotate = true;
|
||||
public boolean animateWalk = false;
|
||||
public boolean cmdTeleport = false;
|
||||
public boolean cmdSit = false;
|
||||
public boolean cmdStand = false;
|
||||
public boolean cmdLay = false;
|
||||
public boolean sitUpdate = false;
|
||||
public boolean isTeleporting = false;
|
||||
public boolean isKicked;
|
||||
public int kickCount = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean canRotate = true;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean animateWalk = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cmdTeleport = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cmdSit = false;
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean cmdStand = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cmdLay = false;
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean sitUpdate = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isTeleporting = false;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isKicked;
|
||||
@Getter
|
||||
@Setter
|
||||
private int kickCount = 0;
|
||||
private int id;
|
||||
@Getter
|
||||
private RoomTile startLocation;
|
||||
@Getter
|
||||
private RoomTile previousLocation;
|
||||
@Getter
|
||||
@Setter @Accessors(chain = true)
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
private double previousLocationZ;
|
||||
private RoomTile currentLocation;
|
||||
@Getter
|
||||
@ -76,6 +101,7 @@ public class RoomUnit {
|
||||
private boolean fastWalk = false;
|
||||
private boolean statusUpdate = false;
|
||||
private boolean invisible = false;
|
||||
@Setter
|
||||
private boolean canLeaveRoomByDoor = true;
|
||||
@Setter
|
||||
private RoomUserRotation bodyRotation = RoomUserRotation.NORTH;
|
||||
@ -97,7 +123,6 @@ public class RoomUnit {
|
||||
private int effectEndTimestamp;
|
||||
private int previousEffectId;
|
||||
private int previousEffectEndTimestamp;
|
||||
private ScheduledFuture moveBlockingTask;
|
||||
private int timeInRoom;
|
||||
|
||||
private int idleTimer;
|
||||
@ -119,7 +144,7 @@ public class RoomUnit {
|
||||
this.effectId = 0;
|
||||
this.previousEffectId = 0;
|
||||
this.previousEffectEndTimestamp = -1;
|
||||
this.isKicked = false;
|
||||
this.setKicked(false);
|
||||
this.overridableTiles = new THashSet<>();
|
||||
this.timeInRoom = 0;
|
||||
}
|
||||
@ -143,46 +168,17 @@ public class RoomUnit {
|
||||
|
||||
public boolean cycle(Room room) {
|
||||
try {
|
||||
Habbo rider = null;
|
||||
if (this.getRoomUnitType() == RoomUnitType.PET) {
|
||||
Pet pet = room.getPet(this);
|
||||
if (pet instanceof RideablePet) {
|
||||
rider = ((RideablePet) pet).getRider();
|
||||
}
|
||||
}
|
||||
|
||||
if (rider != null) {
|
||||
// copy things from rider
|
||||
if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatus().containsKey(RoomUnitStatus.MOVE)) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
}
|
||||
|
||||
if (rider.getRoomUnit().getCurrentLocation().getX() != this.getX() || rider.getRoomUnit().getCurrentLocation().getY() != this.getY()) {
|
||||
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().getX() + "," + rider.getRoomUnit().getCurrentLocation().getY() + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
||||
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
||||
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
||||
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
||||
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
}
|
||||
|
||||
if (handleRider(room))
|
||||
return this.statusUpdate;
|
||||
|
||||
Habbo habboT = room.getHabbo(this);
|
||||
if (!this.isWalking() && !this.isKicked() && this.status.remove(RoomUnitStatus.MOVE) == null && habboT != null) {
|
||||
habboT.getHabboInfo().getRiding().getRoomUnit().status.remove(RoomUnitStatus.MOVE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!this.isWalking() && !this.isKicked) {
|
||||
if (this.status.remove(RoomUnitStatus.MOVE) == null) {
|
||||
Habbo habboT = room.getHabbo(this);
|
||||
if (habboT != null) {
|
||||
habboT.getHabboInfo().getRiding().getRoomUnit().status.remove(RoomUnitStatus.MOVE);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.status.remove(RoomUnitStatus.SIT) != null) this.statusUpdate = true;
|
||||
if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true;
|
||||
if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true;
|
||||
if (this.status.remove(RoomUnitStatus.SIT) != null || this.status.remove(RoomUnitStatus.MOVE) != null || this.status.remove(RoomUnitStatus.LAY) != null)
|
||||
this.statusUpdate = true;
|
||||
|
||||
for (Map.Entry<RoomUnitStatus, String> set : this.status.entrySet()) {
|
||||
if (set.getKey().isRemoveWhenWalking()) {
|
||||
@ -193,18 +189,13 @@ public class RoomUnit {
|
||||
if (this.path == null || this.path.isEmpty())
|
||||
return true;
|
||||
|
||||
boolean canfastwalk = true;
|
||||
Habbo habboT = room.getHabbo(this);
|
||||
if (habboT != null) {
|
||||
if (habboT.getHabboInfo().getRiding() != null)
|
||||
canfastwalk = false;
|
||||
}
|
||||
boolean canfastwalk = habboT == null || habboT.getHabboInfo().getRiding() == null;
|
||||
|
||||
RoomTile next = this.path.poll();
|
||||
boolean overrideChecks = next != null && this.canOverrideTile(next);
|
||||
|
||||
if (this.path.isEmpty()) {
|
||||
this.sitUpdate = true;
|
||||
this.setSitUpdate(true);
|
||||
|
||||
if (next != null && next.hasUnits() && !overrideChecks) {
|
||||
return false;
|
||||
@ -230,10 +221,8 @@ public class RoomUnit {
|
||||
}
|
||||
}
|
||||
|
||||
if (canfastwalk && this.fastWalk) {
|
||||
if (this.path.size() > 1) {
|
||||
next = this.path.poll();
|
||||
}
|
||||
if (canfastwalk && this.fastWalk && this.path.size() > 1) {
|
||||
next = this.path.poll();
|
||||
}
|
||||
|
||||
if (next == null)
|
||||
@ -248,11 +237,9 @@ public class RoomUnit {
|
||||
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (!event.isIdle()) {
|
||||
room.unIdle(habbo);
|
||||
this.idleTimer = 0;
|
||||
}
|
||||
if (!event.isCancelled() && !event.isIdle()) {
|
||||
room.unIdle(habbo);
|
||||
this.idleTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,21 +254,18 @@ public class RoomUnit {
|
||||
|
||||
HabboItem item = room.getTopItemAt(next.getX(), next.getY());
|
||||
|
||||
//if(!(this.path.size() == 0 && canSitNextTile))
|
||||
{
|
||||
double height = next.getStackHeight() - this.currentLocation.getStackHeight();
|
||||
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
||||
this.room = room;
|
||||
this.path.clear();
|
||||
this.findPath();
|
||||
|
||||
if (this.path.isEmpty()) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
return false;
|
||||
}
|
||||
next = this.path.pop();
|
||||
double height = next.getStackHeight() - this.currentLocation.getStackHeight();
|
||||
if (!room.tileWalkable(next) || (!RoomLayout.ALLOW_FALLING && height < -RoomLayout.MAXIMUM_STEP_HEIGHT) || (next.getState() == RoomTileState.OPEN && height > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
||||
this.room = room;
|
||||
this.path.clear();
|
||||
this.findPath();
|
||||
|
||||
if (this.path.isEmpty()) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
return false;
|
||||
}
|
||||
next = this.path.pop();
|
||||
|
||||
}
|
||||
|
||||
boolean canSitNextTile = room.canSitAt(next.getX(), next.getY());
|
||||
@ -293,31 +277,21 @@ public class RoomUnit {
|
||||
item = tallestChair;
|
||||
}
|
||||
|
||||
if (next.equals(this.goalLocation) && next.getState() == RoomTileState.SIT && !overrideChecks) {
|
||||
if (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
return false;
|
||||
}
|
||||
if (next.equals(this.goalLocation) && next.getState() == RoomTileState.SIT && !overrideChecks
|
||||
&& (item == null || item.getZ() - this.getZ() > RoomLayout.MAXIMUM_STEP_HEIGHT)) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
return false;
|
||||
}
|
||||
|
||||
double zHeight = 0.0D;
|
||||
|
||||
/*if (((habbo != null && habbo.getHabboInfo().getRiding() != null) || isRiding) && next.equals(this.goalLocation) && (next.state == RoomTileState.SIT || next.state == RoomTileState.LAY)) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
return false;
|
||||
}*/
|
||||
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getRiding() != null) {
|
||||
zHeight += 1.0D;
|
||||
}
|
||||
if (habbo != null && habbo.getHabboInfo().getRiding() != null) {
|
||||
zHeight += 1.0D;
|
||||
}
|
||||
|
||||
HabboItem habboItem = room.getTopItemAt(this.getX(), this.getY());
|
||||
if (habboItem != null) {
|
||||
if (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.getX(), next.getY()))
|
||||
habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
}
|
||||
if (habboItem != null && (habboItem != item || !RoomLayout.pointInSquare(habboItem.getX(), habboItem.getY(), habboItem.getX() + habboItem.getBaseItem().getWidth() - 1, habboItem.getY() + habboItem.getBaseItem().getLength() - 1, next.getX(), next.getY())))
|
||||
habboItem.onWalkOff(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
|
||||
|
||||
this.tilesWalked++;
|
||||
|
||||
@ -327,7 +301,7 @@ public class RoomUnit {
|
||||
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
|
||||
if (item.canWalkOn(this, room, null)) {
|
||||
item.onWalkOn(this, room, new Object[]{this.getCurrentLocation(), next});
|
||||
} else if (item instanceof ConditionalGate) {
|
||||
} else if (item instanceof ConditionalGate conditionalGate) {
|
||||
this.setRotation(oldRotation);
|
||||
this.tilesWalked--;
|
||||
this.setGoalLocation(this.currentLocation);
|
||||
@ -335,7 +309,7 @@ public class RoomUnit {
|
||||
room.sendComposer(new UserUpdateComposer(this).compose());
|
||||
|
||||
if (habbo != null) {
|
||||
((ConditionalGate) item).onRejected(this, this.getRoom(), new Object[]{});
|
||||
conditionalGate.onRejected(this, this.getRoom(), new Object[]{});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -356,23 +330,19 @@ public class RoomUnit {
|
||||
this.setPreviousLocation(this.getCurrentLocation());
|
||||
|
||||
this.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + zHeight);
|
||||
if (habbo != null) {
|
||||
if (habbo.getHabboInfo().getRiding() != null) {
|
||||
RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit();
|
||||
if (habbo != null && habbo.getHabboInfo().getRiding() != null) {
|
||||
RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit();
|
||||
|
||||
if (ridingUnit != null) {
|
||||
ridingUnit.setPreviousLocationZ(this.getZ());
|
||||
this.setZ(zHeight - 1.0);
|
||||
ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]);
|
||||
ridingUnit.setPreviousLocation(this.getCurrentLocation());
|
||||
ridingUnit.setGoalLocation(this.getGoalLocation());
|
||||
ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0));
|
||||
room.sendComposer(new UserUpdateComposer(ridingUnit).compose());
|
||||
//ridingUnit.setZ(zHeight - 1.0);
|
||||
}
|
||||
if (ridingUnit != null) {
|
||||
ridingUnit.setPreviousLocationZ(this.getZ());
|
||||
this.setZ(zHeight - 1.0);
|
||||
ridingUnit.setRotation(RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), next.getX(), next.getY())]);
|
||||
ridingUnit.setPreviousLocation(this.getCurrentLocation());
|
||||
ridingUnit.setGoalLocation(this.getGoalLocation());
|
||||
ridingUnit.setStatus(RoomUnitStatus.MOVE, next.getX() + "," + next.getY() + "," + (zHeight - 1.0));
|
||||
room.sendComposer(new UserUpdateComposer(ridingUnit).compose());
|
||||
}
|
||||
}
|
||||
//room.sendComposer(new RoomUserStatusComposer(this).compose());
|
||||
|
||||
this.setZ(zHeight);
|
||||
this.setCurrentLocation(room.getLayout().getTile(next.getX(), next.getY()));
|
||||
@ -398,6 +368,34 @@ public class RoomUnit {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleRider(Room room) {
|
||||
Habbo rider = null;
|
||||
if (this.getRoomUnitType() == RoomUnitType.PET) {
|
||||
Pet pet = room.getPet(this);
|
||||
if (pet instanceof RideablePet rideablePet) {
|
||||
rider = rideablePet.getRider();
|
||||
}
|
||||
}
|
||||
|
||||
if (rider != null) {
|
||||
// copy things from rider
|
||||
if (this.status.containsKey(RoomUnitStatus.MOVE) && !rider.getRoomUnit().getStatus().containsKey(RoomUnitStatus.MOVE)) {
|
||||
this.status.remove(RoomUnitStatus.MOVE);
|
||||
}
|
||||
|
||||
if (rider.getRoomUnit().getCurrentLocation().getX() != this.getX() || rider.getRoomUnit().getCurrentLocation().getY() != this.getY()) {
|
||||
this.status.put(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentLocation().getX() + "," + rider.getRoomUnit().getCurrentLocation().getY() + "," + (rider.getRoomUnit().getCurrentLocation().getStackHeight()));
|
||||
this.setPreviousLocation(rider.getRoomUnit().getPreviousLocation());
|
||||
this.setPreviousLocationZ(rider.getRoomUnit().getPreviousLocation().getStackHeight());
|
||||
this.setCurrentLocation(rider.getRoomUnit().getCurrentLocation());
|
||||
this.setZ(rider.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
@ -460,7 +458,7 @@ public class RoomUnit {
|
||||
if (goalLocation != null) {
|
||||
this.setGoalLocation(goalLocation, false);
|
||||
}
|
||||
return this;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setGoalLocation(RoomTile goalLocation, boolean noReset) {
|
||||
@ -481,7 +479,7 @@ public class RoomUnit {
|
||||
this.findPath(); ///< Quadral: this is where we start formulating a path
|
||||
if (!this.path.isEmpty()) {
|
||||
this.tilesWalked = isWalking ? this.tilesWalked : 0;
|
||||
this.cmdSit = false;
|
||||
this.setCmdSit(false);
|
||||
} else {
|
||||
this.goalLocation = this.currentLocation;
|
||||
}
|
||||
@ -510,8 +508,8 @@ public class RoomUnit {
|
||||
|
||||
public void findPath() {
|
||||
if (this.room != null && this.room.getLayout() != null && this.goalLocation != null && (this.goalLocation.isWalkable() || this.room.canSitOrLayAt(this.goalLocation.getX(), this.goalLocation.getY()) || this.canOverrideTile(this.goalLocation))) {
|
||||
Deque<RoomTile> path = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
||||
if (path != null) this.path = path;
|
||||
Deque<RoomTile> newPath = this.room.getLayout().findPath(this.currentLocation, this.goalLocation, this.goalLocation, this);
|
||||
if (newPath != null) this.path = newPath;
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,8 +525,9 @@ public class RoomUnit {
|
||||
return this.status.get(key);
|
||||
}
|
||||
|
||||
public void removeStatus(RoomUnitStatus key) {
|
||||
public RoomUnit removeStatus(RoomUnitStatus key) {
|
||||
this.status.remove(key);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setStatus(RoomUnitStatus key, String value) {
|
||||
@ -561,9 +560,10 @@ public class RoomUnit {
|
||||
return this.handItem;
|
||||
}
|
||||
|
||||
public void setHandItem(int handItem) {
|
||||
public RoomUnit setHandItem(int handItem) {
|
||||
this.handItem = handItem;
|
||||
this.handItemTimestamp = System.currentTimeMillis();
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getHandItemTimestamp() {
|
||||
@ -638,7 +638,7 @@ public class RoomUnit {
|
||||
}
|
||||
|
||||
public void lookAtPoint(RoomTile location) {
|
||||
if (!this.canRotate) return;
|
||||
if (!this.isCanRotate()) return;
|
||||
|
||||
if (Emulator.getPluginManager().isRegistered(RoomUnitLookAtPointEvent.class, false)) {
|
||||
Event lookAtPointEvent = new RoomUnitLookAtPointEvent(this.room, this, location);
|
||||
@ -727,10 +727,6 @@ public class RoomUnit {
|
||||
return canLeaveRoomByDoor;
|
||||
}
|
||||
|
||||
public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) {
|
||||
this.canLeaveRoomByDoor = canLeaveRoomByDoor;
|
||||
}
|
||||
|
||||
public boolean canForcePosture() {
|
||||
if (this.room == null) return false;
|
||||
|
||||
@ -765,17 +761,11 @@ public class RoomUnit {
|
||||
|
||||
return this.getClosestTile(
|
||||
rotations.stream()
|
||||
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
||||
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.getX(), t.getY())))
|
||||
.collect(Collectors.toList())
|
||||
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
|
||||
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t)
|
||||
|| !room.hasHabbosAt(t.getX(), t.getY())))
|
||||
.toList()
|
||||
);
|
||||
}
|
||||
|
||||
public ScheduledFuture getMoveBlockingTask() {
|
||||
return moveBlockingTask;
|
||||
}
|
||||
|
||||
public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) {
|
||||
this.moveBlockingTask = moveBlockingTask;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||
import gnu.trove.map.hash.TIntIntHashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.sql.*;
|
||||
@ -57,6 +58,7 @@ public class HabboInfo implements Runnable {
|
||||
@Setter
|
||||
private boolean online;
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
private int loadingRoom;
|
||||
@Setter
|
||||
private Room currentRoom;
|
||||
|
@ -239,10 +239,8 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
if (client != null && this.getBaseItem().getType() == FurnitureType.FLOOR) {
|
||||
if (objects != null && objects.length >= 2) {
|
||||
if (objects[1] instanceof WiredEffectType) {
|
||||
return;
|
||||
}
|
||||
if (objects != null && objects.length >= 2 && objects[1] instanceof WiredEffectType) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((this.getBaseItem().getStateCount() > 1 && !(this instanceof InteractionDice)) || Arrays.asList(HabboItem.TOGGLING_INTERACTIONS).contains(this.getClass()) || (objects != null && objects.length == 1 && objects[0].equals("TOGGLE_OVERRIDE"))) {
|
||||
@ -390,45 +388,46 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
|
||||
oldHabbos.removeAll(newHabbos);
|
||||
oldBots.removeAll(newBots);
|
||||
|
||||
for (Habbo habbo : oldHabbos) {
|
||||
int finalNextEffectM = nextEffectM;
|
||||
int finalNextEffectF = nextEffectF;
|
||||
|
||||
oldHabbos.forEach(habbo -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, nextEffectM, -1);
|
||||
room.giveEffect(habbo, finalNextEffectM, -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, nextEffectF, -1);
|
||||
room.giveEffect(habbo, finalNextEffectF, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Habbo habbo : newHabbos) {
|
||||
newHabbos.forEach(habbo -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.M) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && habbo.getHabboInfo().getGender().equals(HabboGender.F) && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Bot bot : oldBots) {
|
||||
|
||||
oldBots.forEach(bot -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(bot.getRoomUnit(), nextEffectM, -1);
|
||||
room.giveEffect(bot.getRoomUnit(), finalNextEffectM, -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() == this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(bot.getRoomUnit(), nextEffectF, -1);
|
||||
room.giveEffect(bot.getRoomUnit(), finalNextEffectF, -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (Bot bot : newBots) {
|
||||
newBots.forEach(bot -> {
|
||||
if (this.getBaseItem().getEffectM() > 0 && bot.getGender().equals(HabboGender.M) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM(), -1);
|
||||
}
|
||||
|
||||
if (this.getBaseItem().getEffectF() > 0 && bot.getGender().equals(HabboGender.F) && bot.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
|
||||
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF(), -1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import java.sql.SQLException;
|
||||
|
||||
@Slf4j
|
||||
public class HabboOfferPurchase {
|
||||
@Getter
|
||||
private final int userId;
|
||||
@Getter
|
||||
private final int offerId;
|
||||
|
@ -16,6 +16,8 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class EffectsComponent {
|
||||
@ -35,7 +37,7 @@ public class EffectsComponent {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
if(habbo.getHabboInfo().getRank().getRoomEffect() > 0)
|
||||
this.createRankEffect(habbo.getHabboInfo().getRank().getRoomEffect());
|
||||
@ -51,12 +53,12 @@ public class EffectsComponent {
|
||||
if (this.effects.containsKey(effectId)) {
|
||||
effect = this.effects.get(effectId);
|
||||
|
||||
if (effect.total <= 99) {
|
||||
effect.total++;
|
||||
if (effect.getTotal() <= 99) {
|
||||
effect.setTotal(effect.getTotal() + 1);
|
||||
}
|
||||
} else {
|
||||
effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId());
|
||||
effect.duration = duration;
|
||||
effect.setDuration(duration);
|
||||
effect.insert();
|
||||
}
|
||||
|
||||
@ -68,17 +70,17 @@ public class EffectsComponent {
|
||||
|
||||
public HabboEffect createRankEffect(int effectId) {
|
||||
HabboEffect rankEffect = new HabboEffect(effectId, habbo.getHabboInfo().getId());
|
||||
rankEffect.duration = 0;
|
||||
rankEffect.isRankEnable = true;
|
||||
rankEffect.activationTimestamp = Emulator.getIntUnixTimestamp();
|
||||
rankEffect.enabled = true;
|
||||
rankEffect.setDuration(0);
|
||||
rankEffect.setRankEnable(true);
|
||||
rankEffect.setActivationTimestamp(Emulator.getIntUnixTimestamp());
|
||||
rankEffect.setEnabled(true);
|
||||
this.effects.put(effectId, rankEffect);
|
||||
this.activatedEffect = effectId; // enabled by default
|
||||
return rankEffect;
|
||||
}
|
||||
|
||||
public void addEffect(HabboEffect effect) {
|
||||
this.effects.put(effect.effect, effect);
|
||||
this.effects.put(effect.getEffect(), effect);
|
||||
|
||||
this.habbo.getClient().sendResponse(new AvatarEffectAddedMessageComposer(effect));
|
||||
}
|
||||
@ -87,16 +89,16 @@ public class EffectsComponent {
|
||||
synchronized (this.effects) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET duration = ?, activation_timestamp = ?, total = ? WHERE user_id = ? AND effect = ?")) {
|
||||
this.effects.forEachValue(effect -> {
|
||||
if(!effect.isRankEnable) {
|
||||
if(!effect.isRankEnable()) {
|
||||
try {
|
||||
statement.setInt(1, effect.duration);
|
||||
statement.setInt(2, effect.activationTimestamp);
|
||||
statement.setInt(3, effect.total);
|
||||
statement.setInt(4, effect.userId);
|
||||
statement.setInt(5, effect.effect);
|
||||
statement.setInt(1, effect.getDuration());
|
||||
statement.setInt(2, effect.getActivationTimestamp());
|
||||
statement.setInt(3, effect.getTotal());
|
||||
statement.setInt(4, effect.getUserId());
|
||||
statement.setInt(5, effect.getEffect());
|
||||
statement.addBatch();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -104,7 +106,7 @@ public class EffectsComponent {
|
||||
|
||||
statement.executeBatch();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
this.effects.clear();
|
||||
@ -120,7 +122,7 @@ public class EffectsComponent {
|
||||
|
||||
if (effect != null) {
|
||||
if (effect.isRemaining()) {
|
||||
effect.activationTimestamp = Emulator.getIntUnixTimestamp();
|
||||
effect.setActivationTimestamp(Emulator.getIntUnixTimestamp());
|
||||
} else {
|
||||
this.habbo.getClient().sendResponse(new AvatarEffectExpiredMessageComposer(effect));
|
||||
}
|
||||
@ -132,7 +134,7 @@ public class EffectsComponent {
|
||||
|
||||
if (effect != null) {
|
||||
if (!effect.isActivated()) {
|
||||
this.activateEffect(effect.effect);
|
||||
this.activateEffect(effect.getEffect());
|
||||
}
|
||||
|
||||
this.activatedEffect = effectId;
|
||||
@ -155,75 +157,75 @@ public class EffectsComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class HabboEffect {
|
||||
public int effect;
|
||||
public int userId;
|
||||
public int duration = 86400;
|
||||
public int activationTimestamp = -1;
|
||||
public int total = 1;
|
||||
public boolean enabled = false;
|
||||
public boolean isRankEnable = false;
|
||||
private int effect;
|
||||
private int userId;
|
||||
private int duration = 86400;
|
||||
private int activationTimestamp = -1;
|
||||
private int total = 1;
|
||||
private boolean enabled = false;
|
||||
private boolean isRankEnable = false;
|
||||
|
||||
public HabboEffect(ResultSet set) throws SQLException {
|
||||
this.effect = set.getInt("effect");
|
||||
this.userId = set.getInt(DatabaseConstants.USER_ID);
|
||||
this.duration = set.getInt("duration");
|
||||
this.activationTimestamp = set.getInt("activation_timestamp");
|
||||
this.total = set.getInt("total");
|
||||
this.setEffect(set.getInt("effect"));
|
||||
this.setUserId(set.getInt(DatabaseConstants.USER_ID));
|
||||
this.setDuration(set.getInt("duration"));
|
||||
this.setActivationTimestamp(set.getInt("activation_timestamp"));
|
||||
this.setTotal(set.getInt("total"));
|
||||
}
|
||||
|
||||
public HabboEffect(int effect, int userId) {
|
||||
this.effect = effect;
|
||||
this.userId = userId;
|
||||
this.setEffect(effect);
|
||||
this.setUserId(userId);
|
||||
}
|
||||
|
||||
public boolean isActivated() {
|
||||
return this.activationTimestamp >= 0;
|
||||
return this.getActivationTimestamp() >= 0;
|
||||
}
|
||||
|
||||
public boolean isRemaining() {
|
||||
if(this.duration <= 0)
|
||||
if(this.getDuration() <= 0)
|
||||
return true;
|
||||
|
||||
if (this.total > 0) {
|
||||
if (this.activationTimestamp >= 0) {
|
||||
if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) {
|
||||
this.activationTimestamp = -1;
|
||||
this.total--;
|
||||
}
|
||||
}
|
||||
if (this.getTotal() > 0 && this.getActivationTimestamp() >= 0
|
||||
&& Emulator.getIntUnixTimestamp() - this.getActivationTimestamp() >= this.getDuration()) {
|
||||
this.setActivationTimestamp(-1);
|
||||
this.setTotal(this.getTotal() - 1);
|
||||
}
|
||||
|
||||
return this.total > 0;
|
||||
return this.getTotal() > 0;
|
||||
}
|
||||
|
||||
public int remainingTime() {
|
||||
if(this.duration <= 0) //permanant
|
||||
if(this.getDuration() <= 0) //permanant
|
||||
return Integer.MAX_VALUE;
|
||||
|
||||
return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration;
|
||||
return Emulator.getIntUnixTimestamp() - this.getActivationTimestamp() + this.getDuration();
|
||||
}
|
||||
|
||||
public void insert() {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_effects (user_id, effect, total, duration) VALUES (?, ?, ?, ?)")) {
|
||||
statement.setInt(1, this.userId);
|
||||
statement.setInt(2, this.effect);
|
||||
statement.setInt(3, this.total);
|
||||
statement.setInt(4, this.duration);
|
||||
statement.setInt(1, this.getUserId());
|
||||
statement.setInt(2, this.getEffect());
|
||||
statement.setInt(3, this.getTotal());
|
||||
statement.setInt(4, this.getDuration());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_effects WHERE user_id = ? AND effect = ?")) {
|
||||
statement.setInt(1, this.userId);
|
||||
statement.setInt(2, this.effect);
|
||||
statement.setInt(1, this.getUserId());
|
||||
statement.setInt(2, this.getEffect());
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class PetsComponent {
|
||||
} catch (NoSuchElementException e) {
|
||||
break;
|
||||
}
|
||||
if (petIterator.value().needsUpdate)
|
||||
if (petIterator.value().isNeedsUpdate())
|
||||
Emulator.getThreading().run(petIterator.value());
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo));
|
||||
}, (Emulator.getIntUnixTimestamp() - habbo.getHabboStats().getHcMessageLastModified()));
|
||||
} else {
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, Subscription.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo));
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
if (amount < 0) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
|
||||
if (habbo != null && habbo.getClient() != null) {
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, Subscription.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo));
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.getUserId());
|
||||
|
||||
if (habbo != null && habbo.getClient() != null) {
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, Subscription.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo));
|
||||
}
|
||||
}
|
||||
@ -170,7 +170,7 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
}
|
||||
|
||||
if (habbo != null && habbo.getClient() != null) {
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, SubscriptionHabboClub.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new ScrSendUserInfoComposer(habbo, Subscription.HABBO_CLUB, ScrSendUserInfoComposer.RESPONSE_TYPE_NORMAL));
|
||||
habbo.getClient().sendResponse(new UserRightsMessageComposer(habbo));
|
||||
}
|
||||
}
|
||||
@ -329,16 +329,16 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
while (set.next()) {
|
||||
try {
|
||||
int logId = set.getInt("id");
|
||||
int userId = set.getInt(DatabaseConstants.USER_ID);
|
||||
int totalPayout = set.getInt("total_payout");
|
||||
String currency = set.getString("currency");
|
||||
|
||||
if (claimPayDay(habbo, totalPayout, currency)) {
|
||||
try (PreparedStatement stm2 = connection.prepareStatement("UPDATE logs_hc_payday SET claimed = 1 WHERE id = ?")) {
|
||||
stm2.setInt(1, logId);
|
||||
stm2.execute();
|
||||
}
|
||||
claimPayDay(habbo, totalPayout, currency);
|
||||
|
||||
try (PreparedStatement stm2 = connection.prepareStatement("UPDATE logs_hc_payday SET claimed = 1 WHERE id = ?")) {
|
||||
stm2.setInt(1, logId);
|
||||
stm2.execute();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Exception processing HC payday for user #" + set.getInt(DatabaseConstants.USER_ID), e);
|
||||
}
|
||||
@ -351,7 +351,6 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Seperated these because Beny shouldn't have tied them to Payday.
|
||||
*/
|
||||
public static void processClubBadge(Habbo habbo) {
|
||||
@ -360,13 +359,14 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
|
||||
/**
|
||||
* Issues rewards to user.
|
||||
* @param habbo User to reward to
|
||||
* @param amount Amount of currency to reward
|
||||
*
|
||||
* @param habbo User to reward to
|
||||
* @param amount Amount of currency to reward
|
||||
* @param currency Currency string (Can be one of: credits, diamonds, duckets, pixels or a currency ID e.g. 5)
|
||||
* @return Boolean indicating success of the operation
|
||||
*/
|
||||
public static boolean claimPayDay(Habbo habbo, int amount, String currency) {
|
||||
if(habbo == null)
|
||||
if (habbo == null)
|
||||
return false;
|
||||
|
||||
int pointCurrency;
|
||||
@ -410,16 +410,16 @@ public class SubscriptionHabboClub extends Subscription {
|
||||
private static void progressAchievement(HabboInfo habboInfo) {
|
||||
HabboStats stats = habboInfo.getHabboStats();
|
||||
Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement(ACHIEVEMENT_NAME);
|
||||
if(achievement != null) {
|
||||
if (achievement != null) {
|
||||
int currentProgress = stats.getAchievementProgress(achievement);
|
||||
if(currentProgress == -1) {
|
||||
if (currentProgress == -1) {
|
||||
currentProgress = 0;
|
||||
}
|
||||
|
||||
int progressToSet = (int)Math.ceil(stats.getPastTimeAsClub() / 2678400.0);
|
||||
int progressToSet = (int) Math.ceil(stats.getPastTimeAsClub() / 2678400.0);
|
||||
int toIncrease = Math.max(progressToSet - currentProgress, 0);
|
||||
|
||||
if(toIncrease > 0) {
|
||||
if (toIncrease > 0) {
|
||||
AchievementManager.progressAchievement(habboInfo.getId(), achievement, toIncrease);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.eu.habbo.plugin.events.navigator.NavigatorSearchResultEvent;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RoomTextSearchEvent extends MessageHandler {
|
||||
public final static THashMap<Rank, THashMap<String, ServerMessage>> cachedResults = new THashMap<>(4);
|
||||
@ -20,7 +21,7 @@ public class RoomTextSearchEvent extends MessageHandler {
|
||||
|
||||
String prefix = "";
|
||||
String query = name;
|
||||
ArrayList<Room> rooms;
|
||||
List<Room> rooms;
|
||||
|
||||
ServerMessage message = null;
|
||||
if (cachedResults.containsKey(this.client.getHabbo().getHabboInfo().getRank())) {
|
||||
@ -33,7 +34,7 @@ public class RoomTextSearchEvent extends MessageHandler {
|
||||
if (name.startsWith("owner:")) {
|
||||
query = name.split("owner:")[1];
|
||||
prefix = "owner:";
|
||||
rooms = (ArrayList<Room>) Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(name);
|
||||
rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(name);
|
||||
} else if (name.startsWith("tag:")) {
|
||||
query = name.split("tag:")[1];
|
||||
prefix = "tag:";
|
||||
|
@ -22,8 +22,8 @@ public class OpenFlatConnectionEvent extends MessageHandler {
|
||||
this.client.getHabbo().getHabboInfo().setCurrentRoom(null);
|
||||
}
|
||||
|
||||
if (this.client.getHabbo().getRoomUnit() != null && this.client.getHabbo().getRoomUnit().isTeleporting) {
|
||||
this.client.getHabbo().getRoomUnit().isTeleporting = false;
|
||||
if (this.client.getHabbo().getRoomUnit() != null && this.client.getHabbo().getRoomUnit().isTeleporting()) {
|
||||
this.client.getHabbo().getRoomUnit().setTeleporting(false);
|
||||
}
|
||||
|
||||
Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), roomId, password);
|
||||
|
@ -17,7 +17,7 @@ public class EnterOneWayDoorEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
if (item instanceof InteractionOneWayGate) {
|
||||
if (!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting)
|
||||
if (!item.getExtradata().equals("0") || this.client.getHabbo().getRoomUnit().isTeleporting())
|
||||
return;
|
||||
|
||||
item.onClick(this.client, this.client.getHabbo().getHabboInfo().getCurrentRoom(), null);
|
||||
|
@ -16,9 +16,12 @@ import com.eu.habbo.plugin.events.furniture.FurnitureToggleEvent;
|
||||
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class UseFurnitureEvent extends MessageHandler {
|
||||
|
||||
private static final List<String> PET_PRESENTS = List.of("val11_present", "gnome_box", "leprechaun_box", "velociraptor_egg", "pterosaur_egg", "petbox_epic");
|
||||
|
||||
@Override
|
||||
public void handle() {
|
||||
@ -42,86 +45,11 @@ public class UseFurnitureEvent extends MessageHandler {
|
||||
if (furnitureToggleEvent.isCancelled())
|
||||
return;
|
||||
|
||||
/*
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
|
||||
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
HabboItem totemLeg = null;
|
||||
HabboItem totemHead = null;
|
||||
|
||||
for (HabboItem totemItem : items) {
|
||||
if (totemLeg != null && totemHead != null) {
|
||||
break;
|
||||
}
|
||||
if (totemItem.getBaseItem().getName().equalsIgnoreCase("totem_leg")) {
|
||||
totemLeg = totemItem;
|
||||
}
|
||||
if (totemItem.getBaseItem().getName().equalsIgnoreCase("totem_head")) {
|
||||
totemHead = totemItem;
|
||||
}
|
||||
}
|
||||
|
||||
if (totemHead != null && totemLeg != null) {
|
||||
if (item.getExtradata().equals("2")) {
|
||||
if (totemLeg.getExtradata() == null || totemHead.getExtradata() == null)
|
||||
return;
|
||||
|
||||
if (totemLeg.getExtradata().equals("2") && totemHead.getExtradata().equals("5")) {
|
||||
room.giveEffect(this.client.getHabbo(), 23, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (totemLeg.getExtradata().equals("10") && totemHead.getExtradata().equals("9")) {
|
||||
room.giveEffect(this.client.getHabbo(), 26, -1);
|
||||
return;
|
||||
}
|
||||
} else if (item.getExtradata().equals("0")) {
|
||||
if (totemLeg.getExtradata().equals("7") && totemHead.getExtradata().equals("10")) {
|
||||
room.giveEffect(this.client.getHabbo(), 24, -1);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (item.getExtradata().equals("1")) {
|
||||
if (totemLeg.getExtradata().equals("9") && totemHead.getExtradata().equals("12")) {
|
||||
room.giveEffect(this.client.getHabbo(), 25, -1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
//Do not move to onClick(). Wired could trigger it.
|
||||
if (item instanceof InteractionMonsterPlantSeed) {
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
int rarity = 0;
|
||||
if (handleMonsterPlantSeed(room, item)) return;
|
||||
|
||||
boolean isRare = item.getBaseItem().getName().contains("rare");
|
||||
|
||||
if (item.getExtradata().isEmpty() || Integer.parseInt(item.getExtradata()) - 1 < 0) {
|
||||
rarity = isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
rarity = Integer.parseInt(item.getExtradata()) - 1;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity);
|
||||
room.sendComposer(new RemoveFloorItemComposer(item, true).compose());
|
||||
room.removeHabboItem(item);
|
||||
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
room.placePet(pet, item.getX(), item.getY(), item.getZ());
|
||||
pet.cycle();
|
||||
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(item.getBaseItem().getName().equalsIgnoreCase("val11_present") ||
|
||||
item.getBaseItem().getName().equalsIgnoreCase("gnome_box") ||
|
||||
item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box") ||
|
||||
item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg") ||
|
||||
item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg") ||
|
||||
item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) {
|
||||
if (PET_PRESENTS.contains(item.getBaseItem().getName().toLowerCase()) && room.getCurrentPets().size() < Room.MAXIMUM_PETS) {
|
||||
this.client.sendResponse(new OpenPetPackageRequestedMessageComposer(item));
|
||||
return;
|
||||
}
|
||||
@ -135,4 +63,35 @@ public class UseFurnitureEvent extends MessageHandler {
|
||||
log.error("Caught exception", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleMonsterPlantSeed(Room room, HabboItem item) {
|
||||
if (item instanceof InteractionMonsterPlantSeed) {
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
|
||||
boolean isRare = item.getBaseItem().getName().contains("rare");
|
||||
int rarity = getRarity(item, isRare);
|
||||
|
||||
MonsterplantPet pet = Emulator.getGameEnvironment().getPetManager().createMonsterplant(room, this.client.getHabbo(), isRare, room.getLayout().getTile(item.getX(), item.getY()), rarity);
|
||||
room.sendComposer(new RemoveFloorItemComposer(item, true).compose());
|
||||
room.removeHabboItem(item);
|
||||
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
room.placePet(pet, item.getX(), item.getY(), item.getZ());
|
||||
pet.cycle();
|
||||
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int getRarity(HabboItem item, boolean isRare) {
|
||||
if (item.getExtradata().isEmpty() || Integer.parseInt(item.getExtradata()) - 1 < 0) {
|
||||
return isRare ? InteractionMonsterPlantSeed.randomGoldenRarityLevel() : InteractionMonsterPlantSeed.randomRarityLevel();
|
||||
} else {
|
||||
try {
|
||||
return Integer.parseInt(item.getExtradata()) - 1;
|
||||
} catch (Exception ignored) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
raceType = 0;
|
||||
|
||||
pet.setRace(raceType);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairdye")) {
|
||||
int splittedHairdye = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]);
|
||||
int newHairdye = 48;
|
||||
@ -60,7 +60,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
((HorsePet) pet).setHairColor(newHairdye);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_hairstyle")) {
|
||||
int splittedHairstyle = Integer.parseInt(item.getBaseItem().getName().toLowerCase().split("_")[2]);
|
||||
int newHairstyle = 100;
|
||||
@ -72,14 +72,14 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
((HorsePet) pet).setHairStyle(newHairstyle);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) {
|
||||
((HorsePet) pet).hasSaddle(true);
|
||||
((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId());
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
}
|
||||
|
||||
if (pet.needsUpdate) {
|
||||
if (pet.isNeedsUpdate()) {
|
||||
Emulator.getThreading().run(pet);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose());
|
||||
|
||||
@ -91,10 +91,10 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
} else if (pet instanceof MonsterplantPet) {
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_revival")) {
|
||||
if (((MonsterplantPet) pet).isDead()) {
|
||||
((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
||||
((MonsterplantPet) pet).setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.TIME_TO_LIVE);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "rev");
|
||||
pet.packetUpdate = true;
|
||||
pet.setPacketUpdate(true);
|
||||
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item).compose());
|
||||
@ -107,7 +107,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
}
|
||||
} else if (item.getBaseItem().getName().equalsIgnoreCase("mnstr_fert")) {
|
||||
if (!((MonsterplantPet) pet).isFullyGrown()) {
|
||||
pet.setCreated(pet.getCreated() - MonsterplantPet.growTime);
|
||||
pet.setCreated(pet.getCreated() - MonsterplantPet.GROW_TIME);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.cycle();
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.GESTURE, "spd");
|
||||
|
@ -28,7 +28,7 @@ public class MovePetEvent extends MessageHandler {
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.packet.readInt()));
|
||||
pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getZ());
|
||||
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,55 +22,53 @@ public class OpenPetPackageEvent extends MessageHandler {
|
||||
|
||||
if (room != null) {
|
||||
HabboItem item = room.getHabboItem(itemId);
|
||||
if (item != null) {
|
||||
if (item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) {
|
||||
if (name.matches("^[a-zA-Z0-9]*$")) {
|
||||
Pet pet = null;
|
||||
if (item != null && item.getUserId() == this.client.getHabbo().getHabboInfo().getId()) {
|
||||
if (!name.matches("^[a-zA-Z0-9]*$")) {
|
||||
this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", "")));
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("val11_present")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(11, name, this.client);
|
||||
}
|
||||
Pet pet = null;
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("gnome_box")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createGnome(name, room, this.client.getHabbo());
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("val11_present")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(11, name, this.client);
|
||||
}
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createLeprechaun(name, room, this.client.getHabbo());
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("gnome_box")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createGnome(name, room, this.client.getHabbo());
|
||||
}
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(34, name, this.client);
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("leprechaun_box")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createLeprechaun(name, room, this.client.getHabbo());
|
||||
}
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(33, name, this.client);
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("velociraptor_egg")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(34, name, this.client);
|
||||
}
|
||||
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(32, name, this.client);
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("pterosaur_egg")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(33, name, this.client);
|
||||
}
|
||||
|
||||
if (pet != null) {
|
||||
room.placePet(pet, item.getX(), item.getY(), item.getZ());
|
||||
pet.setUserId(this.client.getHabbo().getHabboInfo().getId());
|
||||
pet.needsUpdate = true;
|
||||
pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
pet.getRoomUnit().setZ(item.getZ());
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
room.removeHabboItem(item);
|
||||
room.sendComposer(new RemoveFloorItemComposer(item).compose());
|
||||
RoomTile tile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
room.sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose());
|
||||
item.setUserId(0);
|
||||
} else {
|
||||
this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR));
|
||||
}
|
||||
} else {
|
||||
this.client.sendResponse(new PerkAllowancesComposer(itemId, PerkAllowancesComposer.CONTAINS_INVALID_CHARS, name.replaceAll("^[a-zA-Z0-9]*$", "")));
|
||||
return;
|
||||
}
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("petbox_epic")) {
|
||||
pet = Emulator.getGameEnvironment().getPetManager().createPet(32, name, this.client);
|
||||
}
|
||||
|
||||
if (pet != null) {
|
||||
room.placePet(pet, item.getX(), item.getY(), item.getZ());
|
||||
pet.setUserId(this.client.getHabbo().getHabboInfo().getId());
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
pet.getRoomUnit().setZ(item.getZ());
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
room.removeHabboItem(item);
|
||||
room.sendComposer(new RemoveFloorItemComposer(item).compose());
|
||||
RoomTile tile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
|
||||
room.sendComposer(new HeightMapUpdateMessageComposer(tile.getX(), tile.getY(), tile.getZ(), tile.relativeHeight()).compose());
|
||||
item.setUserId(0);
|
||||
} else {
|
||||
this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class PlacePetEvent extends MessageHandler {
|
||||
}
|
||||
pet.setRoomUnit(roomUnit);
|
||||
room.addPet(pet);
|
||||
pet.needsUpdate = true;
|
||||
pet.setNeedsUpdate(true);
|
||||
Emulator.getThreading().run(pet);
|
||||
room.sendComposer(new RoomPetComposer(pet).compose());
|
||||
this.client.getHabbo().getInventory().getPetsComponent().removePet(pet);
|
||||
|
@ -52,7 +52,7 @@ public class RemoveSaddleFromPetEvent extends MessageHandler {
|
||||
if (saddleItem == null) return;
|
||||
|
||||
horse.hasSaddle(false);
|
||||
horse.needsUpdate = true;
|
||||
horse.setNeedsUpdate(true);
|
||||
Emulator.getThreading().run(pet);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetFigureUpdateComposer(horse).compose());
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
rideablePet.setAnyoneCanRide(!rideablePet.anyoneCanRide());
|
||||
rideablePet.needsUpdate = true;
|
||||
rideablePet.setNeedsUpdate(true);
|
||||
|
||||
if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) {
|
||||
rideablePet.getRider().getHabboInfo().dismountPet();
|
||||
|
@ -34,7 +34,7 @@ public class LookToEvent extends MessageHandler {
|
||||
if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE))
|
||||
return;
|
||||
|
||||
if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY))
|
||||
if (roomUnit.isCmdLay() || roomUnit.hasStatus(RoomUnitStatus.LAY))
|
||||
return;
|
||||
|
||||
if (roomUnit.isIdle())
|
||||
|
@ -36,11 +36,11 @@ public class MoveAvatarEvent extends MessageHandler {
|
||||
RoomUnit roomUnit = this.client.getHabbo().getRoomUnit();
|
||||
|
||||
// If habbo is teleporting, dont calculate a new path
|
||||
if (roomUnit.isTeleporting)
|
||||
if (roomUnit.isTeleporting())
|
||||
return;
|
||||
|
||||
// If habbo is being kicked dont calculate a new path
|
||||
if (roomUnit.isKicked)
|
||||
if (roomUnit.isKicked())
|
||||
return;
|
||||
|
||||
// If habbo has control (im assuming admin, do something else, but we dont care about this part here)
|
||||
@ -60,101 +60,94 @@ public class MoveAvatarEvent extends MessageHandler {
|
||||
// Get the room the habbo is in
|
||||
Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||
|
||||
try {
|
||||
// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
|
||||
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
|
||||
// If we are not teleporting calcualte a new path
|
||||
if (!roomUnit.cmdTeleport) {
|
||||
// Don't calculate a new path if we are on a horse
|
||||
if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP))
|
||||
return;
|
||||
// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
|
||||
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
|
||||
// If we are not teleporting calcualte a new path
|
||||
if (!roomUnit.isCmdTeleport()) {
|
||||
// Don't calculate a new path if we are on a horse
|
||||
if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP))
|
||||
return;
|
||||
|
||||
// Don't calulcate a new path if are already at the end position
|
||||
if (x == roomUnit.getX() && y == roomUnit.getY())
|
||||
return;
|
||||
// Don't calulcate a new path if are already at the end position
|
||||
if (x == roomUnit.getX() && y == roomUnit.getY())
|
||||
return;
|
||||
|
||||
if (room == null || room.getLayout() == null)
|
||||
return;
|
||||
if (room == null || room.getLayout() == null)
|
||||
return;
|
||||
|
||||
// Reset idle status
|
||||
if (roomUnit.isIdle()) {
|
||||
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
// Reset idle status
|
||||
if (roomUnit.isIdle()) {
|
||||
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
|
||||
Emulator.getPluginManager().fireEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (!event.isIdle()) {
|
||||
if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo);
|
||||
roomUnit.resetIdleTimer();
|
||||
}
|
||||
if (!event.isCancelled()) {
|
||||
if (!event.isIdle()) {
|
||||
if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo);
|
||||
roomUnit.resetIdleTimer();
|
||||
}
|
||||
}
|
||||
|
||||
// Get room height map
|
||||
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
||||
|
||||
// this should never happen, if it does it would be a design flaw
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't care
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
|
||||
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
|
||||
return;
|
||||
}
|
||||
if (room.canLayAt(tile.getX(), tile.getY())) {
|
||||
HabboItem bed = room.getTopItemAt(tile.getX(), tile.getY());
|
||||
|
||||
if (bed != null && bed.getBaseItem().allowLay()) {
|
||||
room.getLayout().getTile(bed.getX(), bed.getY());
|
||||
RoomTile pillow = switch (bed.getRotation()) {
|
||||
case 0, 4 -> room.getLayout().getTile((short) x, bed.getY());
|
||||
case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y);
|
||||
default -> room.getLayout().getTile(bed.getX(), bed.getY());
|
||||
};
|
||||
|
||||
if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) {
|
||||
roomUnit.setGoalLocation(pillow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
THashSet<HabboItem> items = room.getItemsAt(tile);
|
||||
|
||||
if (items.size() > 0) {
|
||||
for (HabboItem item : items) {
|
||||
RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile);
|
||||
|
||||
if (overriddenTile == null) {
|
||||
return; // null cancels the entire event
|
||||
}
|
||||
|
||||
if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) {
|
||||
tile = overriddenTile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is where we set the end location and begin finding a path
|
||||
if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) {
|
||||
if (roomUnit.getMoveBlockingTask() != null) roomUnit.getMoveBlockingTask().get();
|
||||
|
||||
roomUnit.setGoalLocation(tile);
|
||||
}
|
||||
} else {
|
||||
RoomTile t = room.getLayout().getTile((short) x, (short) y);
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose());
|
||||
|
||||
if (habbo.getHabboInfo().getRiding() != null) {
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
|
||||
}
|
||||
}
|
||||
|
||||
// Get room height map
|
||||
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
|
||||
|
||||
// this should never happen, if it does it would be a design flaw
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't care
|
||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
|
||||
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
|
||||
return;
|
||||
}
|
||||
if (room.canLayAt(tile.getX(), tile.getY())) {
|
||||
HabboItem bed = room.getTopItemAt(tile.getX(), tile.getY());
|
||||
|
||||
if (bed != null && bed.getBaseItem().allowLay()) {
|
||||
room.getLayout().getTile(bed.getX(), bed.getY());
|
||||
RoomTile pillow = switch (bed.getRotation()) {
|
||||
case 0, 4 -> room.getLayout().getTile((short) x, bed.getY());
|
||||
case 2, 8 -> room.getLayout().getTile(bed.getX(), (short) y);
|
||||
default -> room.getLayout().getTile(bed.getX(), bed.getY());
|
||||
};
|
||||
|
||||
if (pillow != null && room.canLayAt(pillow.getX(), pillow.getY())) {
|
||||
roomUnit.setGoalLocation(pillow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
THashSet<HabboItem> items = room.getItemsAt(tile);
|
||||
|
||||
if (items.size() > 0) {
|
||||
for (HabboItem item : items) {
|
||||
RoomTile overriddenTile = item.getOverrideGoalTile(roomUnit, room, tile);
|
||||
|
||||
if (overriddenTile == null) {
|
||||
return; // null cancels the entire event
|
||||
}
|
||||
|
||||
if (!overriddenTile.equals(tile) && overriddenTile.isWalkable()) {
|
||||
tile = overriddenTile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is where we set the end location and begin finding a path
|
||||
if (tile.isWalkable() || room.canSitOrLayAt(tile.getX(), tile.getY())) {
|
||||
roomUnit.setGoalLocation(tile);
|
||||
}
|
||||
} else {
|
||||
RoomTile t = room.getLayout().getTile((short) x, (short) y);
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose());
|
||||
|
||||
if (habbo.getHabboInfo().getRiding() != null) {
|
||||
room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Caught exception", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ public class AvatarEffectActivatedMessageComposer extends MessageComposer {
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.avatarEffectActivatedMessageComposer);
|
||||
this.response.appendInt(this.effect.effect); //Type
|
||||
this.response.appendInt(this.effect.duration); //Duration
|
||||
this.response.appendBoolean(this.effect.enabled); //activated
|
||||
this.response.appendInt(this.effect.getEffect()); //Type
|
||||
this.response.appendInt(this.effect.getDuration()); //Duration
|
||||
this.response.appendBoolean(this.effect.isEnabled()); //activated
|
||||
return this.response;
|
||||
}
|
||||
}
|
@ -14,10 +14,10 @@ public class AvatarEffectAddedMessageComposer extends MessageComposer {
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.avatarEffectAddedMessageComposer);
|
||||
this.response.appendInt(this.effect.effect); //Type
|
||||
this.response.appendInt(this.effect.getEffect()); //Type
|
||||
this.response.appendInt(0); //Unknown Costume?
|
||||
this.response.appendInt(effect.duration > 0 ? effect.duration : Integer.MAX_VALUE); //Duration
|
||||
this.response.appendBoolean(effect.duration <= 0); //Is active
|
||||
this.response.appendInt(effect.getDuration() > 0 ? effect.getDuration() : Integer.MAX_VALUE); //Duration
|
||||
this.response.appendBoolean(effect.getDuration() <= 0); //Is active
|
||||
return this.response;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class AvatarEffectExpiredMessageComposer extends MessageComposer {
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.avatarEffectExpiredMessageComposer);
|
||||
this.response.appendInt(this.effect.effect);
|
||||
this.response.appendInt(this.effect.getEffect());
|
||||
return this.response;
|
||||
}
|
||||
}
|
@ -30,18 +30,18 @@ public class AvatarEffectsMessageComposer extends MessageComposer {
|
||||
this.response.appendInt(this.effects.size());
|
||||
|
||||
for (EffectsComponent.HabboEffect effect : effects) {
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.effect);
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.getEffect());
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(0);
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : Integer.MAX_VALUE);
|
||||
AvatarEffectsMessageComposer.this.response.appendInt((effect.duration > 0 ? (effect.total - (effect.isActivated() ? 1 : 0)) : 0));
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.getDuration() > 0 ? effect.getDuration() : Integer.MAX_VALUE);
|
||||
AvatarEffectsMessageComposer.this.response.appendInt((effect.getDuration() > 0 ? (effect.getTotal() - (effect.isActivated() ? 1 : 0)) : 0));
|
||||
|
||||
if(!effect.isActivated() && effect.duration > 0) {
|
||||
if(!effect.isActivated() && effect.getDuration() > 0) {
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(0);
|
||||
}
|
||||
else {
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.duration > 0 ? (Emulator.getIntUnixTimestamp() - effect.activationTimestamp) + effect.duration : 0);
|
||||
AvatarEffectsMessageComposer.this.response.appendInt(effect.getDuration() > 0 ? (Emulator.getIntUnixTimestamp() - effect.getActivationTimestamp()) + effect.getDuration() : 0);
|
||||
}
|
||||
AvatarEffectsMessageComposer.this.response.appendBoolean(effect.duration <= 0); // is perm
|
||||
AvatarEffectsMessageComposer.this.response.appendBoolean(effect.getDuration() <= 0); // is perm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class ModeratorUserInfoComposer extends MessageComposer {
|
||||
@ -30,19 +32,7 @@ public class ModeratorUserInfoComposer extends MessageComposer {
|
||||
try {
|
||||
int totalBans = 0;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) AS amount FROM bans WHERE user_id = ?")) {
|
||||
statement.setInt(1, this.set.getInt(DatabaseConstants.USER_ID));
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
if (set.next()) {
|
||||
totalBans = set.getInt("amount");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
}
|
||||
totalBans = getTotalBansFromDB(totalBans);
|
||||
|
||||
this.response.appendInt(this.set.getInt(DatabaseConstants.USER_ID));
|
||||
this.response.appendString(this.set.getString("username"));
|
||||
@ -68,7 +58,7 @@ public class ModeratorUserInfoComposer extends MessageComposer {
|
||||
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(this.set.getInt(DatabaseConstants.USER_ID));
|
||||
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(this.set.getInt(DatabaseConstants.USER_ID));
|
||||
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) //has sanction
|
||||
if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) //has sanction
|
||||
{
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.getSanctionLevel());
|
||||
@ -81,8 +71,26 @@ public class ModeratorUserInfoComposer extends MessageComposer {
|
||||
|
||||
return this.response;
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int getTotalBansFromDB() {
|
||||
int totalBans = 0;
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) AS amount FROM bans WHERE user_id = ?")) {
|
||||
statement.setInt(1, this.set.getInt(DatabaseConstants.USER_ID));
|
||||
try (ResultSet resultSet = statement.executeQuery()) {
|
||||
if (resultSet.next()) {
|
||||
totalBans = resultSet.getInt("amount");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
return totalBans;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class PetInfoMessageComposer extends MessageComposer {
|
||||
this.response.appendBoolean(!(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isFullyGrown())); //unknown 1
|
||||
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isDead()); //Dead
|
||||
this.response.appendInt(this.pet instanceof MonsterplantPet ? ((MonsterplantPet) this.pet).getRarity() : 0);
|
||||
this.response.appendInt(MonsterplantPet.timeToLive); //Maximum wellbeing
|
||||
this.response.appendInt(MonsterplantPet.TIME_TO_LIVE); //Maximum wellbeing
|
||||
this.response.appendInt(this.pet instanceof MonsterplantPet ? ((MonsterplantPet) this.pet).remainingTimeToLive() : 0); //Remaining Wellbeing
|
||||
this.response.appendInt(this.pet instanceof MonsterplantPet ? ((MonsterplantPet) this.pet).remainingGrowTime() : 0);
|
||||
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isPubliclyBreedable()); //Breedable checkbox
|
||||
|
@ -26,7 +26,7 @@ public class UserUpdateComposer extends MessageComposer {
|
||||
this.overrideZ = overrideZ;
|
||||
}
|
||||
|
||||
public UserUpdateComposer(THashSet<RoomUnit> roomUnits, boolean value) {
|
||||
public UserUpdateComposer(THashSet<RoomUnit> roomUnits) {
|
||||
this.roomUnits = roomUnits;
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,14 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.plugin.events.users.UserEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class NavigatorRoomsEvent extends UserEvent {
|
||||
|
||||
public final ArrayList<Room> rooms;
|
||||
public final List<Room> rooms;
|
||||
|
||||
|
||||
public NavigatorRoomsEvent(Habbo habbo, ArrayList<Room> rooms) {
|
||||
public NavigatorRoomsEvent(Habbo habbo, List<Room> rooms) {
|
||||
super(habbo);
|
||||
|
||||
this.rooms = rooms;
|
||||
|
@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class NavigatorSearchResultEvent extends NavigatorRoomsEvent {
|
||||
|
||||
@ -13,7 +14,7 @@ public class NavigatorSearchResultEvent extends NavigatorRoomsEvent {
|
||||
public final String query;
|
||||
|
||||
|
||||
public NavigatorSearchResultEvent(Habbo habbo, String prefix, String query, ArrayList<Room> rooms) {
|
||||
public NavigatorSearchResultEvent(Habbo habbo, String prefix, String query, List<Room> rooms) {
|
||||
super(habbo, rooms);
|
||||
|
||||
this.prefix = prefix;
|
||||
|
@ -21,8 +21,8 @@ public class OneWayGateActionOne implements Runnable {
|
||||
|
||||
RoomTile t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.oneWayGate.getX(), this.oneWayGate.getY()), (this.oneWayGate.getRotation() + 4) % 8);
|
||||
|
||||
if (this.client.getHabbo().getRoomUnit().animateWalk) {
|
||||
this.client.getHabbo().getRoomUnit().animateWalk = false;
|
||||
if (this.client.getHabbo().getRoomUnit().isAnimateWalk()) {
|
||||
this.client.getHabbo().getRoomUnit().setAnimateWalk(false);
|
||||
}
|
||||
|
||||
if (t.isWalkable()) {
|
||||
|
@ -28,8 +28,8 @@ public class RoomUnitTeleport implements Runnable {
|
||||
if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null)
|
||||
return;
|
||||
|
||||
if (roomUnit.isLeavingTeleporter) {
|
||||
roomUnit.isWiredTeleporting = false;
|
||||
if (roomUnit.isLeavingTeleporter()) {
|
||||
roomUnit.setWiredTeleporting(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class RoomUnitTeleport implements Runnable {
|
||||
this.roomUnit.setLocation(newLocation);
|
||||
//this.room.sendComposer(teleportMessage);
|
||||
this.roomUnit.statusUpdate(true);
|
||||
roomUnit.isWiredTeleporting = false;
|
||||
roomUnit.setWiredTeleporting(false);
|
||||
|
||||
this.room.updateHabbosAt(newLocation.getX(), newLocation.getY());
|
||||
this.room.updateBotsAt(newLocation.getX(), newLocation.getY());
|
||||
|
@ -19,27 +19,25 @@ public class RoomUnitTeleportWalkToAction implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.habbo.getHabboInfo().getCurrentRoom() == this.room) {
|
||||
if (this.habboItem.getRoomId() == this.room.getId()) {
|
||||
RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem);
|
||||
|
||||
if (tile != null) {
|
||||
if (this.habbo.getRoomUnit().getGoalLocation().equals(tile)) {
|
||||
if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) {
|
||||
try {
|
||||
this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0});
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
}
|
||||
} else {
|
||||
if (tile.isWalkable()) {
|
||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.habbo.getHabboInfo().getCurrentRoom() != this.room || this.habboItem.getRoomId() != this.room.getId()) {
|
||||
return;
|
||||
}
|
||||
RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem);
|
||||
|
||||
if (!this.habbo.getRoomUnit().getGoalLocation().equals(tile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) {
|
||||
try {
|
||||
this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0});
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
}
|
||||
} else if (tile.isWalkable()) {
|
||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -18,26 +18,29 @@ public class RoomUnitVendingMachineAction implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.habbo.getHabboInfo().getCurrentRoom() == this.room) {
|
||||
if (this.habboItem.getRoomId() == this.room.getId()) {
|
||||
RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem);
|
||||
if (tile != null) {
|
||||
if (this.habbo.getRoomUnit().getGoalLocation().equals(tile)) {
|
||||
if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) {
|
||||
try {
|
||||
this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0});
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
}
|
||||
} else {
|
||||
if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) {
|
||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.habbo.getHabboInfo().getCurrentRoom() != this.room || this.habboItem.getRoomId() != this.room.getId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomTile tile = HabboItem.getSquareInFront(this.room.getLayout(), this.habboItem);
|
||||
if (tile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.habbo.getRoomUnit().getGoalLocation().equals(tile)) {
|
||||
if (this.habbo.getRoomUnit().getCurrentLocation().equals(tile)) {
|
||||
try {
|
||||
this.habboItem.onClick(this.habbo.getClient(), this.room, new Object[]{0});
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
}
|
||||
} else {
|
||||
if (this.room.getLayout().getTile(tile.getX(), tile.getY()).isWalkable()) {
|
||||
this.habbo.getRoomUnit().setGoalLocation(tile);
|
||||
Emulator.getThreading().run(this, (long) this.habbo.getRoomUnit().getPath().size() + 2 * 510);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class RoomUnitWalkToLocation implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.walker.getGoalLocation().equals(this.goalTile) || (this.walker.getPath().size() == 0 && !this.walker.hasStatus(RoomUnitStatus.MOVE))) {
|
||||
if (!this.walker.getGoalLocation().equals(this.goalTile) || (this.walker.getPath().isEmpty() && !this.walker.hasStatus(RoomUnitStatus.MOVE))) {
|
||||
onFail();
|
||||
return;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class HopperActionFive implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.client.getHabbo().getRoomUnit().isTeleporting = false;
|
||||
this.client.getHabbo().getRoomUnit().setTeleporting(false);
|
||||
RoomTile tile = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY()), this.currentTeleport.getRotation());
|
||||
if (tile != null) {
|
||||
this.client.getHabbo().getRoomUnit().setGoalLocation(tile);
|
||||
|
@ -46,7 +46,7 @@ class HopperActionTwo implements Runnable {
|
||||
} else {
|
||||
this.teleportOne.setExtradata("0");
|
||||
this.client.getHabbo().getRoomUnit().setCanWalk(true);
|
||||
this.client.getHabbo().getRoomUnit().isTeleporting = false;
|
||||
this.client.getHabbo().getRoomUnit().setTeleporting(false);
|
||||
Emulator.getThreading().run(new HopperActionFour(this.teleportOne, this.room, this.client), 500);
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,8 @@ class TeleportActionFive implements Runnable {
|
||||
public void run() {
|
||||
RoomUnit unit = this.client.getHabbo().getRoomUnit();
|
||||
|
||||
unit.isLeavingTeleporter = false;
|
||||
unit.isTeleporting = false;
|
||||
unit.setLeavingTeleporter(false);
|
||||
unit.setTeleporting(false);
|
||||
unit.setCanWalk(true);
|
||||
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room)
|
||||
@ -45,13 +45,13 @@ class TeleportActionFive implements Runnable {
|
||||
onSuccess.add(() -> {
|
||||
unit.setCanLeaveRoomByDoor(true);
|
||||
|
||||
Emulator.getThreading().run(() -> unit.isLeavingTeleporter = false, 300);
|
||||
Emulator.getThreading().run(() -> unit.setLeavingTeleporter(false), 300);
|
||||
});
|
||||
|
||||
unit.setCanLeaveRoomByDoor(false);
|
||||
unit.setGoalLocation(tile);
|
||||
unit.statusUpdate(true);
|
||||
unit.isLeavingTeleporter = true;
|
||||
unit.setLeavingTeleporter(true);
|
||||
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TeleportActionFour implements Runnable {
|
||||
}
|
||||
|
||||
if(this.client.getHabbo().getRoomUnit() != null) {
|
||||
this.client.getHabbo().getRoomUnit().isLeavingTeleporter = true;
|
||||
this.client.getHabbo().getRoomUnit().setLeavingTeleporter(true);
|
||||
}
|
||||
|
||||
Emulator.getThreading().run(new TeleportActionFive(this.currentTeleport, this.room, this.client), 500);
|
||||
|
Loading…
Reference in New Issue
Block a user