This commit is contained in:
harmonic 2020-09-06 12:55:39 +01:00
commit b7446bca45
10 changed files with 235 additions and 270 deletions

View File

@ -130,12 +130,10 @@ public class BotManager {
RoomUnit roomUnit = new RoomUnit();
roomUnit.setRotation(RoomUserRotation.SOUTH);
roomUnit.setLocation(location);
HabboItem topItem = room.getTopItemAt(location.x, location.y);
double topItemHeight = 0;
if (topItem != null) topItemHeight = Item.getCurrentHeight(topItem);
roomUnit.setPreviousLocationZ(roomUnit.getCurrentLocation().getStackHeight() - topItemHeight);
double stackHeight = room.getStackHeight(location.x, location.y, false);
roomUnit.setPreviousLocationZ(stackHeight);
roomUnit.setZ(stackHeight);
roomUnit.setPathFinderRoom(room);
roomUnit.setRoomUnitType(RoomUnitType.BOT);
@ -150,6 +148,8 @@ public class BotManager {
habbo.getClient().sendResponse(new RemoveBotComposer(bot));
bot.onPlace(habbo, room);
HabboItem topItem = room.getTopItemAt(location.x, location.y);
if (topItem != null) {
try {
topItem.onWalkOn(bot.getRoomUnit(), room, null);
@ -157,6 +157,7 @@ public class BotManager {
LOGGER.error("Caught exception", e);
}
}
bot.cycle(false);
} else {
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));

View File

@ -29,7 +29,7 @@ public class InteractionEffectVendingMachine extends InteractionVendingMachine {
}
@Override
public void giveVendingMachineItem(Habbo habbo, Room room) {
room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getRandomVendingItem(), 30);
public void giveVendingMachineItem(Room room, RoomUnit unit) {
room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30);
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -18,7 +19,18 @@ public class InteractionNoSidesVendingMachine extends InteractionVendingMachine
}
@Override
public RoomTile getRequiredTile(Habbo habbo, Room room) {
return habbo.getRoomUnit().getClosestAdjacentTile(this.getX(), this.getY(), true);
public THashSet<RoomTile> getActivatorTiles(Room room) {
THashSet<RoomTile> tiles = new THashSet<RoomTile>();
for(int x = -1; x <= 1; x++) {
for(int y = -1; y <= 1; y++) {
RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y));
if(tile != null) {
tiles.add(tile);
}
}
}
return tiles;
}
}

View File

@ -6,18 +6,23 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import com.eu.habbo.util.pathfinding.Rotation;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledFuture;
public class InteractionVendingMachine extends InteractionDefault {
public class InteractionVendingMachine extends HabboItem {
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
this.setExtradata("0");
@ -28,6 +33,65 @@ public class InteractionVendingMachine extends InteractionDefault {
this.setExtradata("0");
}
public THashSet<RoomTile> getActivatorTiles(Room room) {
THashSet<RoomTile> tiles = new THashSet<RoomTile>();
tiles.add(getSquareInFront(room.getLayout(), this));
tiles.add(room.getLayout().getTile(this.getX(), this.getY()));
return tiles;
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
serverMessage.appendString(this.getExtradata());
super.serializeExtradata(serverMessage);
}
private void tryInteract(GameClient client, Room room, RoomUnit unit) {
THashSet<RoomTile> activatorTiles = getActivatorTiles(room);
if(activatorTiles.size() == 0)
return;
boolean inActivatorSpace = false;
for(RoomTile tile : activatorTiles) {
if(unit.getCurrentLocation().is(unit.getX(), unit.getY())) {
inActivatorSpace = true;
}
}
if(inActivatorSpace) {
useVendingMachine(client, room, unit);
}
}
private void useVendingMachine(GameClient client, Room room, RoomUnit unit) {
this.setExtradata("1");
room.updateItem(this);
if(!unit.isWalking()) {
this.rotateToMachine(room, unit);
}
Emulator.getThreading().run(() -> {
giveVendingMachineItem(room, unit);
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
Emulator.getThreading().run(this, 500);
}, 1500);
}
public void giveVendingMachineItem(Room room, RoomUnit unit) {
Emulator.getThreading().run(new RoomUnitGiveHanditem(unit, room, this.getBaseItem().getRandomVendingItem()));
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
@ -36,81 +100,49 @@ public class InteractionVendingMachine extends InteractionDefault {
return;
}
RoomTile tile = this.getRequiredTile(client.getHabbo(), room);
RoomUnit unit = client.getHabbo().getRoomUnit();
if (tile != null &&
tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
if (!this.getExtradata().equals("0") || this.getExtradata().length() != 0) {
return;
}
THashSet<RoomTile> activatorTiles = getActivatorTiles(room);
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) && (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.MOVE) || tile.equals(client.getHabbo().getRoomUnit().getGoal()))) {
room.updateHabbo(client.getHabbo());
this.rotateToMachine(client.getHabbo().getRoomUnit());
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
}
if(activatorTiles.size() == 0)
return;
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
boolean inActivatorSpace = false;
this.setExtradata("1");
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
for(RoomTile tile : activatorTiles) {
if(unit.getCurrentLocation().is(tile.x, tile.y)) {
inActivatorSpace = true;
}
}
this.runGiveItemThread(client, room);
} else {
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY) {
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
if (t != null && t.isWalkable()) {
tile = t;
break;
}
if(!inActivatorSpace) {
RoomTile tileToWalkTo = null;
for(RoomTile tile : activatorTiles) {
if(room.getLayout().tileWalkable(tile.x, tile.y) && (tileToWalkTo == null || tileToWalkTo.distance(unit.getCurrentLocation()) > tile.distance(unit.getCurrentLocation()))) {
tileToWalkTo = tile;
}
}
RoomTile finalTile = tile;
client.getHabbo().getRoomUnit().setGoalLocation(tile);
if(tileToWalkTo != null) {
List<Runnable> onSuccess = new ArrayList<Runnable>();
List<Runnable> onFail = new ArrayList<Runnable>();
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> {
this.setExtradata("1");
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
onSuccess.add(() -> {
tryInteract(client, room, unit);
});
try {
super.onClick(client, room, new Object[]{"TOGGLE_OVERRIDE"});
} catch (Exception e) {
e.printStackTrace();
}
Emulator.getThreading().run(() -> client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
this.rotateToMachine(client.getHabbo().getRoomUnit());
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
}
this.runGiveItemThread(client, room);
}, 300)), 250);
}, null));
unit.setGoalLocation(tileToWalkTo);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tileToWalkTo, room, onSuccess, onFail));
}
}
else {
useVendingMachine(client, room, unit);
}
}
private void runGiveItemThread(GameClient client, Room room) {
try {
ScheduledFuture thread = Emulator.getThreading().run(() -> {
Emulator.getThreading().run(this, 1000);
this.giveVendingMachineItem(client.getHabbo(), room);
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M)
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F)
room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
}, 500);
if (thread.isDone()) {
thread.get();
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
@Override
@ -125,54 +157,27 @@ public class InteractionVendingMachine extends InteractionDefault {
}
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return true;
}
@Override
public boolean isWalkable() {
return this.getBaseItem().allowWalk();
}
@Override
public boolean isUsable() {
return true;
}
private void rotateToMachine(RoomUnit unit) {
if (unit.getCurrentLocation().getState() != RoomTileState.OPEN) {
// if sitting on a chair or laying on a bed, skip rotating altogether
return;
}
private void rotateToMachine(Room room, RoomUnit unit) {
RoomUserRotation rotation = RoomUserRotation.values()[Rotation.Calculate(unit.getX(), unit.getY(), this.getX(), this.getY())];
boolean onlyHead = false;
switch (unit.getBodyRotation()) {
case NORTH_EAST:
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.EAST))
onlyHead = true;
break;
case NORTH_WEST:
if (rotation.equals(RoomUserRotation.NORTH) || rotation.equals(RoomUserRotation.WEST))
onlyHead = true;
break;
case SOUTH_EAST:
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.EAST))
onlyHead = true;
break;
case SOUTH_WEST:
if (rotation.equals(RoomUserRotation.SOUTH) || rotation.equals(RoomUserRotation.WEST))
onlyHead = true;
break;
}
if (onlyHead) {
unit.setHeadRotation(rotation);
} else {
if(Math.abs(unit.getBodyRotation().getValue() - rotation.getValue()) > 1) {
unit.setRotation(rotation);
unit.statusUpdate(true);
}
}
public void giveVendingMachineItem(Habbo habbo, Room room) {
Emulator.getThreading().run(new RoomUnitGiveHanditem(habbo.getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
}
public RoomTile getRequiredTile(Habbo habbo, Room room) {
return getSquareInFront(room.getLayout(), this);
}
}

View File

@ -114,6 +114,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480;
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
static {
for (int i = 1; i <= 3; i++) {
@ -426,7 +427,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (this.itemCount() > Room.MAXIMUM_FURNI) {
LOGGER.error("Room ID: {} has exceeded the furniture limit ({} > {}).", this.getId(), this.itemCount(), Room.MAXIMUM_FURNI);
}
}
private synchronized void loadWiredData(Connection connection) {
@ -542,7 +542,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public void updateTile(RoomTile tile) {
if (tile != null) {
tile.setStackHeight(this.getStackHeight(tile.x, tile.y, false));
tile.setState(this.calculateTileState(tile));
}
}
@ -566,17 +565,28 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return RoomTileState.INVALID;
RoomTileState result = RoomTileState.OPEN;
HabboItem lowestItem = null;
HabboItem highestItem = null;
HabboItem lowestChair = this.getLowestChair(tile);
THashSet<HabboItem> items = this.getItemsAt(tile);
if (items == null) return RoomTileState.INVALID;
if (items.stream().anyMatch(i -> i.getBaseItem().allowLay())) return RoomTileState.LAY;
if (items == null) return RoomTileState.INVALID;
for (HabboItem item : items) {
if (exclude != null && item == exclude) continue;
if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
if(item.getBaseItem().allowLay()) {
return RoomTileState.LAY;
}
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
highestItem = item;
if (result == RoomTileState.OPEN) {
result = this.checkStateForItem(item, tile);
}
/*if (lowestChair != null && item.getZ() > lowestChair.getZ() + 1.5) {
continue;
}
@ -588,7 +598,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (result == RoomTileState.OPEN) {
result = this.checkStateForItem(item, tile);
}
}
}*/
}
if (lowestChair != null) return RoomTileState.SIT;
@ -1400,9 +1410,13 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
HabboItem nextTileChair = this.getLowestChair(tileInFront);
THashSet<Integer> usersRolledThisTile = new THashSet<>();
for (RoomUnit unit : unitsOnTile) {
if (rolledUnitIds.contains(unit.getId())) continue;
if(usersRolledThisTile.size() >= Room.ROLLERS_MAXIMUM_ROLL_AVATARS) break;
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
@ -1437,6 +1451,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
}
usersRolledThisTile.add(unit.getId());
rolledUnitIds.add(unit.getId());
updatedUnit.remove(unit);
messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, tile.getStackHeight() + (isRiding ? 1 : 0) + (nextTileChair != null ? -1 : 0), room));
@ -2601,7 +2616,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit());
}
if (sendRemovePacket && habbo.getRoomUnit() != null) {
if (sendRemovePacket && habbo.getRoomUnit() != null && !habbo.getRoomUnit().isTeleporting) {
this.sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
}
@ -3005,7 +3020,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public void talk(Habbo habbo, RoomChatMessage roomChatMessage, RoomChatType chatType) {
this.talk(habbo, roomChatMessage, chatType, true);
this.talk(habbo, roomChatMessage, chatType, false);
}
public void talk(final Habbo habbo, final RoomChatMessage roomChatMessage, RoomChatType chatType, boolean ignoreWired) {
@ -3311,6 +3326,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public THashSet<HabboItem> getItemsAt(RoomTile tile) {
return getItemsAt(tile, false);
}
public THashSet<HabboItem> getItemsAt(RoomTile tile, boolean returnOnFirst) {
THashSet<HabboItem> items = new THashSet<>(0);
if (tile == null)
@ -3339,19 +3358,24 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (item.getBaseItem().getType() != FurnitureType.FLOOR)
continue;
if (item.getX() == tile.x && item.getY() == tile.y) {
items.add(item);
} else {
if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
continue;
}
int width, length;
THashSet<RoomTile> tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for (RoomTile t : tiles) {
if ((t.x == tile.x) && (t.y == tile.y) && (!items.contains(item))) {
items.add(item);
}
}
if (item.getRotation() != 2 && item.getRotation() != 6) {
width = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
length = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
}
else {
width = item.getBaseItem().getLength() > 0 ? item.getBaseItem().getLength() : 1;
length = item.getBaseItem().getWidth() > 0 ? item.getBaseItem().getWidth() : 1;
}
if (!(tile.x >= item.getX() && tile.x <= item.getX() + width - 1 && tile.y >= item.getY() && tile.y <= item.getY() + length - 1))
continue;
items.add(item);
if(returnOnFirst) {
return items;
}
}
@ -3369,20 +3393,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (item.getZ() < minZ)
continue;
if (item.getX() == x && item.getY() == y && item.getZ() >= minZ) {
items.add(item);
} else {
if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
continue;
}
THashSet<RoomTile> tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for (RoomTile tile : tiles) {
if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) {
items.add(item);
}
}
}
items.add(item);
}
return items;
}
@ -3390,54 +3401,22 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public THashSet<HabboItem> getItemsAt(Class<? extends HabboItem> type, int x, int y) {
THashSet<HabboItem> items = new THashSet<>();
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
for (HabboItem item : this.getItemsAt(x, y)) {
if (!item.getClass().equals(type))
continue;
for (int i = this.roomItems.size(); i-- > 0; ) {
HabboItem item;
try {
iterator.advance();
item = iterator.value();
} catch (Exception e) {
break;
}
if (item.getClass().equals(type)) {
if (item.getX() == x && item.getY() == y) {
items.add(item);
} else {
if (item.getBaseItem().getWidth() <= 1 && item.getBaseItem().getLength() <= 1) {
continue;
}
THashSet<RoomTile> tiles = this.getLayout().getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for (RoomTile tile : tiles) {
if ((tile.x == x) && (tile.y == y) && (!items.contains(item))) {
items.add(item);
}
}
}
}
items.add(item);
}
return items;
}
public boolean hasItemsAt(int x, int y) {
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
RoomTile tile = this.getLayout().getTile((short) x, (short) y);
for (int i = this.roomItems.size(); i-- > 0; ) {
HabboItem habboItem;
try {
iterator.advance();
habboItem = iterator.value();
} catch (Exception e) {
break;
}
if(tile == null)
return false;
if (habboItem.getX() == x && habboItem.getY() == y) return true;
}
return false;
return this.getItemsAt(tile, true).size() > 0;
}
public HabboItem getTopItemAt(int x, int y) {
@ -3445,55 +3424,24 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public HabboItem getTopItemAt(int x, int y, HabboItem exclude) {
HabboItem item = null;
RoomTile tile = this.getLayout().getTile((short) x, (short) y);
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
if(tile == null)
return null;
for (int i = this.roomItems.size(); i-- > 0; ) {
HabboItem habboItem;
try {
iterator.advance();
habboItem = iterator.value();
} catch (Exception e) {
break;
}
HabboItem highestItem = null;
if (habboItem.getBaseItem().getType() != FurnitureType.FLOOR)
for (HabboItem item : this.getItemsAt(x, y)) {
if(exclude != null && exclude == item)
continue;
if (exclude != null) {
if (exclude == habboItem)
continue;
}
if (highestItem != null && highestItem.getZ() + Item.getCurrentHeight(highestItem) > item.getZ() + Item.getCurrentHeight(item))
continue;
if (habboItem.getX() == x && habboItem.getY() == y) {
if (item == null || (habboItem.getZ() + Item.getCurrentHeight(habboItem)) > (item.getZ() + Item.getCurrentHeight(item))) {
item = habboItem;
}
} else {
if (habboItem.getBaseItem().getWidth() <= 1 && habboItem.getBaseItem().getLength() <= 1) {
continue;
}
if (this.layout == null) continue;
THashSet<RoomTile> tiles = this.layout.getTilesAt(
this.layout.getTile(habboItem.getX(), habboItem.getY()),
habboItem.getBaseItem().getWidth(),
habboItem.getBaseItem().getLength(),
habboItem.getRotation()
);
for (RoomTile tile : tiles) {
if (((tile.x == x) && (tile.y == y))) {
if (item == null || item.getZ() < habboItem.getZ())
item = habboItem;
}
}
}
highestItem = item;
}
return item;
return highestItem;
}
public double getTopHeightAt(int x, int y) {
@ -3524,17 +3472,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<HabboItem> items = this.getItemsAt(tile);
if (items != null && !items.isEmpty()) {
for (HabboItem item : items) {
if (item.getBaseItem().allowSit()) {
if (lowestChair == null || item.getZ() < lowestChair.getZ()) {
lowestChair = item;
}
}
if (lowestChair != null) {
if (item.getZ() > lowestChair.getZ() && item.getZ() - lowestChair.getZ() < 1.5) {
lowestChair = null;
}
}
if(!item.getBaseItem().allowSit())
continue;
if(lowestChair != null && lowestChair.getZ() < item.getZ())
continue;
lowestChair = item;
}
}
@ -3542,37 +3487,32 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
public double getStackHeight(short x, short y, boolean calculateHeightmap, HabboItem exclude) {
if (x < 0 || y < 0 || this.layout == null)
return calculateHeightmap ? Short.MAX_VALUE : 0.0;
double height = this.layout.getHeightAtSquare(x, y);
boolean canStack = true;
boolean stackHelper = false;
THashSet<HabboItem> items = this.getItemsAt(x, y);
if (items != null) {
for (HabboItem item : items) {
THashSet<HabboItem> stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y);
if(stackHelpers.size() > 0) {
for(HabboItem item : stackHelpers) {
if (item == exclude) continue;
if (item instanceof InteractionStackHelper) {
stackHelper = true;
height = item.getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(item.getExtradata()) / 100);
canStack = true;
}
return calculateHeightmap ? item.getZ() * 256.0D : item.getZ();
}
}
if (!stackHelper) {
HabboItem item = this.getTopItemAt(x, y, exclude);
if (item != null) {
canStack = item.getBaseItem().allowStack();
height = item.getZ() + Item.getCurrentHeight(item);
}
HabboItem item = this.getTopItemAt(x, y, exclude);
if (item != null) {
canStack = item.getBaseItem().allowStack();
height = item.getZ() + Item.getCurrentHeight(item);
}
HabboItem lowestChair = this.getLowestChair(x, y);
if (lowestChair != null && lowestChair != exclude) {
canStack = true;
height = lowestChair.getZ();
}
}
HabboItem lowestChair = this.getLowestChair(x, y);
if (lowestChair != null && lowestChair != exclude) {
canStack = true;
height = lowestChair.getZ();
}
if (calculateHeightmap) {

View File

@ -386,8 +386,8 @@ public class RoomManager {
if (Emulator.getPluginManager().fireEvent(new RoomUncachedEvent(room)).isCancelled())
continue;
this.activeRooms.remove(room.getId());
room.dispose();
this.activeRooms.remove(room.getId());
}
}
@ -586,11 +586,11 @@ public class RoomManager {
habbo.getClient().sendResponse(new HideDoorbellComposer(""));
if (habbo.getRoomUnit() != null) {
Room existingRoom = habbo.getRoomUnit().getRoom();
if (existingRoom != null) {
if (habbo.getRoomUnit().getCurrentLocation() != null)
habbo.getRoomUnit().getCurrentLocation().removeUnit(habbo.getRoomUnit());
habbo.getRoomUnit().getRoom().sendComposer(new RoomUserRemoveComposer(habbo.getRoomUnit()).compose());
RoomUnit existingRoom = habbo.getRoomUnit();
if (existingRoom.getRoom() != null) {
if (existingRoom.getCurrentLocation() != null)
existingRoom.getCurrentLocation().removeUnit(existingRoom);
existingRoom.getRoom().sendComposer(new RoomUserRemoveComposer(existingRoom).compose());
}
habbo.getRoomUnit().setRoom(null);
}

View File

@ -25,6 +25,9 @@ public class GuildChangeNameDescEvent extends MessageHandler {
if (guild.getName().equals(nameEvent.name) && guild.getDescription().equals(nameEvent.description))
return;
if(nameEvent.name.length() > 29 || nameEvent.description.length() > 254)
return;
guild.setName(nameEvent.name);
guild.setDescription(nameEvent.description);
guild.needsUpdate = true;

View File

@ -21,6 +21,12 @@ public class RequestGuildBuyEvent extends MessageHandler {
@Override
public void handle() throws Exception {
String name = this.packet.readString();
String description = this.packet.readString();
if(name.length() > 29 || description.length() > 254)
return;
if (Emulator.getConfig().getBoolean("catalog.guild.hc_required", true) && this.client.getHabbo().getHabboStats().getClubExpireTimestamp() < Emulator.getIntUnixTimestamp()) {
this.client.sendResponse(new GuildEditFailComposer(GuildEditFailComposer.HC_REQUIRED));
return;
@ -36,9 +42,6 @@ public class RequestGuildBuyEvent extends MessageHandler {
}
}
String name = this.packet.readString();
String description = this.packet.readString();
int roomId = this.packet.readInt();
Room r = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);

View File

@ -106,6 +106,7 @@ public class PluginManager {
Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240);
Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480);
Room.ROLLERS_MAXIMUM_ROLL_AVATARS = Emulator.getConfig().getInt("hotel.room.rollers.roll_avatars.max", 1);
RoomManager.MAXIMUM_ROOMS_VIP = Emulator.getConfig().getInt("hotel.max.rooms.vip");
RoomManager.MAXIMUM_ROOMS_USER = Emulator.getConfig().getInt("hotel.max.rooms.user");
RoomManager.HOME_ROOM_ID = Emulator.getConfig().getInt("hotel.home.room");

View File

@ -59,7 +59,7 @@ class TeleportActionThree implements Runnable {
this.client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[targetTeleport.getRotation() % 8]);
if (targetRoom != this.room) {
this.room.removeHabbo(this.client.getHabbo(), true);
this.room.removeHabbo(this.client.getHabbo(), false);
Emulator.getGameEnvironment().getRoomManager().enterRoom(this.client.getHabbo(), targetRoom.getId(), "", Emulator.getConfig().getBoolean("hotel.teleport.locked.allowed"), teleportLocation);
}