Fix flagme

This commit is contained in:
brenoepic 2022-04-15 18:59:06 -03:00 committed by Harmonic
parent 8d89f2034d
commit 5b869f35b4

View File

@ -1,6 +1,9 @@
package com.eu.habbo.messages.incoming.handshake; package com.eu.habbo.messages.incoming.handshake;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign;
import com.eu.habbo.habbohotel.catalog.TargetOffer;
import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem; import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
import com.eu.habbo.habbohotel.modtool.ModToolSanctions; import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
@ -14,16 +17,19 @@ import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
import com.eu.habbo.messages.NoAuthMessage; import com.eu.habbo.messages.NoAuthMessage;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer;
import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAccountInfoComposer; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterAccountInfoComposer;
import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameListComposer; import com.eu.habbo.messages.outgoing.gamecenter.GameCenterGameListComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer; import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer;
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
import com.eu.habbo.messages.outgoing.handshake.EnableNotificationsComposer; import com.eu.habbo.messages.outgoing.handshake.EnableNotificationsComposer;
import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer; import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer;
import com.eu.habbo.messages.outgoing.handshake.AvailabilityStatusMessageComposer; import com.eu.habbo.messages.outgoing.handshake.AvailabilityStatusMessageComposer;
import com.eu.habbo.messages.outgoing.handshake.PingComposer; import com.eu.habbo.messages.outgoing.handshake.PingComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryAchievementsComposer; import com.eu.habbo.messages.outgoing.inventory.BadgePointLimitsComposer;
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer; import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer; import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer;
import com.eu.habbo.messages.outgoing.modtool.ModToolComposer; import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
@ -38,15 +44,22 @@ import gnu.trove.map.hash.THashMap;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import static java.time.temporal.ChronoUnit.DAYS;
@NoAuthMessage @NoAuthMessage
public class SecureLoginEvent extends MessageHandler { public class SecureLoginEvent extends MessageHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(SecureLoginEvent.class); private static final Logger LOGGER = LoggerFactory.getLogger(SecureLoginEvent.class);
@Override @Override
public void handle() throws Exception { public void handle() throws Exception {
if (!this.client.getChannel().isOpen()) { if (!this.client.getChannel().isOpen()) {
@ -123,6 +136,70 @@ public class SecureLoginEvent extends MessageHandler {
else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0) else if (!this.client.getHabbo().getHabboStats().nux || Emulator.getConfig().getBoolean("retro.style.homeroom") && RoomManager.HOME_ROOM_ID > 0)
roomIdToEnter = RoomManager.HOME_ROOM_ID; roomIdToEnter = RoomManager.HOME_ROOM_ID;
boolean calendar = false;
if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login"))) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login"));
calendar = true;
} else {
int previousOnline = (int)this.client.getHabbo().getHabboStats().cache.get("previousOnline");
long daysBetween = ChronoUnit.DAYS.between(new Date((long) previousOnline * 1000L).toInstant(), new Date().toInstant());
Date lastLogin = new Date(previousOnline);
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.DAY_OF_YEAR, -1);
Calendar c2 = Calendar.getInstance();
c2.setTime(lastLogin);
if (daysBetween == 1) {
if (this.client.getHabbo().getHabboStats().getAchievementProgress().get(Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login")) == this.client.getHabbo().getHabboStats().loginStreak) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Login"));
}
this.client.getHabbo().getHabboStats().loginStreak++;
calendar = true;
} else if (daysBetween >= 1) {
calendar = true;
} else {
if (((lastLogin.getTime() / 1000) - Emulator.getIntUnixTimestamp()) > 86400) {
this.client.getHabbo().getHabboStats().loginStreak = 0;
}
}
}
if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"))) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"), 0);
} else {
int daysRegistered = ((Emulator.getIntUnixTimestamp() - this.client.getHabbo().getHabboInfo().getAccountCreated()) / 86400);
int days = this.client.getHabbo().getHabboStats().getAchievementProgress(
Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration")
);
if (daysRegistered - days > 0) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RegistrationDuration"), daysRegistered - days);
}
}
if (!this.client.getHabbo().getHabboStats().getAchievementProgress().containsKey(Emulator.getGameEnvironment().getAchievementManager().getAchievement("TraderPass"))) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("TraderPass"));
}
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement achievementQueueStatement = connection.prepareStatement("SELECT * FROM users_achievements_queue WHERE user_id = ?")) {
achievementQueueStatement.setInt(1, this.client.getHabbo().getHabboInfo().getId());
try (ResultSet achievementSet = achievementQueueStatement.executeQuery()) {
while (achievementSet.next()) {
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievementSet.getInt("achievement_id")), achievementSet.getInt("amount"));
}
}
try (PreparedStatement deleteStatement = connection.prepareStatement("DELETE FROM users_achievements_queue WHERE user_id = ?")) {
deleteStatement.setInt(1, this.client.getHabbo().getHabboInfo().getId());
deleteStatement.execute();
}
}
messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), roomIdToEnter).compose()); messages.add(new UserHomeRoomComposer(this.client.getHabbo().getHabboInfo().getHomeRoom(), roomIdToEnter).compose());
messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose()); messages.add(new UserEffectsListComposer(habbo, this.client.getHabbo().getInventory().getEffectsComponent().effects.values()).compose());
messages.add(new UserClothesComposer(this.client.getHabbo()).compose()); messages.add(new UserClothesComposer(this.client.getHabbo()).compose());
@ -147,11 +224,31 @@ public class SecureLoginEvent extends MessageHandler {
messages.add(new ModToolComposer(this.client.getHabbo()).compose()); messages.add(new ModToolComposer(this.client.getHabbo()).compose());
} }
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default"));
if (campaign != null) {
long daysBetween = DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
if (daysBetween >= 0) {
messages.add(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()).compose());
if(Emulator.getConfig().getBoolean("hotel.login.show.calendar", false)) {
messages.add(new NuxAlertComposer("openView/calendar").compose());
}
}
}
if (TargetOffer.ACTIVE_TARGET_OFFER_ID > 0) {
TargetOffer offer = Emulator.getGameEnvironment().getCatalogManager().getTargetOffer(TargetOffer.ACTIVE_TARGET_OFFER_ID);
if (offer != null) {
messages.add(new TargetedOfferComposer(this.client.getHabbo(), offer).compose());
}
}
this.client.sendResponses(messages); this.client.sendResponses(messages);
//Hardcoded //Hardcoded
//this.client.sendResponse(new ForumsTestComposer()); //this.client.sendResponse(new ForumsTestComposer());
this.client.sendResponse(new InventoryAchievementsComposer()); this.client.sendResponse(new BadgePointLimitsComposer());
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();