mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Merge branch 'vuln-monsterplant' into 'dev'
Added RateLimit to ScratchPetEvent See merge request morningstar/Arcturus-Community!208
This commit is contained in:
commit
f4fd43eb89
@ -353,6 +353,19 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mayScratch() {
|
||||
// Monsterplant petting is available when:
|
||||
// ((energy / max_energy) < 0.98) = true
|
||||
// You can find the minimum deathTimestamp by solving (insert a timestamp for timestamp, solve for death_timestamp):
|
||||
// (((death_timestamp - timestamp) / 259200)) < 0.98
|
||||
// This information was found in the Habbo swf, com.sulake.habbo.ui.widget.infostand.InfoStandPetView.as
|
||||
// this._Str_2304("pettreat", ((_local_3 / _local_4) < 0.98));
|
||||
final float energy = this.getEnergy();
|
||||
final float energyMax = this.getMaxEnergy();
|
||||
|
||||
return ((energy / energyMax) < 0.98);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergy() {
|
||||
return MonsterplantPet.timeToLive;
|
||||
@ -368,13 +381,15 @@ public class MonsterplantPet extends Pet implements IPetLook {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scratched(Habbo habbo) {
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
|
||||
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
||||
this.addHappyness(10);
|
||||
this.addExperience(10);
|
||||
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
|
||||
this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
|
||||
public synchronized void scratched(Habbo habbo) {
|
||||
if (this.mayScratch()) {
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantTreater"), 5);
|
||||
this.setDeathTimestamp(Emulator.getIntUnixTimestamp() + MonsterplantPet.timeToLive);
|
||||
this.addHappyness(10);
|
||||
this.addExperience(10);
|
||||
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
|
||||
this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,19 +5,23 @@ import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
|
||||
public class ScratchPetEvent extends MessageHandler {
|
||||
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
int petId = this.packet.readInt();
|
||||
final int petId = this.packet.readInt();
|
||||
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null)
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
||||
final Pet pet = this.client.getHabbo().getHabboInfo().getCurrentRoom().getPet(petId);
|
||||
|
||||
if (pet != null) {
|
||||
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
||||
pet.scratched(this.client.getHabbo());
|
||||
}
|
||||
if (pet == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) {
|
||||
pet.scratched(this.client.getHabbo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user