mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 15:36:27 +01:00
Horse Riding fixed
This commit is contained in:
parent
59290bae8d
commit
6dcb02d6f0
@ -30,6 +30,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@ -124,7 +126,7 @@ public class Bot extends Avatar implements Runnable {
|
||||
statement.execute();
|
||||
this.sqlUpdateNeeded = false;
|
||||
} catch (SQLException e) {
|
||||
log.error("Caught SQL exception", e);
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ public class CatalogManager {
|
||||
if (guild != null && Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild, habbo) != null) {
|
||||
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);
|
||||
habboItem.setExtraData("");
|
||||
habboItem.needsUpdate(true);
|
||||
habboItem.setSqlUpdateNeeded(true);
|
||||
|
||||
Emulator.getThreading().run(habboItem);
|
||||
Emulator.getGameEnvironment().getGuildManager().setGuild(habboItem, guildId);
|
||||
@ -1031,7 +1031,7 @@ public class CatalogManager {
|
||||
}
|
||||
|
||||
InteractionMusicDisc habboItem = (InteractionMusicDisc) Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, habbo.getClient().getHabbo().getHabboInfo().getUsername() + "\n" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "\n" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "\n" + Calendar.getInstance().get(Calendar.YEAR) + "\n" + track.getLength() + "\n" + track.getName() + "\n" + track.getId());
|
||||
habboItem.needsUpdate(true);
|
||||
habboItem.setSqlUpdateNeeded(true);
|
||||
|
||||
Emulator.getThreading().run(habboItem);
|
||||
itemsList.add(habboItem);
|
||||
|
@ -189,7 +189,7 @@ public class RoomBundleLayout extends SingleBundle {
|
||||
}
|
||||
|
||||
if (Emulator.getConfig().getBoolean("bundle.bots.enabled")) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (user_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO bots (owner_id, room_id, name, motto, figure, gender, x, y, z, chat_lines, chat_auto, chat_random, chat_delay, dance, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
synchronized (this.room.getRoomUnitManager().getCurrentBots()) {
|
||||
statement.setInt(1, userId);
|
||||
statement.setInt(2, roomId);
|
||||
|
@ -282,7 +282,7 @@ public class MarketPlace {
|
||||
event.price = calculateCommision(event.price);
|
||||
|
||||
item.setOwnerInfo(client.getHabbo().getHabboInfo());
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
client.getHabbo().getInventory().getItemsComponent().addItem(item);
|
||||
@ -363,7 +363,7 @@ public class MarketPlace {
|
||||
client.getHabbo().getInventory().addMarketplaceOffer(offer);
|
||||
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.getItem());
|
||||
item.setOwnerInfo(null);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
return true;
|
||||
|
@ -25,8 +25,7 @@ public class InvisibleCommand extends Command {
|
||||
|
||||
new RoomUnitTeleport(roomUnit, roomUnit.getRoom(), roomLayout.getDoorTile().getX(), roomLayout.getDoorTile().getY(), roomLayout.getDoorTile().getZ(), 0).run();
|
||||
|
||||
roomUnit.setInvisible(false)
|
||||
.setInRoom(true);
|
||||
roomUnit.setInvisible(false);
|
||||
|
||||
roomUnit.getRoom().sendComposer(new RoomUsersComposer(gameClient.getHabbo()).compose());
|
||||
roomUnit.getRoom().sendComposer(new UserUpdateComposer(roomUnit).compose());
|
||||
|
@ -39,7 +39,7 @@ public class InteractionBackgroundToner extends RoomItem {
|
||||
serverMessage.appendInt(126);
|
||||
serverMessage.appendInt(126);
|
||||
this.setExtraData("0:126:126:126");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class InteractionBackgroundToner extends RoomItem {
|
||||
this.setExtraData("0:126:126:126");
|
||||
room.updateItem(this);
|
||||
}
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class InteractionColorPlate extends InteractionDefault {
|
||||
}
|
||||
|
||||
this.setExtraData(state + "");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
@ -107,7 +107,7 @@ public class InteractionCrackable extends RoomItem {
|
||||
}
|
||||
this.ticks++;
|
||||
this.setExtraData("" + (this.ticks));
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
|
||||
if (!rewardData.getAchievementTick().isEmpty()) {
|
||||
|
@ -88,7 +88,7 @@ public class InteractionDefault extends RoomItem {
|
||||
}
|
||||
|
||||
this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount());
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class InteractionFireworks extends InteractionDefault {
|
||||
|
||||
Emulator.getThreading().run(() -> {
|
||||
this.setExtraData(STATE_CHARGED);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItemState(this);
|
||||
}, explodeDuration);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class InteractionGate extends RoomItem {
|
||||
|
||||
this.setExtraData((Integer.parseInt(this.getExtraData()) + 1) % 2 + "");
|
||||
room.updateTile(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()));
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItemState(this);
|
||||
|
||||
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
|
||||
|
@ -111,7 +111,7 @@ public class InteractionLoveLock extends RoomItem {
|
||||
data += Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR);
|
||||
|
||||
this.setExtraData(data);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
room.updateItem(this);
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class InteractionMannequin extends RoomItem {
|
||||
serverMessage.appendString("OUTFIT_NAME");
|
||||
serverMessage.appendString("My Look");
|
||||
this.setExtraData("m: :My look");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
super.serializeExtradata(serverMessage);
|
||||
|
@ -51,7 +51,7 @@ public class InteractionMoodLight extends RoomItem {
|
||||
for (RoomMoodlightData data : ((TIntObjectMap<RoomMoodlightData>) room.getRoomInfo().getMoodLightData()).valueCollection()) {
|
||||
if (data.isEnabled()) {
|
||||
this.setExtraData(data.toString());
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class InteractionMultiHeight extends RoomItem {
|
||||
return;
|
||||
}
|
||||
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
if (this.getExtraData().length() == 0) {
|
||||
this.setExtraData("0");
|
||||
@ -70,7 +70,7 @@ public class InteractionMultiHeight extends RoomItem {
|
||||
|
||||
if (this.getBaseItem().getMultiHeights().length > 0) {
|
||||
this.setExtraData(String.valueOf((Integer.parseInt(this.getExtraData()) + 1) % (this.getBaseItem().getMultiHeights().length)));
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getCurrentPosition().getX(), this.getCurrentPosition().getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class InteractionOneWayGate extends RoomItem {
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
if (this.getExtraData().length() == 0) {
|
||||
this.setExtraData("0");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
|
@ -71,7 +71,7 @@ public class InteractionPuzzleBox extends RoomItem {
|
||||
return;
|
||||
|
||||
this.setCurrentZ(room.getStackHeight(tile.getX(), tile.getY(), false));
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
room.updateItem(this);
|
||||
|
||||
@ -81,7 +81,7 @@ public class InteractionPuzzleBox extends RoomItem {
|
||||
|
||||
room.scheduledTasks.add(() -> client.getHabbo().getRoomUnit().walkTo(boxLocation));
|
||||
});
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,7 +145,7 @@ public class InteractionRentableSpace extends RoomItem {
|
||||
|
||||
habbo.getHabboStats().setRentedItemId(this.getId());
|
||||
habbo.getHabboStats().setRentedTimeEnd(this.endTimestamp);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
this.run();
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ public class InteractionRentableSpace extends RoomItem {
|
||||
|
||||
this.setRenterId(0);
|
||||
this.setRenterName("");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
this.run();
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class InteractionSwitchRemoteControl extends InteractionDefault {
|
||||
}
|
||||
|
||||
this.setExtraData("" + (currentState + 1) % this.getBaseItem().getStateCount());
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
@ -232,9 +232,4 @@ public class InteractionTeleport extends RoomItem {
|
||||
public boolean isUsable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean invalidatesToRoomKick() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class InteractionVoteCounter extends RoomItem {
|
||||
}
|
||||
|
||||
updateExtradata();
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ public class InteractionVoteCounter extends RoomItem {
|
||||
|
||||
votes += vote;
|
||||
updateExtradata();
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public class InteractionWater extends InteractionDefault {
|
||||
|
||||
if (!this.getExtraData().equals(updatedData)) {
|
||||
this.setExtraData(updatedData);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class InteractionWaterItem extends InteractionMultiHeight {
|
||||
public void onPickUp(Room room) {
|
||||
super.onPickUp(room);
|
||||
this.setExtraData("0");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -82,7 +82,7 @@ public class InteractionWaterItem extends InteractionMultiHeight {
|
||||
|
||||
if (!this.getExtraData().equals(updatedData)) {
|
||||
this.setExtraData(updatedData);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public abstract class InteractionWired extends InteractionDefault implements IWi
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate()) {
|
||||
if (this.isSqlUpdateNeeded()) {
|
||||
//TODO HERE IS WHERE WIRED_SAVE_EXCEPTION WILL BE THROWN
|
||||
//EXAMPLE: if StringParam should be number, throw error here, maybe activating a flag in wiredSettings that string params are numbers
|
||||
this.loadDefaultIntegerParams();
|
||||
|
@ -155,7 +155,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.needsUpdate() || this.needsDelete()) {
|
||||
if (this.isSqlUpdateNeeded() || this.isSqlDeleteNeeded()) {
|
||||
super.run();
|
||||
}
|
||||
}
|
||||
@ -165,7 +165,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable {
|
||||
this.endGame(room);
|
||||
|
||||
this.setExtraData(this.baseTime + "\t" + this.baseTime);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -178,7 +178,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable {
|
||||
|
||||
this.setExtraData(this.timeNow + "\t" + this.baseTime);
|
||||
room.updateItem(this);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
super.onPlace(room);
|
||||
}
|
||||
@ -318,7 +318,7 @@ public class InteractionGameTimer extends RoomItem implements Runnable {
|
||||
|
||||
this.timeNow = this.baseTime;
|
||||
room.updateItem(this);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public class InteractionFootballGate extends RoomItem {
|
||||
this.figureM = look;
|
||||
|
||||
this.setExtraData(this.figureM + ";" + this.figureF);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ public class InteractionFootballGate extends RoomItem {
|
||||
this.figureF = look;
|
||||
|
||||
this.setExtraData(this.figureM + ";" + this.figureF);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard {
|
||||
}
|
||||
|
||||
this.setExtraData(this.score + "");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
||||
if (room != null) {
|
||||
@ -86,7 +86,7 @@ public class InteractionFootballScoreboard extends InteractionGameScoreboard {
|
||||
}
|
||||
|
||||
this.setExtraData(this.score + "");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
Room room = Emulator.getGameEnvironment().getRoomManager().getActiveRoomById(this.getRoomId());
|
||||
if (room != null) {
|
||||
|
@ -18,7 +18,7 @@ public class InteractionMonsterPlantSeed extends RoomItem {
|
||||
|
||||
if (this.getExtraData().isEmpty()) {
|
||||
this.setExtraData("" + randomRarityLevel());
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class InteractionMonsterPlantSeed extends RoomItem {
|
||||
|
||||
if (this.getExtraData().isEmpty()) {
|
||||
this.setExtraData("" + randomRarityLevel());
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class InteractionPetBreedingNest extends RoomItem {
|
||||
|
||||
|
||||
habbo.getRoomUnit().getRoom().getRoomUnitManager().placePet(offspring, habbo.getRoomUnit().getRoom(), box.getCurrentPosition().getX(), box.getCurrentPosition().getY(), box.getCurrentZ());
|
||||
offspring.setNeedsUpdate(true);
|
||||
offspring.setSqlUpdateNeeded(true);
|
||||
offspring.run();
|
||||
InteractionPetBreedingNest.this.freePets();
|
||||
habbo.getRoomUnit().getRoom().getRoomItemManager().removeRoomItem(box);
|
||||
|
@ -123,7 +123,7 @@ public class InteractionPetDrink extends InteractionDefault {
|
||||
}
|
||||
|
||||
this.setExtraData(state + "");
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItemState(this);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class InteractionTotemHead extends InteractionDefault {
|
||||
public void updateTotemState(Room room, RoomTile tile) {
|
||||
this.setExtraData(getTotemType().getType() - 1 + "");
|
||||
update(room, tile);
|
||||
this.needsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
room.updateItem(this);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class GnomePet extends Pet implements IPetLook {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.isNeedsUpdate()) {
|
||||
if (this.isSqlUpdateNeeded()) {
|
||||
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.isNeedsUpdate()) {
|
||||
if (this.isSqlUpdateNeeded()) {
|
||||
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);
|
||||
|
@ -119,7 +119,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.isNeedsUpdate()) {
|
||||
if (this.isSqlUpdateNeeded()) {
|
||||
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 = ?")) {
|
||||
@ -153,7 +153,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath"));
|
||||
|
||||
this.hasDied = true;
|
||||
this.setNeedsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
this.getRoomUnit().clearStatuses();
|
||||
|
@ -19,9 +19,13 @@ import com.eu.habbo.plugin.events.pets.PetTalkEvent;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
@ -29,108 +33,39 @@ import java.util.TimeZone;
|
||||
import static com.eu.habbo.database.DatabaseConstants.CAUGHT_SQL_EXCEPTION;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
public class Pet extends Unit implements ISerialize, Runnable {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public int levelThirst;
|
||||
@Getter
|
||||
@Setter
|
||||
public int levelHunger;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean needsUpdate = false;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean packetUpdate = false;
|
||||
@Getter
|
||||
protected int id;
|
||||
@Getter
|
||||
@Setter
|
||||
protected final int id;
|
||||
protected int userId;
|
||||
@Getter
|
||||
@Setter
|
||||
protected Room room;
|
||||
@Getter
|
||||
@Setter
|
||||
protected String name;
|
||||
@Setter
|
||||
@Getter
|
||||
protected PetData petData;
|
||||
@Setter
|
||||
@Getter
|
||||
protected int race;
|
||||
@Getter
|
||||
@Setter
|
||||
protected String color;
|
||||
@Getter
|
||||
@Setter
|
||||
protected int happiness;
|
||||
@Getter
|
||||
@Setter
|
||||
protected int experience;
|
||||
@Setter
|
||||
@Getter
|
||||
protected int energy;
|
||||
|
||||
/**
|
||||
* The respect points of the pet.
|
||||
*/
|
||||
protected int respect;
|
||||
@Getter
|
||||
@Setter
|
||||
protected int created;
|
||||
@Getter
|
||||
@Setter
|
||||
protected int level;
|
||||
|
||||
/**
|
||||
* The chat timeout of the pet.
|
||||
*/
|
||||
private int chatTimeout;
|
||||
|
||||
/**
|
||||
* The tick timeout of the pet.
|
||||
*/
|
||||
private int tickTimeout = Emulator.getIntUnixTimestamp();
|
||||
private int happinessDelay = Emulator.getIntUnixTimestamp();
|
||||
private int gestureTickTimeout = Emulator.getIntUnixTimestamp();
|
||||
|
||||
/**
|
||||
* The random action tick timeout of the pet.
|
||||
*/
|
||||
private int randomActionTickTimeout = Emulator.getIntUnixTimestamp();
|
||||
|
||||
/**
|
||||
* The posture timeout of the pet.
|
||||
*/
|
||||
private int postureTimeout = Emulator.getIntUnixTimestamp();
|
||||
@Getter
|
||||
@Setter
|
||||
private int stayStartedAt = 0;
|
||||
/**
|
||||
* The number of ticks that the pet has spent idle while waiting for a command.
|
||||
*/
|
||||
private int idleCommandTicks = 0;
|
||||
|
||||
/**
|
||||
* The number of ticks that the pet has spent free after completing a command.
|
||||
*/
|
||||
private int freeCommandTicks = -1;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private PetTasks task = PetTasks.FREE;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
private boolean muted = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private RoomPet roomUnit;
|
||||
private final RoomPet roomUnit;
|
||||
public int levelThirst;
|
||||
public int levelHunger;
|
||||
private boolean sqlUpdateNeeded = false;
|
||||
private boolean packetUpdate = false;
|
||||
|
||||
/**
|
||||
* Creates a new pet using the given result set, which should contain data retrieved from a
|
||||
@ -159,6 +94,9 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
||||
this.levelThirst = set.getInt("thirst");
|
||||
this.levelHunger = set.getInt("hunger");
|
||||
this.level = PetManager.getLevel(this.experience);
|
||||
|
||||
this.roomUnit = new RoomPet();
|
||||
this.roomUnit.setUnit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,6 +129,9 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
||||
this.levelHunger = 0;
|
||||
this.created = Emulator.getIntUnixTimestamp();
|
||||
this.level = 1;
|
||||
|
||||
this.roomUnit = new RoomPet();
|
||||
this.roomUnit.setUnit(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -283,52 +224,26 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
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 = ?, happiness = ?, created = ? WHERE id = ?")) {
|
||||
statement.setInt(1, (this.room == null ? 0 : this.room.getRoomInfo().getId()));
|
||||
statement.setInt(2, this.experience);
|
||||
statement.setInt(3, this.energy);
|
||||
statement.setInt(4, this.respect);
|
||||
statement.setInt(5, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getX() : 0);
|
||||
statement.setInt(6, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getY() : 0);
|
||||
statement.setDouble(7, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentZ() : 0.0);
|
||||
statement.setInt(8, this.getRoomUnit() != null ? this.getRoomUnit().getBodyRotation().getValue() : 0);
|
||||
statement.setInt(9, this.levelHunger);
|
||||
statement.setInt(10, this.levelThirst);
|
||||
statement.setInt(11, this.happiness);
|
||||
statement.setInt(12, this.created);
|
||||
statement.setInt(13, this.id);
|
||||
statement.execute();
|
||||
}
|
||||
} else if (this.id == 0) {
|
||||
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_pets (user_id, room_id, name, race, type, color, experience, energy, respect, created) VALUES (?, 0, ?, ?, ?, ?, 0, 0, 0, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, this.userId);
|
||||
statement.setString(2, this.name);
|
||||
statement.setInt(3, this.race);
|
||||
statement.setInt(4, 0);
|
||||
|
||||
if (this.petData != null) {
|
||||
statement.setInt(4, this.petData.getType());
|
||||
}
|
||||
|
||||
statement.setString(5, this.color);
|
||||
statement.setInt(6, this.created);
|
||||
statement.execute();
|
||||
|
||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
||||
if (set.next()) {
|
||||
this.id = set.getInt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.sqlUpdateNeeded) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET room_id = ?, experience = ?, energy = ?, respect = ?, x = ?, y = ?, z = ?, rot = ?, hunger = ?, thirst = ?, happiness = ?, created = ? WHERE id = ?")) {
|
||||
statement.setInt(1, (this.room == null ? 0 : this.room.getRoomInfo().getId()));
|
||||
statement.setInt(2, this.experience);
|
||||
statement.setInt(3, this.energy);
|
||||
statement.setInt(4, this.respect);
|
||||
statement.setInt(5, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getX() : 0);
|
||||
statement.setInt(6, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentPosition().getY() : 0);
|
||||
statement.setDouble(7, this.getRoomUnit() != null ? this.getRoomUnit().getCurrentZ() : 0.0);
|
||||
statement.setInt(8, this.getRoomUnit() != null ? this.getRoomUnit().getBodyRotation().getValue() : 0);
|
||||
statement.setInt(9, this.levelHunger);
|
||||
statement.setInt(10, this.levelThirst);
|
||||
statement.setInt(11, this.happiness);
|
||||
statement.setInt(12, this.created);
|
||||
statement.setInt(13, this.id);
|
||||
statement.execute();
|
||||
this.sqlUpdateNeeded = false;
|
||||
} catch (SQLException e) {
|
||||
log.error(CAUGHT_SQL_EXCEPTION, e);
|
||||
}
|
||||
|
||||
this.setNeedsUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -788,7 +703,7 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
||||
this.addHappiness(10);
|
||||
this.addExperience(10);
|
||||
this.addRespect();
|
||||
this.setNeedsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getHabboStats().decreasePetRespectPointsToGive();
|
||||
@ -825,9 +740,9 @@ public class Pet extends Unit implements ISerialize, Runnable {
|
||||
room.getRoomUnitManager().removePet(this.id);
|
||||
}
|
||||
|
||||
this.setRoomUnit(null);
|
||||
this.roomUnit.setRoom(null);
|
||||
this.room = null;
|
||||
this.setNeedsUpdate(true);
|
||||
this.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.pets.*;
|
||||
import com.eu.habbo.habbohotel.pets.actions.*;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import gnu.trove.map.TIntIntMap;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
@ -407,7 +406,7 @@ public class PetManager {
|
||||
client.getHabbo().getHabboInfo().getId()
|
||||
);
|
||||
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -421,7 +420,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.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -443,10 +442,8 @@ public class PetManager {
|
||||
|
||||
pet.setUserId(habbo.getHabboInfo().getId());
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomPet());
|
||||
pet.getRoomUnit().setUnit(pet);
|
||||
pet.getRoomUnit().setRoom(room);
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
return pet;
|
||||
}
|
||||
@ -463,10 +460,8 @@ public class PetManager {
|
||||
|
||||
pet.setUserId(habbo.getHabboInfo().getId());
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomPet());
|
||||
pet.getRoomUnit().setUnit(pet);
|
||||
pet.getRoomUnit().setRoom(room);
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
|
||||
return pet;
|
||||
@ -484,10 +479,8 @@ public class PetManager {
|
||||
|
||||
pet.setUserId(habbo.getHabboInfo().getId());
|
||||
pet.setRoom(room);
|
||||
pet.setRoomUnit(new RoomPet());
|
||||
pet.getRoomUnit().setUnit(pet);
|
||||
pet.getRoomUnit().setRoom(room);
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
|
||||
return pet;
|
||||
|
@ -995,6 +995,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
for (Game game : this.games) {
|
||||
game.dispose();
|
||||
}
|
||||
|
||||
this.games.clear();
|
||||
|
||||
this.roomUnitManager.removeAllPetsExceptRoomOwner();
|
||||
|
@ -314,7 +314,7 @@ public class RoomItemManager {
|
||||
item.setCurrentPosition(tile);
|
||||
item.setCurrentZ(height);
|
||||
item.setRotation(rotation);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
|
||||
this.addRoomItem(item);
|
||||
|
||||
@ -350,7 +350,7 @@ public class RoomItemManager {
|
||||
this.room.getFurniOwnerNames().put(item.getOwnerInfo().getId(), owner.getHabboInfo().getUsername());
|
||||
}
|
||||
this.room.sendComposer(new ItemAddMessageComposer(item, this.room.getFurniOwnerName(item.getOwnerInfo().getId())).compose());
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
this.addRoomItem(item);
|
||||
//Deprecated
|
||||
item.setRoomId(this.room.getRoomInfo().getId());
|
||||
@ -504,7 +504,7 @@ public class RoomItemManager {
|
||||
|
||||
//Update Furniture
|
||||
item.onMove(this.room, oldLocation, targetTile);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
@ -557,7 +557,7 @@ public class RoomItemManager {
|
||||
//Deprecated
|
||||
roomItem.setRoomId(0);
|
||||
roomItem.setRoom(null);
|
||||
roomItem.needsUpdate(true);
|
||||
roomItem.setSqlUpdateNeeded(true);
|
||||
|
||||
if (roomItem.getBaseItem().getType() == FurnitureType.FLOOR) {
|
||||
this.room.sendComposer(new RemoveFloorItemComposer(roomItem).compose());
|
||||
@ -1101,7 +1101,7 @@ public class RoomItemManager {
|
||||
|
||||
public void dispose() {
|
||||
this.currentItems.values().parallelStream()
|
||||
.filter(RoomItem::needsUpdate)
|
||||
.filter(roomItem1 -> roomItem1.isSqlUpdateNeeded())
|
||||
.forEach(roomItem -> {
|
||||
roomItem.run();
|
||||
this.currentItems.remove(roomItem.getId());
|
||||
|
@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
import lombok.Getter;
|
||||
@ -276,7 +277,13 @@ public class RoomLayout {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.room.getRoomUnitManager().areRoomUnitsAt(currentAdj) && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) {
|
||||
RoomUnit exception = null;
|
||||
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) {
|
||||
exception = roomAvatar.getRidingPet().getRoomUnit();
|
||||
}
|
||||
|
||||
if (this.room.getRoomUnitManager().areRoomUnitsAt(currentAdj, exception) && doorTile.distance(currentAdj) > 2 && (!isWalktroughRetry || !this.room.getRoomInfo().isAllowWalkthrough() || currentAdj.equals(goalLocation))) {
|
||||
closedList.add(currentAdj);
|
||||
openList.remove(currentAdj);
|
||||
continue;
|
||||
|
@ -594,9 +594,6 @@ public class RoomManager {
|
||||
|
||||
habbo.getClient().sendResponse(new OpenConnectionMessageComposer());
|
||||
|
||||
//@Deprecated
|
||||
roomHabbo.setInRoom(true);
|
||||
|
||||
if (!habbo.getHabboStats().isBlockFollowing() && roomHabbo.getRoom() == null) {
|
||||
habbo.getMessenger().connectionChanged(habbo, true, true);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.rooms;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -173,7 +174,15 @@ public class RoomTile {
|
||||
|
||||
public void removeUnit(RoomUnit roomUnit) {
|
||||
synchronized (this.roomUnits) {
|
||||
if(!this.roomUnits.contains(roomUnit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.roomUnits.remove(roomUnit);
|
||||
|
||||
if(roomUnit instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) {
|
||||
this.roomUnits.remove(roomAvatar.getRidingPet().getRoomUnit());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ public class RoomTraxManager implements Disposable {
|
||||
//Deprecated
|
||||
musicDisc.setRoomId(-1);
|
||||
musicDisc.setRoom(null);
|
||||
musicDisc.needsUpdate(true);
|
||||
musicDisc.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(musicDisc);
|
||||
|
||||
habbo.getInventory().getItemsComponent().removeHabboItem(musicDisc);
|
||||
@ -298,7 +298,7 @@ public class RoomTraxManager implements Disposable {
|
||||
//Deprecated
|
||||
musicDisc.setRoomId(0);
|
||||
musicDisc.setRoom(null);
|
||||
musicDisc.needsUpdate(true);
|
||||
musicDisc.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(musicDisc);
|
||||
|
||||
Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().getId());
|
||||
@ -330,7 +330,7 @@ public class RoomTraxManager implements Disposable {
|
||||
//Deprecated
|
||||
musicDisc.setRoomId(0);
|
||||
musicDisc.setRoom(null);
|
||||
musicDisc.needsUpdate(true);
|
||||
musicDisc.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(musicDisc);
|
||||
|
||||
Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(musicDisc.getOwnerInfo().getId());
|
||||
|
@ -13,7 +13,6 @@ import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomBot;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomHabbo;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
||||
import com.eu.habbo.habbohotel.units.Unit;
|
||||
import com.eu.habbo.habbohotel.users.DanceType;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -99,9 +98,6 @@ public class RoomUnitManager {
|
||||
|
||||
bot.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
|
||||
|
||||
//@DEPRECATED
|
||||
bot.getRoomUnit().setInRoom(true);
|
||||
|
||||
bot.getRoomUnit().giveEffect(set.getInt("effect"), Integer.MAX_VALUE, false);
|
||||
|
||||
this.addRoomUnit(bot);
|
||||
@ -125,8 +121,6 @@ public class RoomUnitManager {
|
||||
Pet pet = PetManager.loadPet(set);
|
||||
|
||||
pet.setRoom(this.room);
|
||||
pet.setRoomUnit(new RoomPet());
|
||||
pet.getRoomUnit().setUnit(pet);
|
||||
pet.getRoomUnit().setRoom(this.room);
|
||||
pet.getRoomUnit().setLocation(this.room.getLayout().getTile((short) set.getInt("x"), (short) set.getInt("y")));
|
||||
if (pet.getRoomUnit().getCurrentPosition() == null || pet.getRoomUnit().getCurrentPosition().getState() == RoomTileState.INVALID) {
|
||||
@ -152,6 +146,8 @@ public class RoomUnitManager {
|
||||
|
||||
public void addRoomUnit(Unit unit) {
|
||||
synchronized (this.roomUnitLock) {
|
||||
//TODO Maybe set the room in this method
|
||||
|
||||
unit.getRoomUnit().setVirtualId(this.roomUnitCounter);
|
||||
this.currentRoomUnits.put(unit.getRoomUnit().getVirtualId(), unit.getRoomUnit());
|
||||
this.roomUnitCounter++;
|
||||
@ -184,6 +180,10 @@ public class RoomUnitManager {
|
||||
}
|
||||
|
||||
public boolean areRoomUnitsAt(RoomTile tile, RoomUnit skippedRoomUnit) {
|
||||
if(skippedRoomUnit == null) {
|
||||
return this.areRoomUnitsAt(tile);
|
||||
}
|
||||
|
||||
return this.currentRoomUnits.values().stream().filter(roomUnit -> !roomUnit.equals(skippedRoomUnit)).anyMatch(roomUnit -> roomUnit.getCurrentPosition().equals(tile));
|
||||
}
|
||||
|
||||
@ -405,8 +405,6 @@ public class RoomUnitManager {
|
||||
spawnTile = room.getLayout().getDoorTile();
|
||||
}
|
||||
|
||||
pet.setRoomUnit(new RoomPet());
|
||||
pet.getRoomUnit().setUnit(pet);
|
||||
pet.setRoom(room);
|
||||
pet.getRoomUnit().walkTo(spawnTile);
|
||||
pet.getRoomUnit().setLocation(spawnTile)
|
||||
@ -420,7 +418,7 @@ public class RoomUnitManager {
|
||||
.setRotation(RoomRotation.fromValue(room.getLayout().getDoorDirection()));
|
||||
}
|
||||
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
room.getFurniOwnerNames().put(pet.getUserId(), this.getRoomHabboById(pet.getUserId()).getHabboInfo().getUsername());
|
||||
this.addRoomUnit(pet);
|
||||
room.sendComposer(new RoomPetComposer(pet).compose());
|
||||
@ -511,22 +509,18 @@ public class RoomUnitManager {
|
||||
}
|
||||
|
||||
public void removeBot(Bot bot) {
|
||||
synchronized (this.currentBots) {
|
||||
if (this.currentBots.containsKey(bot.getId())) {
|
||||
//TODO gotta do a method to removeUnit and clear tile
|
||||
if (bot.getRoomUnit() != null && bot.getRoomUnit().getCurrentPosition() != null) {
|
||||
bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit());
|
||||
}
|
||||
|
||||
this.currentBots.remove(bot.getId());
|
||||
this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId());
|
||||
|
||||
//@DEPRECATED
|
||||
bot.getRoomUnit().setInRoom(false);
|
||||
bot.getRoomUnit().setRoom(null);
|
||||
|
||||
this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose());
|
||||
if (this.currentBots.containsKey(bot.getId())) {
|
||||
//TODO gotta do a method to removeUnit and clear tile
|
||||
if (bot.getRoomUnit().getCurrentPosition() != null) {
|
||||
bot.getRoomUnit().getCurrentPosition().removeUnit(bot.getRoomUnit());
|
||||
}
|
||||
|
||||
this.currentBots.remove(bot.getId());
|
||||
this.currentRoomUnits.remove(bot.getRoomUnit().getVirtualId());
|
||||
|
||||
bot.getRoomUnit().setRoom(null);
|
||||
|
||||
this.room.sendComposer(new UserRemoveMessageComposer(bot.getRoomUnit()).compose());
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,7 +558,7 @@ public class RoomUnitManager {
|
||||
habbo.getClient().sendResponse(new PetAddedToInventoryComposer(pet));
|
||||
}
|
||||
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.run();
|
||||
}
|
||||
|
||||
@ -611,7 +605,7 @@ public class RoomUnitManager {
|
||||
while(petIterator.hasNext()) {
|
||||
try {
|
||||
Pet pet = petIterator.next();
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(pet);
|
||||
} catch (NoSuchElementException e) {
|
||||
log.error("Caught Exception", e);
|
||||
|
@ -142,7 +142,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
||||
serverMessage.appendInt(this.getCurrentPosition().getY());
|
||||
serverMessage.appendInt(this.getRotation());
|
||||
serverMessage.appendString(Double.toString(this.getCurrentZ()));
|
||||
|
||||
serverMessage.appendString((this.getBaseItem().getInteractionType().getType() == InteractionTrophy.class || this.getBaseItem().getInteractionType().getType() == InteractionCrackable.class || this.getBaseItem().getName().equalsIgnoreCase("gnome_box")) ? "1.0" : ((this.getBaseItem().allowWalk() || this.getBaseItem().allowSit() && this.roomId != 0) ? String.valueOf(Item.getCurrentHeight(this)) : ""));
|
||||
} catch (Exception e) {
|
||||
log.error("Caught exception", e);
|
||||
@ -180,22 +179,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
||||
this.rotation = (byte) (rotation % 8);
|
||||
}
|
||||
|
||||
public boolean needsUpdate() {
|
||||
return this.sqlUpdateNeeded;
|
||||
}
|
||||
|
||||
public boolean needsDelete() {
|
||||
return sqlDeleteNeeded;
|
||||
}
|
||||
|
||||
public void needsUpdate(boolean value) {
|
||||
this.sqlUpdateNeeded = value;
|
||||
}
|
||||
|
||||
public void needsDelete(boolean value) {
|
||||
this.sqlDeleteNeeded = value;
|
||||
}
|
||||
|
||||
public boolean isLimited() {
|
||||
return this.limitedStack > 0;
|
||||
}
|
||||
@ -486,8 +469,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean invalidatesToRoomKick() { return false; }
|
||||
|
||||
public List<RoomTile> getOccupyingTiles(RoomLayout layout) {
|
||||
List<RoomTile> tiles = new ArrayList<>();
|
||||
|
||||
@ -502,10 +483,6 @@ public abstract class RoomItem extends RoomEntity implements Runnable, IEventTri
|
||||
return tiles;
|
||||
}
|
||||
|
||||
public RoomTile getOverrideGoalTile(RoomUnit unit, Room room, RoomTile tile) {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public RoomTileState getOverrideTileState(RoomTile tile, Room room) {
|
||||
return null;
|
||||
}
|
||||
|
@ -5,13 +5,11 @@ import com.eu.habbo.habbohotel.bots.Bot;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
|
||||
import com.eu.habbo.habbohotel.pets.RideablePet;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.RoomEntity;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomPet;
|
||||
import com.eu.habbo.habbohotel.units.Unit;
|
||||
import com.eu.habbo.habbohotel.users.DanceType;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||
@ -74,8 +72,6 @@ public abstract class RoomUnit extends RoomEntity {
|
||||
@Setter
|
||||
protected int kickCount = 0;
|
||||
@Setter
|
||||
protected boolean inRoom;
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
protected boolean invisible = false;
|
||||
@Setter
|
||||
@ -97,7 +93,6 @@ public abstract class RoomUnit extends RoomEntity {
|
||||
this.statuses = new ConcurrentHashMap<>();
|
||||
this.statusUpdateNeeded = false;
|
||||
|
||||
this.inRoom = false;
|
||||
this.cacheable = new THashMap<>();
|
||||
this.roomUnitType = RoomUnitType.UNKNOWN;
|
||||
this.walkTimeOut = Emulator.getIntUnixTimestamp();
|
||||
@ -121,6 +116,10 @@ public abstract class RoomUnit extends RoomEntity {
|
||||
}
|
||||
};
|
||||
|
||||
public boolean isInRoom() {
|
||||
return this.room != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoomUnit setCurrentPosition(RoomTile tile) {
|
||||
super.setCurrentPosition(tile);
|
||||
@ -529,6 +528,10 @@ public abstract class RoomUnit extends RoomEntity {
|
||||
private double handleNextHeight(RoomTile next) {
|
||||
double height = 0.0D;
|
||||
|
||||
if(this instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) {
|
||||
height += 1.0D;
|
||||
}
|
||||
|
||||
RoomItem nextTileItem = this.room.getRoomItemManager().getTopItemAt(next);
|
||||
|
||||
if(nextTileItem != null) {
|
||||
@ -566,17 +569,13 @@ public abstract class RoomUnit extends RoomEntity {
|
||||
|
||||
double heightDifference = tile.getStackHeight() - this.currentZ;
|
||||
|
||||
boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile);
|
||||
RoomUnit exception = null;
|
||||
|
||||
if(this instanceof RoomAvatar roomAvatar && roomAvatar.isRiding()) {
|
||||
areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, roomAvatar.getRidingPet().getRoomUnit());
|
||||
exception = roomAvatar.getRidingPet().getRoomUnit();
|
||||
}
|
||||
|
||||
if(this instanceof RoomPet roomPet) {
|
||||
if(roomPet.getUnit() instanceof RideablePet rideablePet && rideablePet.hasRider()) {
|
||||
areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, rideablePet.getRider().getRoomUnit());
|
||||
}
|
||||
}
|
||||
boolean areRoomUnitsAtTile = this.room.getRoomUnitManager().areRoomUnitsAt(tile, exception);
|
||||
|
||||
boolean isAboveMaximumStepHeight = (!RoomLayout.ALLOW_FALLING && heightDifference < -RoomLayout.MAXIMUM_STEP_HEIGHT);
|
||||
boolean isOpenTileAboveMaxHeight = (tile.getState() == RoomTileState.OPEN && heightDifference > RoomLayout.MAXIMUM_STEP_HEIGHT);
|
||||
|
@ -6,9 +6,15 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnitType;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@Accessors(chain = true)
|
||||
public class RoomPet extends RoomUnit {
|
||||
private Pet unit;
|
||||
|
||||
@ -23,26 +29,38 @@ public class RoomPet extends RoomUnit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the interaction between a RideablePet unit and its rider (Habbo) in the virtual room.
|
||||
* If the unit is a RideablePet and has a rider, this method updates the unit's position and status
|
||||
* to reflect the rider's movement and actions.
|
||||
*
|
||||
* @return {@code true} if the interaction was successfully handled, {@code false} pet walks normally.
|
||||
*/
|
||||
public boolean handleRider() {
|
||||
Habbo rider = null;
|
||||
|
||||
if (this.unit instanceof RideablePet rideablePet) {
|
||||
rider = rideablePet.getRider();
|
||||
if (!(this.unit instanceof RideablePet rideablePet)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Habbo rider = rideablePet.getRider();
|
||||
|
||||
if(rider == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy things from rider
|
||||
if (this.hasStatus(RoomUnitStatus.MOVE) && !rider.getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || !rider.getRoomUnit().isWalking()) {
|
||||
this.removeStatus(RoomUnitStatus.MOVE);
|
||||
RoomAvatar riderAvatar = rider.getRoomUnit();
|
||||
|
||||
if(this.getNextPosition() != null) {
|
||||
this.setCurrentPosition(this.getNextPosition());
|
||||
this.setCurrentZ(this.getNextZ());
|
||||
}
|
||||
|
||||
if (!this.currentPosition.equals(rider.getRoomUnit().getCurrentPosition())) {
|
||||
this.addStatus(RoomUnitStatus.MOVE, rider.getRoomUnit().getCurrentPosition().getX() + "," + rider.getRoomUnit().getCurrentPosition().getY() + "," + (rider.getRoomUnit().getCurrentPosition().getStackHeight()));
|
||||
this.setCurrentPosition(rider.getRoomUnit().getCurrentPosition());
|
||||
this.setCurrentZ(rider.getRoomUnit().getCurrentPosition().getStackHeight());
|
||||
if(riderAvatar.isWalking()) {
|
||||
this.addStatus(RoomUnitStatus.MOVE, riderAvatar.getNextPosition().getX() + "," + riderAvatar.getNextPosition().getY() + "," + (riderAvatar.getNextZ() - 1.0D));
|
||||
this.setNextPosition(riderAvatar.getNextPosition());
|
||||
this.setNextZ(riderAvatar.getNextZ() - 1.0D);
|
||||
this.setRotation(riderAvatar.getBodyRotation());
|
||||
} else if(!riderAvatar.isWalking() && this.hasStatus(RoomUnitStatus.MOVE)) {
|
||||
this.stopWalking();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -159,7 +159,8 @@ public class ItemsComponent {
|
||||
} catch (NoSuchElementException e) {
|
||||
break;
|
||||
}
|
||||
if (items.value().needsUpdate())
|
||||
RoomItem roomItem = items.value();
|
||||
if (roomItem.isSqlUpdateNeeded())
|
||||
Emulator.getThreading().run(items.value());
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public class PetsComponent {
|
||||
} catch (NoSuchElementException e) {
|
||||
break;
|
||||
}
|
||||
if (petIterator.value().isNeedsUpdate())
|
||||
if (petIterator.value().isSqlUpdateNeeded())
|
||||
Emulator.getThreading().run(petIterator.value());
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class PurchasePhotoEvent extends MessageHandler {
|
||||
|
||||
if (photoItem != null) {
|
||||
photoItem.setExtraData(photoItem.getExtraData().replace("%id%", photoItem.getId() + ""));
|
||||
photoItem.needsUpdate(true);
|
||||
photoItem.setSqlUpdateNeeded(true);
|
||||
|
||||
this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
|
||||
|
||||
|
@ -11,9 +11,9 @@ import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboBadge;
|
||||
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.catalog.*;
|
||||
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
|
||||
@ -285,7 +285,7 @@ public class PurchaseFromCatalogAsGiftEvent extends MessageHandler {
|
||||
} else if (baseItem.getInteractionType().getType() == InteractionGuildFurni.class || baseItem.getInteractionType().getType() == InteractionGuildGate.class) {
|
||||
InteractionGuildFurni habboItem = (InteractionGuildFurni) Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, limitedStack, limitedNumber, extraData);
|
||||
habboItem.setExtraData("");
|
||||
habboItem.needsUpdate(true);
|
||||
habboItem.setSqlUpdateNeeded(true);
|
||||
int guildId;
|
||||
try {
|
||||
guildId = Integer.parseInt(extraData);
|
||||
|
@ -29,6 +29,5 @@ public class QuitEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
roomHabbo.clear();
|
||||
roomHabbo.setInRoom(false);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class RequestRoomPropertySet extends MessageHandler {
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
|
||||
room.setNeedsUpdate(true);
|
||||
room.sendComposer(new RoomPropertyMessageComposer(item.getBaseItem().getName(), item.getExtraData()).compose());
|
||||
item.needsDelete(true);
|
||||
item.setSqlDeleteNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
this.client.sendResponse(new FurniListRemoveComposer(itemId));
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class SetRoomBackgroundColorDataEvent extends MessageHandler {
|
||||
brightness = event.getBrightness() % 256;
|
||||
|
||||
item.setExtraData(item.getExtraData().split(":")[0] + ":" + hue + ":" + saturation + ":" + brightness);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
room.updateItem(item);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class AddSpamWallPostItEvent extends MessageHandler {
|
||||
|
||||
sticky.setOwnerInfo(room.getRoomInfo().getOwnerInfo());
|
||||
sticky.setExtraData(color + " " + text);
|
||||
sticky.needsUpdate(true);
|
||||
sticky.setSqlUpdateNeeded(true);
|
||||
room.updateItem(sticky);
|
||||
Emulator.getThreading().run(sticky);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class DiceOffEvent extends MessageHandler {
|
||||
if (RoomLayout.tilesAdjecent(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()), this.client.getHabbo().getRoomUnit().getCurrentPosition())) {
|
||||
if (!item.getExtraData().equals("-1")) {
|
||||
item.setExtraData("0");
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
room.updateItem(item);
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ public class MoveWallItemEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
item.setWallPosition(wallPosition);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
room.updateItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class PlacePostItEvent extends MessageHandler {
|
||||
item.setRoom(this.client.getHabbo().getRoomUnit().getRoom());
|
||||
item.setWallPosition(location);
|
||||
item.setOwnerInfo(this.client.getHabbo().getHabboInfo());
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
room.sendComposer(new ItemAddMessageComposer(item, this.client.getHabbo().getHabboInfo().getUsername()).compose());
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
|
||||
this.client.sendResponse(new FurniListRemoveComposer(item.getGiftAdjustedId()));
|
||||
|
@ -32,7 +32,7 @@ public class RoomDimmerChangeStateEvent extends MessageHandler {
|
||||
if (RoomMoodlightData.fromString(moodLight.getExtraData()).isEnabled()) adjusted.disable();
|
||||
moodLight.setExtraData(adjusted.toString());
|
||||
|
||||
moodLight.needsUpdate(true);
|
||||
moodLight.setSqlUpdateNeeded(true);
|
||||
room.updateItem(moodLight);
|
||||
Emulator.getThreading().run(moodLight);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class RoomDimmerSavePresetEvent extends MessageHandler {
|
||||
|
||||
for (RoomItem item : room.getRoomSpecialTypes().getItemsOfType(InteractionMoodLight.class)) {
|
||||
item.setExtraData(data.toString());
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
room.updateItem(item);
|
||||
Emulator.getThreading().run(item);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class SetCustomStackingHeightEvent extends MessageHandler {
|
||||
|
||||
item.setCurrentZ(height);
|
||||
item.setExtraData(String.valueOf((int) (height * 100)));
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
|
||||
this.client.getHabbo().getRoomUnit().getRoom().updateItem(item);
|
||||
this.client.getHabbo().getRoomUnit().getRoom().updateTiles(tiles);
|
||||
|
@ -52,7 +52,7 @@ public class SetItemDataEvent extends MessageHandler {
|
||||
color = PostItColor.YELLOW.hexColor;
|
||||
|
||||
item.setExtraData(color + " " + text);
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
room.updateItem(item);
|
||||
Emulator.getThreading().run(item);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class SetMannequinFigureEvent extends MessageHandler {
|
||||
item.setExtraData(habbo.getHabboInfo().getGender().name().toLowerCase() + ":" + look + ":" + habbo.getHabboInfo().getUsername() + "'s look.");
|
||||
}
|
||||
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
room.updateItem(item);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class SetMannequinNameEvent extends MessageHandler {
|
||||
} else {
|
||||
item.setExtraData(this.client.getHabbo().getHabboInfo().getGender().name().toUpperCase() + ":" + this.client.getHabbo().getHabboInfo().getLook() + ":" + name);
|
||||
}
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
room.updateItem(item);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class SetObjectDataEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
item.setExtraData(((InteractionCustomValues) item).toExtraData());
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(item);
|
||||
room.updateItem(item);
|
||||
((InteractionCustomValues) item).onCustomValuesSaved(room, this.client, oldValues);
|
||||
|
@ -32,7 +32,7 @@ public class UseWallItemEvent extends MessageHandler {
|
||||
if (item.getBaseItem().getName().equalsIgnoreCase("poster"))
|
||||
return;
|
||||
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
item.onClick(this.client, room, new Object[]{state});
|
||||
room.updateItem(item);
|
||||
Emulator.getThreading().run(item);
|
||||
|
@ -43,7 +43,7 @@ public class SetYoutubeDisplayPlaylistEvent extends YoutubeEvent {
|
||||
room.sendComposer(new YoutubeDisplayVideoMessageComposer(itemId, video, true, 0).compose());
|
||||
((InteractionYoutubeTV) item).autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo((InteractionYoutubeTV) item), video.getDuration() * 1000L);
|
||||
|
||||
item.needsUpdate(true);
|
||||
item.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ public class CustomizePetWithFurniEvent extends MessageHandler {
|
||||
raceType = 0;
|
||||
|
||||
pet.setRace(raceType);
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(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.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(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.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
} else if (item.getBaseItem().getName().toLowerCase().startsWith("horse_saddle")) {
|
||||
((HorsePet) pet).hasSaddle(true);
|
||||
((HorsePet) pet).setSaddleItemId(item.getBaseItem().getId());
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
}
|
||||
|
||||
if (pet.isNeedsUpdate()) {
|
||||
if (pet.isSqlUpdateNeeded()) {
|
||||
Emulator.getThreading().run(pet);
|
||||
this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer((HorsePet) pet).compose());
|
||||
|
||||
|
@ -28,10 +28,8 @@ public class MountPetEvent extends MessageHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
//dismount
|
||||
if (habbo.getRoomUnit().isRiding()) {
|
||||
boolean mountAnotherPet = petId != habbo.getRoomUnit().getRidingPet().getId();
|
||||
|
||||
habbo.getRoomUnit().dismountPet(false);
|
||||
|
||||
if(!mountAnotherPet) {
|
||||
@ -39,12 +37,10 @@ public class MountPetEvent extends MessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// someone is already on it
|
||||
if (rideablePet.getRider() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if able to ride
|
||||
if (!rideablePet.anyoneCanRide() && habbo.getHabboInfo().getId() != rideablePet.getUserId()) {
|
||||
return;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class MovePetEvent extends MessageHandler {
|
||||
pet.getRoomUnit().setCurrentZ(tile.getZ());
|
||||
pet.getRoomUnit().setRotation(RoomRotation.fromValue(this.packet.readInt()));
|
||||
room.sendComposer(new UserUpdateComposer(pet.getRoomUnit()).compose());
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class OpenPetPackageEvent extends MessageHandler {
|
||||
if (pet != null) {
|
||||
room.getRoomUnitManager().placePet(pet, room, item.getCurrentPosition().getX(), item.getCurrentPosition().getY(), item.getCurrentZ());
|
||||
pet.setUserId(this.client.getHabbo().getHabboInfo().getId());
|
||||
pet.setNeedsUpdate(true);
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
pet.getRoomUnit().setLocation(room.getLayout().getTile(item.getCurrentPosition().getX(), item.getCurrentPosition().getY()));
|
||||
pet.getRoomUnit().setCurrentZ(item.getCurrentZ());
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
|
@ -73,27 +73,31 @@ public class PlacePetEvent extends MessageHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO REMOVE THIS
|
||||
pet.setRoom(room);
|
||||
RoomPet roomPet = pet.getRoomUnit();
|
||||
|
||||
if (roomPet == null) {
|
||||
roomPet = new RoomPet();
|
||||
roomPet.setUnit(pet);
|
||||
}
|
||||
RoomPet roomPet = pet.getRoomUnit();
|
||||
|
||||
roomPet.setRoom(room);
|
||||
|
||||
roomPet.setLocation(tile);
|
||||
roomPet.setCurrentZ(tile.getStackHeight());
|
||||
|
||||
roomPet.addStatus(RoomUnitStatus.SIT, "0");
|
||||
|
||||
//TODO I dont think I need this anymore
|
||||
roomPet.setRoomUnitType(RoomUnitType.PET);
|
||||
|
||||
if (playerTile != null) {
|
||||
roomPet.lookAtPoint(playerTile);
|
||||
}
|
||||
pet.setRoomUnit(roomPet);
|
||||
|
||||
room.getRoomUnitManager().addRoomUnit(pet);
|
||||
pet.setNeedsUpdate(true);
|
||||
|
||||
//This to update room on DB
|
||||
pet.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(pet);
|
||||
|
||||
room.sendComposer(new RoomPetComposer(pet).compose());
|
||||
this.client.getHabbo().getInventory().getPetsComponent().removePet(pet);
|
||||
this.client.sendResponse(new PetRemovedFromInventoryComposer(pet));
|
||||
|
@ -53,7 +53,7 @@ public class RemoveSaddleFromPetEvent extends MessageHandler {
|
||||
if (saddleItem == null) return;
|
||||
|
||||
horse.hasSaddle(false);
|
||||
horse.setNeedsUpdate(true);
|
||||
horse.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(pet);
|
||||
this.client.getHabbo().getRoomUnit().getRoom().sendComposer(new PetFigureUpdateComposer(horse).compose());
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class TogglePetRidingPermissionEvent extends MessageHandler {
|
||||
return;
|
||||
|
||||
rideablePet.setAnyoneCanRide(!rideablePet.anyoneCanRide());
|
||||
rideablePet.setNeedsUpdate(true);
|
||||
rideablePet.setSqlUpdateNeeded(true);
|
||||
|
||||
if (!rideablePet.anyoneCanRide() && rideablePet.getRider() != null && rideablePet.getRider().getHabboInfo().getId() != this.client.getHabbo().getHabboInfo().getId()) {
|
||||
rideablePet.getRider().getRoomUnit().dismountPet(false);
|
||||
|
@ -28,7 +28,7 @@ public class UpdateActionEvent extends MessageHandler {
|
||||
|
||||
effect.saveWiredSettings(this.packet, room);
|
||||
this.client.sendResponse(new WiredSavedComposer());
|
||||
effect.needsUpdate(true);
|
||||
effect.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(effect);
|
||||
}
|
||||
catch (WiredSaveException e) {
|
||||
|
@ -26,7 +26,7 @@ public class UpdateConditionEvent extends MessageHandler {
|
||||
|
||||
condition.saveWiredSettings(this.packet, room);
|
||||
this.client.sendResponse(new WiredSavedComposer());
|
||||
condition.needsUpdate(true);
|
||||
condition.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(condition);
|
||||
}
|
||||
catch (WiredSaveException e) {
|
||||
|
@ -26,7 +26,7 @@ public class UpdateTriggerEvent extends MessageHandler {
|
||||
|
||||
trigger.saveWiredSettings(this.packet, room);
|
||||
this.client.sendResponse(new WiredSavedComposer());
|
||||
trigger.needsUpdate(true);
|
||||
trigger.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(trigger);
|
||||
}
|
||||
catch (WiredSaveException e) {
|
||||
|
@ -54,7 +54,7 @@ public class FloorItemOnRollerComposer extends MessageComposer {
|
||||
|
||||
this.item.setCurrentPosition(this.newLocation);
|
||||
this.item.setCurrentZ(this.item.getCurrentZ() + this.heightOffset);
|
||||
this.item.needsUpdate(true);
|
||||
this.item.setSqlUpdateNeeded(true);
|
||||
|
||||
//TODO This is bad
|
||||
//
|
||||
|
@ -37,7 +37,7 @@ public class WiredConditionDataComposer extends MessageComposer {
|
||||
this.response.appendInt(this.condition.getWiredSettings().getSelectionType());
|
||||
this.response.appendInt(this.condition.getType().getCode());
|
||||
|
||||
this.condition.needsUpdate(true);
|
||||
this.condition.setSqlUpdateNeeded(true);
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class WiredEffectDataComposer extends MessageComposer {
|
||||
this.response.appendInt(blockedTrigger);
|
||||
}
|
||||
|
||||
this.effect.needsUpdate(true);
|
||||
this.effect.setSqlUpdateNeeded(true);
|
||||
|
||||
return this.response;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class WiredTriggerDataComposer extends MessageComposer {
|
||||
this.response.appendInt(blockedTrigger);
|
||||
}
|
||||
|
||||
this.trigger.needsUpdate(true);
|
||||
this.trigger.setSqlUpdateNeeded(true);
|
||||
return this.response;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class ClearRentedSpace implements Runnable {
|
||||
//Deprecated
|
||||
i.setRoomId(0);
|
||||
i.setRoom(null);
|
||||
i.needsUpdate(true);
|
||||
i.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class CloseGate implements Runnable {
|
||||
if (!this.room.getRoomUnitManager().hasHabbosAt(tile)) {
|
||||
this.gate.setExtraData("0");
|
||||
this.room.updateItem(this.gate);
|
||||
this.gate.needsUpdate(true);
|
||||
this.gate.setSqlUpdateNeeded(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class CrackableExplode implements Runnable {
|
||||
//Deprecated
|
||||
newItem.setRoomId(this.room.getRoomInfo().getId());
|
||||
newItem.setRoom(this.room);
|
||||
newItem.needsUpdate(true);
|
||||
newItem.setSqlUpdateNeeded(true);
|
||||
this.room.getRoomItemManager().addRoomItem(newItem);
|
||||
this.room.updateItem(newItem);
|
||||
this.room.sendComposer(new ObjectAddMessageComposer(newItem, this.room.getFurniOwnerNames().get(newItem.getOwnerInfo().getId())).compose());
|
||||
|
@ -34,7 +34,7 @@ public class OpenGift implements Runnable {
|
||||
inside = i;
|
||||
|
||||
i.setOwnerInfo(this.habbo.getHabboInfo());
|
||||
i.needsUpdate(true);
|
||||
i.setSqlUpdateNeeded(true);
|
||||
i.run();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class RandomDiceNumber implements Runnable {
|
||||
this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1);
|
||||
|
||||
this.item.setExtraData(this.result + "");
|
||||
this.item.needsUpdate(true);
|
||||
this.item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this.item);
|
||||
|
||||
this.room.updateItem(this.item);
|
||||
|
@ -30,7 +30,7 @@ public class RandomSpinningBottleNumber implements Runnable {
|
||||
this.result = Emulator.getRandom().nextInt(this.maxNumber);
|
||||
|
||||
this.item.setExtraData(this.result + "");
|
||||
this.item.needsUpdate(true);
|
||||
this.item.setSqlUpdateNeeded(true);
|
||||
Emulator.getThreading().run(this.item);
|
||||
|
||||
this.room.updateItem(this.item);
|
||||
|
@ -7,19 +7,34 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.AvatarEffectMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class RoomUnitRidePet implements Runnable {
|
||||
private final int MAX_RETRIES = 3;
|
||||
private final RideablePet pet;
|
||||
private final Habbo habbo;
|
||||
private final RoomTile goalTile;
|
||||
private int retries;
|
||||
|
||||
public RoomUnitRidePet(RideablePet pet, Habbo rider, RoomTile petTile) {
|
||||
this.pet = pet;
|
||||
this.habbo = rider;
|
||||
this.goalTile = petTile;
|
||||
this.retries = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (this.habbo.getRoomUnit() == null || this.pet.getRoomUnit() == null || this.pet.getRoom() != this.habbo.getRoomUnit().getRoom() || this.goalTile == null || this.habbo.getRoomUnit().getTargetPosition() != this.goalTile)
|
||||
if (this.pet.getRoom() != this.habbo.getRoomUnit().getRoom()) {
|
||||
this.habbo.getRoomUnit().setRideLocked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.retries >= MAX_RETRIES) {
|
||||
this.habbo.getRoomUnit().setRideLocked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.retries++;
|
||||
|
||||
if (habbo.getRoomUnit().getCurrentPosition().distance(pet.getRoomUnit().getCurrentPosition()) <= 1) {
|
||||
habbo.getRoomUnit().stopWalking();
|
||||
|
Loading…
Reference in New Issue
Block a user