diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java index 067f1056..46f4a6c3 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/battlebanzai/InteractionBattleBanzaiTeleporter.java @@ -55,18 +55,18 @@ public class InteractionBattleBanzaiTeleporter extends HabboItem { @Override public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { super.onWalkOn(roomUnit, room, objects); - HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this); - if (target == null) return; + if(objects.length < 3) { + HabboItem target = room.getRoomSpecialTypes().getRandomTeleporter(this.getBaseItem(), this); + if (target == null) return; - this.setExtradata("1"); - roomUnit.removeStatus(RoomUnitStatus.MOVE); - target.setExtradata("1"); - room.updateItem(this); - room.updateItem(target); - roomUnit.setGoalLocation(room.getLayout().getTile(roomUnit.getX(), roomUnit.getY())); - roomUnit.setCanWalk(false); - Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 1000); + this.setExtradata("1"); + room.updateItemState(this); + roomUnit.removeStatus(RoomUnitStatus.MOVE); + roomUnit.setGoalLocation(roomUnit.getCurrentLocation()); + roomUnit.setCanWalk(false); + Emulator.getThreading().run(new BanzaiRandomTeleport(this, target, roomUnit, room), 500); + } } @Override diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index a7e5c561..65fffba4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -2971,7 +2971,7 @@ public class Room implements Comparable, ISerialize, Runnable { this.teleportRoomUnitToLocation(roomUnit, x, y, 0.0); } - void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) { + public void teleportRoomUnitToLocation(RoomUnit roomUnit, short x, short y, double z) { if (this.loaded) { RoomTile tile = this.layout.getTile(x, y); diff --git a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java index c372652a..d559daed 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/BanzaiRandomTeleport.java @@ -2,9 +2,11 @@ package com.eu.habbo.threading.runnables; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.HabboItem; +import org.slf4j.LoggerFactory; public class BanzaiRandomTeleport implements Runnable { private final HabboItem item; @@ -21,12 +23,52 @@ public class BanzaiRandomTeleport implements Runnable { @Override public void run() { - this.habbo.setCanWalk(true); - this.item.setExtradata("0"); - this.toItem.setExtradata("0"); - this.room.updateItem(this.item); - this.room.updateItem(this.toItem); - this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8))); - this.room.teleportRoomUnitToItem(this.habbo, this.toItem); + HabboItem topItemNow = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY()); + RoomTile lastLocation = this.habbo.getCurrentLocation(); + RoomTile newLocation = this.room.getLayout().getTile(toItem.getX(), toItem.getY()); + + if(topItemNow != null) { + try { + topItemNow.onWalkOff(this.habbo, this.room, new Object[] { lastLocation, newLocation, this }); + } catch (Exception e) { + LoggerFactory.getLogger(BanzaiRandomTeleport.class).error("BanzaiRandomTeleport exception", e); + } + } + + Emulator.getThreading().run(() -> { + if (this.item.getExtradata().equals("1")) { + this.item.setExtradata("0"); + this.room.updateItemState(this.item); + } + }, 500); + + if(!this.toItem.getExtradata().equals("1")) { + this.toItem.setExtradata("1"); + this.room.updateItemState(this.toItem); + } + + Emulator.getThreading().run(() -> { + this.habbo.setCanWalk(true); + HabboItem topItemNext = this.room.getTopItemAt(this.habbo.getX(), this.habbo.getY()); + + if(topItemNext != null) { + try { + topItemNext.onWalkOn(this.habbo, this.room, new Object[] { lastLocation, newLocation, this }); + } catch (Exception e) { + LoggerFactory.getLogger(BanzaiRandomTeleport.class).error("BanzaiRandomTeleport exception", e); + } + } + + if (this.toItem.getExtradata().equals("1")) { + this.toItem.setExtradata("0"); + this.room.updateItemState(this.toItem); + } + }, 750); + + Emulator.getThreading().run(() -> { + this.habbo.setRotation(RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8))); + this.room.teleportRoomUnitToLocation(this.habbo, newLocation.x, newLocation.y, newLocation.getStackHeight()); + }, 250); + } } diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 5aafb4e9..755005c8 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -36,8 +36,9 @@ public class RoomUnitTeleport implements Runnable { public void run() { if (roomUnit == null || roomUnit.getRoom() == null || room.getLayout() == null || roomUnit.isLeavingTeleporter) return; - - RoomTile t = this.room.getLayout().getTile((short) this.x, (short) this.y); + + RoomTile lastLocation = this.roomUnit.getCurrentLocation(); + RoomTile newLocation = this.room.getLayout().getTile((short) this.x, (short) this.y); HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); if (topItem != null) { @@ -48,23 +49,23 @@ public class RoomUnitTeleport implements Runnable { } } this.roomUnit.setPath(new LinkedList<>()); - this.roomUnit.setCurrentLocation(t); - this.roomUnit.setPreviousLocation(t); + this.roomUnit.setCurrentLocation(newLocation); + this.roomUnit.setPreviousLocation(newLocation); this.roomUnit.setZ(this.z); this.roomUnit.setPreviousLocationZ(this.z); this.roomUnit.removeStatus(RoomUnitStatus.MOVE); - ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose(); - this.roomUnit.setLocation(t); + ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose(); + this.roomUnit.setLocation(newLocation); this.room.sendComposer(teleportMessage); roomUnit.isWiredTeleporting = false; - this.room.updateHabbosAt(t.x, t.y); - this.room.updateBotsAt(t.x, t.y); + this.room.updateHabbosAt(newLocation.x, newLocation.y); + this.room.updateBotsAt(newLocation.x, newLocation.y); topItem = room.getTopItemAt(x, y); if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile((short) x, (short) y))) { try { - topItem.onWalkOn(roomUnit, room, new Object[]{}); + topItem.onWalkOn(roomUnit, room, new Object[]{ lastLocation, newLocation, this }); } catch (Exception e) { } }