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.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent;
import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler {
@Override
public void handle() throws Exception
{
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null)
{
int x = this.packet.readInt(); ///< Position X
int y = this.packet.readInt(); ///<Position Y
public void handle() throws Exception {
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
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();
/// Get Room Habbo object (Unique GUID?)
// Get Room Habbo object (Unique GUID?)
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)
return;
/// If habbo is being kicked dont calculate a new path
// If habbo is being kicked dont calculate a new path
if (roomUnit.isKicked)
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) {
habbo = (Habbo) roomUnit.getCacheable().get("control");
@ -47,34 +44,30 @@ public class RoomUserWalkEvent extends MessageHandler {
}
}
/// Get room unit?
// Get room unit?
roomUnit = habbo.getRoomUnit();
/// Get the room the habbo is in
// Get the room the habbo is in
Room room = habbo.getHabboInfo().getCurrentRoom();
try
{
/// 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 we are not teleporting calcualte a new path
if (!roomUnit.cmdTeleport)
{
/// Don't calculate a new path if we are on a horse
try {
// 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 we are not teleporting calcualte a new path
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))
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())
return;
if (room == null || room.getLayout() == null)
return;
/// Reset idle status
if (roomUnit.isIdle())
{
// Reset idle status
if (roomUnit.isIdle()) {
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
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);
/// 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) {
return;
}
/// Don't care
// Don't care
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
return;
@ -107,11 +100,11 @@ public class RoomUserWalkEvent extends MessageHandler {
switch (bed.getRotation()) {
case 0:
case 4:
pillow = room.getLayout().getTile((short)x, bed.getY());
pillow = room.getLayout().getTile((short) x, bed.getY());
break;
case 2:
case 8:
pillow = room.getLayout().getTile(bed.getX(), (short)y);
pillow = room.getLayout().getTile(bed.getX(), (short) y);
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)) {
roomUnit.setGoalLocation(tile);
}