2018-09-12 16:45:00 +00:00
|
|
|
package com.eu.habbo.habbohotel.commands;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
2022-02-19 19:24:48 -03:00
|
|
|
import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign;
|
2018-09-12 16:45:00 +00:00
|
|
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
|
|
|
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer;
|
2018-12-22 10:39:00 +00:00
|
|
|
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
|
2018-09-12 16:45:00 +00:00
|
|
|
|
2022-02-19 19:24:48 -03:00
|
|
|
import java.sql.Timestamp;
|
|
|
|
import java.time.Duration;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import static java.time.temporal.ChronoUnit.DAYS;
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public class CalendarCommand extends Command {
|
|
|
|
public CalendarCommand() {
|
2018-09-12 16:45:00 +00:00
|
|
|
super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 21:14:53 +03:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
|
2022-02-19 19:24:48 -03:00
|
|
|
String campaignName = Emulator.getConfig().getValue("hotel.calendar.default");
|
|
|
|
|
|
|
|
if(params.length > 1 && gameClient.getHabbo().hasPermission("cmd_calendar_staff")) {
|
|
|
|
campaignName = params[1];
|
|
|
|
}
|
|
|
|
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName);
|
|
|
|
if(campaign == null) return false;
|
|
|
|
int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant());
|
|
|
|
if(daysBetween >= 0) {
|
|
|
|
gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
|
|
|
|
}
|
2018-09-12 16:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|