🆙 Cleanup code Banzai
This commit is contained in:
parent
0c4d9ac939
commit
25c2c06116
@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
|
|||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -47,13 +46,7 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
// Determine if the user is riding a pet
|
// Determine if the user is riding a pet
|
||||||
final boolean isRiding = isUserRiding();
|
final boolean isRiding = isUserRiding();
|
||||||
final Habbo rider = isRiding ? room.getHabbo(roomUnit) : null;
|
final Habbo rider = isRiding ? room.getHabbo(roomUnit) : null;
|
||||||
final RoomUnit petUnit;
|
final RoomUnit petUnit = isRiding && rider != null ? rider.getHabboInfo().getRiding().getRoomUnit() : null;
|
||||||
|
|
||||||
if (rider != null && rider.getHabboInfo().getRiding() != null) {
|
|
||||||
petUnit = rider.getHabboInfo().getRiding().getRoomUnit();
|
|
||||||
} else {
|
|
||||||
petUnit = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move the pet onto the teleport tile before teleporting
|
// Move the pet onto the teleport tile before teleporting
|
||||||
if (petUnit != null) {
|
if (petUnit != null) {
|
||||||
@ -70,7 +63,7 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
// Get correct Z-height
|
// Get correct Z-height
|
||||||
final double baseZ = targetTeleporter.getZ();
|
final double baseZ = targetTeleporter.getZ();
|
||||||
final double finalPetZ = baseZ;
|
final double finalPetZ = baseZ;
|
||||||
final double finalRiderZ = baseZ + (isRiding ? 1 : 0); // Rider stays above pet if riding
|
final double finalRiderZ = baseZ + 1; // Rider stays above pet if riding
|
||||||
|
|
||||||
// Delay to ensure the pet has reached the teleport tile
|
// Delay to ensure the pet has reached the teleport tile
|
||||||
Emulator.getThreading().run(() -> {
|
Emulator.getThreading().run(() -> {
|
||||||
@ -86,24 +79,9 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
petUnit.setHeadRotation(roomUnit.getHeadRotation());
|
petUnit.setHeadRotation(roomUnit.getHeadRotation());
|
||||||
|
|
||||||
// Re-enable walking after teleportation
|
// Re-enable walking after teleportation
|
||||||
Emulator.getThreading().run(() -> {
|
enableWalkingAndUpdateTeleporters(roomUnit, petUnit, 650);
|
||||||
roomUnit.setCanWalk(true);
|
|
||||||
petUnit.setCanWalk(true);
|
|
||||||
|
|
||||||
// Update teleporter states
|
|
||||||
if ("1".equals(initialTeleporter.getExtradata())) {
|
|
||||||
initialTeleporter.setExtradata("0");
|
|
||||||
room.updateItemState(initialTeleporter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("1".equals(targetTeleporter.getExtradata())) {
|
|
||||||
targetTeleporter.setExtradata("0");
|
|
||||||
room.updateItemState(targetTeleporter);
|
|
||||||
}
|
|
||||||
}, 650); // Delay to ensure smooth transition
|
|
||||||
}, 1000); // Increased delay to ensure pet reaches the teleport tile
|
}, 1000); // Increased delay to ensure pet reaches the teleport tile
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// If not riding, proceed with teleportation for the rider only
|
// If not riding, proceed with teleportation for the rider only
|
||||||
roomUnit.setRotation(this.newRotation);
|
roomUnit.setRotation(this.newRotation);
|
||||||
|
|
||||||
@ -114,20 +92,7 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
room.teleportRoomUnitToLocation(roomUnit, newLocation.x, newLocation.y, finalRiderZ);
|
room.teleportRoomUnitToLocation(roomUnit, newLocation.x, newLocation.y, finalRiderZ);
|
||||||
roomUnit.setZ(finalRiderZ);
|
roomUnit.setZ(finalRiderZ);
|
||||||
|
|
||||||
Emulator.getThreading().run(() -> {
|
enableWalkingAndUpdateTeleporters(roomUnit, null, 650);
|
||||||
roomUnit.setCanWalk(true);
|
|
||||||
|
|
||||||
// Update teleporter states
|
|
||||||
if ("1".equals(initialTeleporter.getExtradata())) {
|
|
||||||
initialTeleporter.setExtradata("0");
|
|
||||||
room.updateItemState(initialTeleporter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("1".equals(targetTeleporter.getExtradata())) {
|
|
||||||
targetTeleporter.setExtradata("0");
|
|
||||||
room.updateItemState(targetTeleporter);
|
|
||||||
}
|
|
||||||
}, 650); // Delay to ensure smooth transition
|
|
||||||
}, 700); // Standard delay for non-ridden teleportation
|
}, 700); // Standard delay for non-ridden teleportation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,4 +104,24 @@ public class BanzaiRandomTeleport implements Runnable {
|
|||||||
Habbo habbo = room.getHabbo(roomUnit);
|
Habbo habbo = room.getHabbo(roomUnit);
|
||||||
return habbo != null && habbo.getHabboInfo().getRiding() != null;
|
return habbo != null && habbo.getHabboInfo().getRiding() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableWalkingAndUpdateTeleporters(RoomUnit roomUnit, RoomUnit petUnit, int delay) {
|
||||||
|
Emulator.getThreading().run(() -> {
|
||||||
|
roomUnit.setCanWalk(true);
|
||||||
|
if (petUnit != null) {
|
||||||
|
petUnit.setCanWalk(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update teleporter states
|
||||||
|
if ("1".equals(initialTeleporter.getExtradata())) {
|
||||||
|
initialTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(initialTeleporter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("1".equals(targetTeleporter.getExtradata())) {
|
||||||
|
targetTeleporter.setExtradata("0");
|
||||||
|
room.updateItemState(targetTeleporter);
|
||||||
|
}
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user