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/commands/AboutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java index ab4ece28..c38796ec 100644 --- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java +++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java @@ -3,7 +3,10 @@ package com.eu.habbo.habbohotel.commands; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.catalog.CatalogManager; import com.eu.habbo.habbohotel.gameclients.GameClient; +import com.eu.habbo.habbohotel.users.HabboManager; +import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; +import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -11,9 +14,12 @@ public class AboutCommand extends Command { public AboutCommand() { super(null, new String[]{"about", "info", "online", "server"}); } - + public static String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" + + "The Following people have all contributed to this emulator:\n" + + " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper"; @Override public boolean handle(GameClient gameClient, String[] params) { + Emulator.getRuntime().gc(); int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted(); @@ -42,9 +48,8 @@ public class AboutCommand extends Command { "Thanks for using Arcturus. Report issues on the forums. http://arcturus.wf \r\r" + " - The General"; - gameClient.getHabbo().alert(message); - + gameClient.sendResponse(new MessagesForYouComposer(Collections.singletonList(credits))); return true; } } diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java index d5e13742..afd7e035 100644 --- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java +++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java @@ -578,6 +578,7 @@ public class Pet implements ISerialize, Runnable { this.addHappyness(10); this.addExperience(10); this.addRespect(); + this.needsUpdate = true; if (habbo != null) { habbo.getHabboStats().petRespectPointsToGive--; 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/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 102ca77d..113736f1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -672,7 +672,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomPromotionMessageComposer(null, null)); } - if (room.getOwnerId() != habbo.getHabboInfo().getId()) { + if (room.getOwnerId() != habbo.getHabboInfo().getId() && !habbo.getHabboStats().visitedRoom(room.getId())) { AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomEntry")); } } @@ -916,6 +916,9 @@ public class RoomManager { statement.setInt(2, habbo.getHabboInfo().getId()); statement.setInt(3, (int) (habbo.getHabboStats().roomEnterTimestamp)); statement.execute(); + + if (!habbo.getHabboStats().visitedRoom(room.getId())) + habbo.getHabboStats().addVisitRoom(room.getId()); } catch (SQLException e) { LOGGER.error("Caught SQL exception", e); } 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++; } diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java index 603e9b9e..4463148f 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboStats.java @@ -41,6 +41,7 @@ public class HabboStats implements Runnable { private final THashMap recentPurchases; private final TIntArrayList favoriteRooms; private final TIntArrayList ignoredUsers; + private TIntArrayList roomsVists; public int achievementScore; public int respectPointsReceived; public int respectPointsGiven; @@ -106,6 +107,7 @@ public class HabboStats implements Runnable { this.recentPurchases = new THashMap<>(0); this.favoriteRooms = new TIntArrayList(0); this.ignoredUsers = new TIntArrayList(0); + this.roomsVists = new TIntArrayList(0); this.secretRecipes = new TIntArrayList(0); this.calendarRewardsClaimed = new TIntArrayList(0); @@ -236,6 +238,15 @@ public class HabboStats implements Runnable { } } } + + try (PreparedStatement loadRoomsVisit = set.getStatement().getConnection().prepareStatement("SELECT DISTINCT room_id FROM room_enter_log WHERE user_id = ?")) { + loadRoomsVisit.setInt(1, this.habboInfo.getId()); + try (ResultSet roomSet = loadRoomsVisit.executeQuery()) { + while (roomSet.next()) { + this.roomsVists.add(roomSet.getInt("room_id")); + } + } + } } private static HabboStats createNewStats(HabboInfo habboInfo) { @@ -622,6 +633,10 @@ public class HabboStats implements Runnable { return this.favoriteRooms.contains(roomId); } + public boolean visitedRoom(int roomId) { return this.roomsVists.contains(roomId); } + + public void addVisitRoom(int roomId) { this.roomsVists.add(roomId); } + public TIntArrayList getFavoriteRooms() { return this.favoriteRooms; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java index 03e9bd2a..739eabc9 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildDeleteEvent.java @@ -2,11 +2,15 @@ package com.eu.habbo.messages.incoming.guilds; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; +import com.eu.habbo.habbohotel.guilds.GuildMember; import com.eu.habbo.habbohotel.permissions.Permission; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer; import com.eu.habbo.messages.outgoing.guilds.RemoveGuildFromRoomComposer; import com.eu.habbo.messages.outgoing.rooms.RoomDataComposer; import com.eu.habbo.plugin.events.guilds.GuildDeletedEvent; +import gnu.trove.set.hash.THashSet; public class GuildDeleteEvent extends MessageHandler { @Override @@ -18,6 +22,15 @@ public class GuildDeleteEvent extends MessageHandler { if (guild != null) { if (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_GUILD_ADMIN)) //TODO Add staff permission override. { + THashSet members = Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild.getId()); + + for (GuildMember member : members) { + Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(member.getUserId()); + if (habbo != null) + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) + habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose()); + } + Emulator.getGameEnvironment().getGuildManager().deleteGuild(guild); Emulator.getPluginManager().fireEvent(new GuildDeletedEvent(guild, this.client.getHabbo())); Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()).sendComposer(new RemoveGuildFromRoomComposer(guildId).compose()); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java index cd97c727..6f64afac 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java @@ -22,7 +22,7 @@ public class GuildRemoveFavoriteEvent extends MessageHandler { this.client.getHabbo().getHabboStats().guild = 0; if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) { - this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose()); + this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), null).compose()); } this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java index 7652c0da..7ee21067 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveMemberEvent.java @@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.messages.incoming.MessageHandler; +import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer; import com.eu.habbo.messages.outgoing.guilds.GuildInfoComposer; import com.eu.habbo.messages.outgoing.guilds.GuildRefreshMembersListComposer; import com.eu.habbo.plugin.events.guilds.GuildRemovedMemberEvent; @@ -44,8 +45,11 @@ public class GuildRemoveMemberEvent extends MessageHandler { if (habbo.getHabboStats().guild == guildId) habbo.getHabboStats().guild = 0; - if (room != null && habbo.getHabboInfo().getCurrentRoom() == room) { - room.refreshRightsForHabbo(habbo); + if (room != null) { + if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getRoomUnit() != null) + habbo.getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(habbo.getRoomUnit(), null).compose()); + if (habbo.getHabboInfo().getCurrentRoom() == room) + room.refreshRightsForHabbo(habbo); } habbo.getClient().sendResponse(new GuildInfoComposer(guild, habbo.getClient(), false, null)); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java index 4621c044..501b6901 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/pets/ScratchPetEvent.java @@ -1,5 +1,6 @@ package com.eu.habbo.messages.incoming.rooms.pets; +import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.pets.MonsterplantPet; import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.messages.incoming.MessageHandler; @@ -22,6 +23,9 @@ public class ScratchPetEvent extends MessageHandler { if (this.client.getHabbo().getHabboStats().petRespectPointsToGive > 0 || pet instanceof MonsterplantPet) { pet.scratched(this.client.getHabbo()); + + // Update the stats to the database. + Emulator.getThreading().run(pet); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java index 48d9c556..37df2118 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildFavoriteRoomUserUpdateComposer.java @@ -19,9 +19,9 @@ public class GuildFavoriteRoomUserUpdateComposer extends MessageComposer { protected ServerMessage composeInternal() { this.response.init(Outgoing.GuildFavoriteRoomUserUpdateComposer); this.response.appendInt(this.roomUnit.getId()); - this.response.appendInt(this.guild.getId()); - this.response.appendInt(this.guild.getState().state); - this.response.appendString(this.guild.getName()); + this.response.appendInt(this.guild != null ? this.guild.getId() : 0); + this.response.appendInt(this.guild != null ? this.guild.getState().state : 3); + this.response.appendString(this.guild != null ? this.guild.getName() : ""); return this.response; } }