Minor updates

This commit is contained in:
Alejandro 2019-07-30 13:56:54 +03:00
parent 8870145948
commit a0d5e92f1a

View File

@ -11,32 +11,29 @@ import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent; import com.eu.habbo.plugin.events.users.UserIdleEvent;
import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler { public class RoomUserWalkEvent extends MessageHandler {
@Override @Override
public void handle() throws Exception public void handle() throws Exception {
{ if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) int x = this.packet.readInt(); // Position X
{ int y = this.packet.readInt(); // Position Y
int x = this.packet.readInt(); ///< Position X
int y = this.packet.readInt(); ///<Position Y
/// Get Habbo object // Get Habbo object
Habbo habbo = this.client.getHabbo(); Habbo habbo = this.client.getHabbo();
/// Get Room Habbo object (Unique GUID?) // Get Room Habbo object (Unique GUID?)
RoomUnit roomUnit = this.client.getHabbo().getRoomUnit(); RoomUnit roomUnit = this.client.getHabbo().getRoomUnit();
/// If habbo is teleporting, dont calculate a new path // If habbo is teleporting, dont calculate a new path
if (roomUnit.isTeleporting) if (roomUnit.isTeleporting)
return; return;
/// If habbo is being kicked dont calculate a new path // If habbo is being kicked dont calculate a new path
if (roomUnit.isKicked) if (roomUnit.isKicked)
return; return;
/// If habbo has control (im assuming admin, do something else, but we dont care about this part here) // If habbo has control (im assuming admin, do something else, but we dont care about this part here)
if (roomUnit.getCacheable().get("control") != null) { if (roomUnit.getCacheable().get("control") != null) {
habbo = (Habbo) roomUnit.getCacheable().get("control"); habbo = (Habbo) roomUnit.getCacheable().get("control");
@ -47,34 +44,30 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
/// Get room unit? // Get room unit?
roomUnit = habbo.getRoomUnit(); roomUnit = habbo.getRoomUnit();
/// Get the room the habbo is in // Get the room the habbo is in
Room room = habbo.getHabboInfo().getCurrentRoom(); Room room = habbo.getHabboInfo().getCurrentRoom();
try try {
{ // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
/// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) // If we are not teleporting calcualte a new path
{ if (!roomUnit.cmdTeleport) {
/// If we are not teleporting calcualte a new path // Don't calculate a new path if we are on a horse
if (!roomUnit.cmdTeleport)
{
/// Don't calculate a new path if we are on a horse
if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP))
return; return;
/// Don't calulcate a new path if are already at the end position // Don't calulcate a new path if are already at the end position
if (x == roomUnit.getX() && y == roomUnit.getY()) if (x == roomUnit.getX() && y == roomUnit.getY())
return; return;
if (room == null || room.getLayout() == null) if (room == null || room.getLayout() == null)
return; return;
/// Reset idle status // Reset idle status
if (roomUnit.isIdle()) if (roomUnit.isIdle()) {
{
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
Emulator.getPluginManager().fireEvent(event); Emulator.getPluginManager().fireEvent(event);
@ -86,15 +79,15 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
/// Get room height map // Get room height map
RoomTile tile = room.getLayout().getTile((short) x, (short) y); RoomTile tile = room.getLayout().getTile((short) x, (short) y);
/// this should never happen, if it does it would be a design flaw // this should never happen, if it does it would be a design flaw
if (tile == null) { if (tile == null) {
return; return;
} }
/// Don't care // Don't care
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
return; return;
@ -107,11 +100,11 @@ public class RoomUserWalkEvent extends MessageHandler {
switch (bed.getRotation()) { switch (bed.getRotation()) {
case 0: case 0:
case 4: case 4:
pillow = room.getLayout().getTile((short)x, bed.getY()); pillow = room.getLayout().getTile((short) x, bed.getY());
break; break;
case 2: case 2:
case 8: case 8:
pillow = room.getLayout().getTile(bed.getX(), (short)y); pillow = room.getLayout().getTile(bed.getX(), (short) y);
break; break;
} }
@ -122,7 +115,7 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
/// This is where we set the end location and begin finding a path // This is where we set the end location and begin finding a path
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
roomUnit.setGoalLocation(tile); roomUnit.setGoalLocation(tile);
} }