mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Avatar will walk to an adjacent tile before scratching the pet #1886
This commit is contained in:
parent
0f3ca7807e
commit
22810c13e6
@ -3,7 +3,14 @@ package com.eu.habbo.messages.incoming.rooms.pets;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
|
import com.eu.habbo.habbohotel.pets.MonsterplantPet;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class RespectPetEvent extends MessageHandler {
|
public class RespectPetEvent extends MessageHandler {
|
||||||
|
|
||||||
@ -11,21 +18,29 @@ public class RespectPetEvent extends MessageHandler {
|
|||||||
public void handle() {
|
public void handle() {
|
||||||
final int petId = this.packet.readInt();
|
final int petId = this.packet.readInt();
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) {
|
final Habbo habbo = this.client.getHabbo();
|
||||||
return;
|
if (habbo == null) { return; }
|
||||||
}
|
|
||||||
|
|
||||||
final Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
final Room room = habbo.getHabboInfo().getCurrentRoom();
|
||||||
|
if (room == null) { return; }
|
||||||
|
|
||||||
if (pet == null) {
|
final Pet pet = room.getPet(petId);
|
||||||
return;
|
if (pet == null) { return; }
|
||||||
}
|
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboStats().getPetRespectPointsToGive() > 0 || pet instanceof MonsterplantPet) {
|
if (habbo.getHabboStats().getPetRespectPointsToGive() > 0 || pet instanceof MonsterplantPet) {
|
||||||
pet.scratched(this.client.getHabbo());
|
|
||||||
|
|
||||||
// Update the stats to the database.
|
List<Runnable> tasks = new ArrayList<>();
|
||||||
Emulator.getThreading().run(pet);
|
tasks.add(() -> {
|
||||||
|
pet.scratched(habbo);
|
||||||
|
Emulator.getThreading().run(pet);
|
||||||
|
});
|
||||||
|
|
||||||
|
RoomTile tile = habbo.getRoomUnit().getClosestAdjacentTile(pet.getRoomUnit().getX(), pet.getRoomUnit().getY(), true);
|
||||||
|
if(tile != null) {
|
||||||
|
habbo.getRoomUnit().setGoalLocation(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
Emulator.getThreading().run(new RoomUnitWalkToLocation(habbo.getRoomUnit(), tile, room, tasks, tasks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user