From 9381bcf0e97c46806578be6f734203a9fb560575 Mon Sep 17 00:00:00 2001 From: Snaiker Date: Mon, 18 Nov 2024 21:26:27 +0000 Subject: [PATCH] Fix the Cycle on RoomDeco Hosting --- .../com/eu/habbo/habbohotel/rooms/Room.java | 28 ++++++++++--------- .../eu/habbo/habbohotel/rooms/RoomUnit.java | 14 ---------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 9bcea4ac..0d3ea36a 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -203,6 +203,7 @@ public class Room implements Comparable, ISerialize, Runnable { private volatile boolean loaded; private volatile boolean preLoaded; private int idleCycles; + private int idleHostingCycles; private volatile int unitCounter; private volatile int rollerSpeed; private final int muteTime = Emulator.getConfig().getInt("hotel.flood.mute.time", 30); @@ -368,6 +369,7 @@ public class Room implements Comparable, ISerialize, Runnable { } this.idleCycles = 0; + this.idleHostingCycles = 0; this.loaded = true; this.roomCycleTask = Emulator.getThreading().getService().scheduleAtFixedRate(this, 500, 500, TimeUnit.MILLISECONDS); @@ -1209,6 +1211,19 @@ public class Room implements Comparable, ISerialize, Runnable { task.cycle(this); } + if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting")) { + if (this.idleHostingCycles < 120) { + this.idleHostingCycles++; + } else { + this.idleHostingCycles = 0; + + int amount = (int) this.currentHabbos.values().stream().filter(habbo -> habbo.getHabboInfo().getId() != this.ownerId).count(); + if (amount > 0) { + AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting"), amount); + } + } + } + if (!this.currentHabbos.isEmpty()) { this.idleCycles = 0; @@ -1267,19 +1282,6 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (Emulator.getConfig().getBoolean("hotel.rooms.deco_hosting")) { - //Check if the user isn't the owner id - if (this.ownerId != habbo.getHabboInfo().getId()) { - //Check if the time already have 1 minute (120 / 2 = 60s) - if (habbo.getRoomUnit().getTimeInRoom() >= 120) { - AchievementManager.progressAchievement(this.ownerId, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHosting")); - habbo.getRoomUnit().resetTimeInRoom(); - } else { - habbo.getRoomUnit().increaseTimeInRoom(); - } - } - } - if (habbo.getHabboStats().mutedBubbleTracker && habbo.getHabboStats().allowTalk()) { habbo.getHabboStats().mutedBubbleTracker = false; this.sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose()); diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 9e1ad74e..52d4feb4 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -73,7 +73,6 @@ public class RoomUnit { private int effectId; private int effectEndTimestamp; private ScheduledFuture moveBlockingTask; - private int timeInRoom; private int idleTimer; private Room room; @@ -94,7 +93,6 @@ public class RoomUnit { this.effectId = 0; this.isKicked = false; this.overridableTiles = new THashSet<>(); - this.timeInRoom = 0; } public void clearWalking() { @@ -645,18 +643,6 @@ public class RoomUnit { this.walkTimeOut = walkTimeOut; } - public void increaseTimeInRoom() { - this.timeInRoom++; - } - - public int getTimeInRoom() { - return this.timeInRoom; - } - - public void resetTimeInRoom() { - this.timeInRoom = 0; - } - public void increaseIdleTimer() { this.idleTimer++; }