mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
Merge branch '3-picking-up-pets' into 'dev'
Resolve "Picking up pets" See merge request morningstar/Arcturus-Community!9
This commit is contained in:
commit
6402c7f89c
@ -157,7 +157,7 @@ public class TestCommand extends Command
|
|||||||
((MonsterplantPet) pet).setPubliclyBreedable(false);
|
((MonsterplantPet) pet).setPubliclyBreedable(false);
|
||||||
((MonsterplantPet) pet).setCanBreed(true);
|
((MonsterplantPet) pet).setCanBreed(true);
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose());
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetStatusUpdateComposer(pet).compose());
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetInformationComposer(pet, gameClient.getHabbo().getHabboInfo().getCurrentRoom()).compose());
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new PetInformationComposer(pet, gameClient.getHabbo().getHabboInfo().getCurrentRoom(), gameClient.getHabbo()).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1023,6 +1023,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
}
|
}
|
||||||
this.games.clear();
|
this.games.clear();
|
||||||
|
|
||||||
|
removeAllPets(ownerId);
|
||||||
|
|
||||||
synchronized (this.roomItems)
|
synchronized (this.roomItems)
|
||||||
{
|
{
|
||||||
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
|
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
|
||||||
@ -1086,22 +1088,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TIntObjectIterator<Pet> petIterator = this.currentPets.iterator();
|
|
||||||
for (int i = this.currentPets.size(); i-- > 0; )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
petIterator.advance();
|
|
||||||
petIterator.value().needsUpdate = true;
|
|
||||||
Emulator.getThreading().run(petIterator.value());
|
|
||||||
}
|
|
||||||
catch (NoSuchElementException e)
|
|
||||||
{
|
|
||||||
Emulator.getLogging().logErrorLine(e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.currentBots.clear();
|
this.currentBots.clear();
|
||||||
this.currentPets.clear();
|
this.currentPets.clear();
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
@ -2386,6 +2372,48 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
public void setAllowPets(boolean allowPets)
|
public void setAllowPets(boolean allowPets)
|
||||||
{
|
{
|
||||||
this.allowPets = allowPets;
|
this.allowPets = allowPets;
|
||||||
|
if(!allowPets) {
|
||||||
|
removeAllPets(ownerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllPets() {
|
||||||
|
removeAllPets(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all pets from the room except if the owner id is excludeUserId
|
||||||
|
* @param excludeUserId Habbo id to keep pets
|
||||||
|
*/
|
||||||
|
public void removeAllPets(int excludeUserId) {
|
||||||
|
ArrayList<Pet> removedPets = new ArrayList<>();
|
||||||
|
synchronized (this.currentPets) {
|
||||||
|
for (Pet pet : this.currentPets.valueCollection()) {
|
||||||
|
try {
|
||||||
|
if (pet.getUserId() != excludeUserId) {
|
||||||
|
pet.setRoom(null);
|
||||||
|
removedPets.add(pet);
|
||||||
|
this.sendComposer(new RoomUserRemoveComposer(pet.getRoomUnit()).compose());
|
||||||
|
|
||||||
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(pet.getUserId());
|
||||||
|
if (habbo != null) {
|
||||||
|
habbo.getInventory().getPetsComponent().addPet(pet);
|
||||||
|
habbo.getClient().sendResponse(new AddPetComposer(pet));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pet.needsUpdate = true;
|
||||||
|
pet.run();
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
Emulator.getLogging().logErrorLine(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Pet pet : removedPets) {
|
||||||
|
this.currentPets.remove(pet.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowPetsEat(boolean allowPetsEat)
|
public void setAllowPetsEat(boolean allowPetsEat)
|
||||||
@ -3201,6 +3229,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
|
|||||||
trade.stopTrade(habbo);
|
trade.stopTrade(habbo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (habbo.getHabboInfo().getId() != this.ownerId)
|
||||||
|
{
|
||||||
|
this.pickupPetsForHabbo(habbo);
|
||||||
|
}
|
||||||
|
|
||||||
this.updateDatabaseUserCount();
|
this.updateDatabaseUserCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,10 +1099,6 @@ public class RoomManager
|
|||||||
{
|
{
|
||||||
habbo.getRoomUnit().setPathFinderRoom(null);
|
habbo.getRoomUnit().setPathFinderRoom(null);
|
||||||
|
|
||||||
if (!room.isOwner(habbo))
|
|
||||||
{
|
|
||||||
room.pickupPetsForHabbo(habbo);
|
|
||||||
}
|
|
||||||
this.logExit(habbo);
|
this.logExit(habbo);
|
||||||
room.removeHabbo(habbo);
|
room.removeHabbo(habbo);
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public class RequestPetInformationEvent extends MessageHandler
|
|||||||
|
|
||||||
if(pet != null)
|
if(pet != null)
|
||||||
{
|
{
|
||||||
this.client.sendResponse(new PetInformationComposer(pet, room));
|
this.client.sendResponse(new PetInformationComposer(pet, room, this.client.getHabbo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.eu.habbo.messages.outgoing.rooms.pets;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.pets.*;
|
import com.eu.habbo.habbohotel.pets.*;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
@ -11,11 +12,13 @@ public class PetInformationComposer extends MessageComposer
|
|||||||
{
|
{
|
||||||
private final Pet pet;
|
private final Pet pet;
|
||||||
private final Room room;
|
private final Room room;
|
||||||
|
private final Habbo requestingHabbo;
|
||||||
|
|
||||||
public PetInformationComposer(Pet pet, Room room)
|
public PetInformationComposer(Pet pet, Room room, Habbo requestingHabbo)
|
||||||
{
|
{
|
||||||
this.pet = pet;
|
this.pet = pet;
|
||||||
this.room = room;
|
this.room = room;
|
||||||
|
this.requestingHabbo = requestingHabbo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,10 +57,10 @@ public class PetInformationComposer extends MessageComposer
|
|||||||
this.response.appendString(this.room.getFurniOwnerName(this.pet.getUserId())); //Owner name
|
this.response.appendString(this.room.getFurniOwnerName(this.pet.getUserId())); //Owner name
|
||||||
|
|
||||||
this.response.appendInt(this.pet instanceof MonsterplantPet ? ((MonsterplantPet) this.pet).getRarity() : 0);
|
this.response.appendInt(this.pet instanceof MonsterplantPet ? ((MonsterplantPet) this.pet).getRarity() : 0);
|
||||||
this.response.appendBoolean(this.pet instanceof RideablePet && ((RideablePet) this.pet).hasSaddle());
|
this.response.appendBoolean(this.pet instanceof RideablePet && this.requestingHabbo != null && (((RideablePet) this.pet).getRider() == null || this.pet.getUserId() == this.requestingHabbo.getHabboInfo().getId()) && ((RideablePet) this.pet).hasSaddle()); // can ride
|
||||||
this.response.appendBoolean(this.pet instanceof RideablePet && ((RideablePet) this.pet).getRider() != null);
|
this.response.appendBoolean(this.pet instanceof RideablePet && ((RideablePet) this.pet).getRider() != null && this.requestingHabbo != null && ((RideablePet) this.pet).getRider().getHabboInfo().getId() == this.requestingHabbo.getHabboInfo().getId()); // is current user riding
|
||||||
this.response.appendInt(0);
|
this.response.appendInt(0);
|
||||||
this.response.appendInt(this.pet instanceof RideablePet && ((RideablePet) this.pet).anyoneCanRide() ? 1 : 0);
|
this.response.appendInt(this.pet instanceof RideablePet && ((RideablePet) this.pet).anyoneCanRide() ? 1 : 0); // anyone can ride
|
||||||
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).canBreed()); //State Grown
|
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).canBreed()); //State Grown
|
||||||
this.response.appendBoolean(!(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isFullyGrown())); //unknown 1
|
this.response.appendBoolean(!(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isFullyGrown())); //unknown 1
|
||||||
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isDead()); //Dead
|
this.response.appendBoolean(this.pet instanceof MonsterplantPet && ((MonsterplantPet) this.pet).isDead()); //Dead
|
||||||
|
@ -51,7 +51,7 @@ public class RoomPetHorseFigureComposer extends MessageComposer
|
|||||||
this.response.appendInt(this.pet.getHairColor());
|
this.response.appendInt(this.pet.getHairColor());
|
||||||
}
|
}
|
||||||
this.response.appendBoolean(this.pet.hasSaddle());
|
this.response.appendBoolean(this.pet.hasSaddle());
|
||||||
this.response.appendBoolean(this.pet.anyoneCanRide());
|
this.response.appendBoolean(false); // this.pet.anyoneCanRide()
|
||||||
return this.response;
|
return this.response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user