Fixed Teleport and OneWayGate able to make you leave the room. Added canLeaveRoomByDoor to RoomUnit.

This commit is contained in:
Beny 2019-05-15 22:54:07 +01:00
parent 3f015ecc5a
commit efc3c46d0b
5 changed files with 36 additions and 11 deletions

View File

@ -91,15 +91,15 @@ public class InteractionOneWayGate extends HabboItem
List<Runnable> onFail = new ArrayList<Runnable>();
onSuccess.add(() -> {
unit.setCanLeaveRoomByDoor(false);
walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation);
room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose());
unit.removeOverrideTile(currentLocation);
unit.setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4));
RoomTile tile = room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), this.getRotation() + 4);
unit.setGoalLocation(tile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onFail, onFail));
});
onFail.add(() -> {
unit.setCanLeaveRoomByDoor(true);
walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation);
room.sendComposer(new ItemIntStateComposer(this.getId(), 0).compose());

View File

@ -103,6 +103,7 @@ public class InteractionTeleport extends HabboItem
room.updateTile(currentLocation);
tryTeleport(client, room);
unit.removeOverrideTile(currentLocation);
unit.setCanLeaveRoomByDoor(true);
});
onFail.add(() -> {
@ -112,12 +113,14 @@ public class InteractionTeleport extends HabboItem
room.updateItem(this);
this.roomUnitID = -1;
unit.removeOverrideTile(currentLocation);
unit.setCanLeaveRoomByDoor(true);
});
walkable = true;
room.updateTile(currentLocation);
unit.addOverrideTile(currentLocation);
unit.setGoalLocation(currentLocation);
unit.setCanLeaveRoomByDoor(false);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, currentLocation, room, onSuccess, onFail));
}
else {

View File

@ -720,6 +720,7 @@ public class RoomManager
habbo.getRoomUnit().setHeadRotation(RoomUserRotation.values()[room.getLayout().getDoorDirection()]);
}
else {
habbo.getRoomUnit().setCanLeaveRoomByDoor(false);
habbo.getRoomUnit().isTeleporting = true;
HabboItem topItem = room.getTopItemAt(doorLocation.x, doorLocation.y);
if(topItem != null) {

View File

@ -57,6 +57,7 @@ public class RoomUnit
private boolean statusUpdate = false;
private boolean invisible = false;
private boolean lastCycleStatus = false;
private boolean canLeaveRoomByDoor = true;
private final ConcurrentHashMap<RoomUnitStatus, String> status;
private final THashMap<String, Object> cacheable;
@ -383,7 +384,7 @@ public class RoomUnit
if (habbo != null)
{
if (next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick")))
if (this.canLeaveRoomByDoor && next.x == room.getLayout().getDoorX() && next.y == room.getLayout().getDoorY() && (!room.isPublicRoom()) || (room.isPublicRoom() && Emulator.getConfig().getBoolean("hotel.room.public.doortile.kick")))
{
Emulator.getThreading().run(new RoomUnitKick(habbo, room, false), 500);
}
@ -824,4 +825,12 @@ public class RoomUnit
public void clearOverrideTiles() {
this.overridableTiles.clear();
}
public boolean canLeaveRoomByDoor() {
return canLeaveRoomByDoor;
}
public void setCanLeaveRoomByDoor(boolean canLeaveRoomByDoor) {
this.canLeaveRoomByDoor = canLeaveRoomByDoor;
}
}

View File

@ -5,6 +5,10 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.threading.runnables.HabboItemNewState;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import java.util.ArrayList;
import java.util.List;
class TeleportActionFive implements Runnable
{
@ -22,8 +26,10 @@ class TeleportActionFive implements Runnable
@Override
public void run()
{
this.client.getHabbo().getRoomUnit().isTeleporting = false;
this.client.getHabbo().getRoomUnit().setCanWalk(true);
RoomUnit unit = this.client.getHabbo().getRoomUnit();
unit.isTeleporting = false;
unit.setCanWalk(true);
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != this.room)
return;
@ -35,10 +41,16 @@ class TeleportActionFive implements Runnable
if (tile != null)
{
this.client.getHabbo().getRoomUnit().setGoalLocation(tile);
this.client.getHabbo().getRoomUnit().statusUpdate(true);
}
List<Runnable> onSuccess = new ArrayList<Runnable>();
onSuccess.add(() -> {
unit.setCanLeaveRoomByDoor(true);
});
unit.setCanLeaveRoomByDoor(false);
unit.setGoalLocation(tile);
unit.statusUpdate(true);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, tile, room, onSuccess, onSuccess));
}
this.currentTeleport.setExtradata("1");
this.room.updateItem(this.currentTeleport);