Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/commands/CalendarCommand.java

39 lines
1.7 KiB
Java
Raw Normal View History

2018-09-12 18:45:00 +02:00
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
2022-02-19 23:24:48 +01:00
import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign;
2018-09-12 18:45:00 +02:00
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer;
2018-12-22 11:39:00 +01:00
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
2018-09-12 18:45:00 +02:00
2022-02-19 23:24:48 +01:00
import java.sql.Timestamp;
import java.time.Duration;
import java.util.Date;
import static java.time.temporal.ChronoUnit.DAYS;
2019-05-26 20:14:53 +02:00
public class CalendarCommand extends Command {
public CalendarCommand() {
2018-09-12 18:45:00 +02:00
super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";"));
}
@Override
2019-05-26 20:14:53 +02:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
2022-02-19 23:24:48 +01: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 18:45:00 +02:00
}
return true;
}
}