From 4fc5a484aef013573f181b00cd46cc27f9a93abb Mon Sep 17 00:00:00 2001 From: Snaiker Date: Sun, 27 Dec 2020 13:13:26 -0500 Subject: [PATCH] Fix #923 room host achievement Fixes issue #923 --- sqlupdates/2_4_0 to 3_0_BETA_1.sql | 2 ++ .../java/com/eu/habbo/habbohotel/rooms/Room.java | 14 ++++++++++++++ .../com/eu/habbo/habbohotel/rooms/RoomUnit.java | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/sqlupdates/2_4_0 to 3_0_BETA_1.sql b/sqlupdates/2_4_0 to 3_0_BETA_1.sql index cbd02a7b..b8fc2d61 100644 --- a/sqlupdates/2_4_0 to 3_0_BETA_1.sql +++ b/sqlupdates/2_4_0 to 3_0_BETA_1.sql @@ -104,6 +104,8 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.m -- OPTIONAL HC MIGRATION -- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP(); +INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.rooms.deco_hosting', '1'); + INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('easter_eggs.enabled', '1'); ALTER TABLE `bots` 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 4b30a0e3..d0704c82 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1,6 +1,7 @@ package com.eu.habbo.habbohotel.rooms; import com.eu.habbo.Emulator; +import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.VisitorBot; import com.eu.habbo.habbohotel.commands.CommandHandler; @@ -1221,6 +1222,19 @@ 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 bb078268..972030b8 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -73,6 +73,7 @@ public class RoomUnit { private int effectId; private int effectEndTimestamp; private ScheduledFuture moveBlockingTask; + private int timeInRoom; private int idleTimer; private Room room; @@ -93,6 +94,7 @@ public class RoomUnit { this.effectId = 0; this.isKicked = false; this.overridableTiles = new THashSet<>(); + this.timeInRoom = 0; } public void clearWalking() { @@ -639,6 +641,18 @@ 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++; }