mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +01:00
Merge branch 'calendar-fix' into 'dev'
Fix calendar timestamp on mariadb See merge request morningstar/Arcturus-Community!506
This commit is contained in:
commit
10f2d6d98e
@ -22,6 +22,7 @@ CREATE TABLE `messenger_categories` (
|
|||||||
-- Set an ID (int) from category list items
|
-- Set an ID (int) from category list items
|
||||||
ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since;
|
ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since;
|
||||||
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for calendar_campaigns
|
-- Table structure for calendar_campaigns
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -30,18 +31,13 @@ CREATE TABLE `calendar_campaigns` (
|
|||||||
`id` int NOT NULL AUTO_INCREMENT,
|
`id` int NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(255) NOT NULL DEFAULT '',
|
`name` varchar(255) NOT NULL DEFAULT '',
|
||||||
`image` varchar(255) NOT NULL DEFAULT '',
|
`image` varchar(255) NOT NULL DEFAULT '',
|
||||||
`start_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
`start_timestamp` int NOT NULL DEFAULT '0',
|
||||||
`total_days` int NOT NULL DEFAULT '30',
|
`total_days` int NOT NULL DEFAULT '30',
|
||||||
`lock_expired` enum('1','0') NOT NULL DEFAULT '1',
|
`lock_expired` enum('1','0') NOT NULL DEFAULT '1',
|
||||||
`enabled` enum('1','0') NOT NULL DEFAULT '1',
|
`enabled` enum('1','0') NOT NULL DEFAULT '1',
|
||||||
UNIQUE KEY `id` (`id`)
|
UNIQUE KEY `id` (`id`)
|
||||||
);
|
);
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- Records of calendar_campaigns
|
|
||||||
-- ----------------------------
|
|
||||||
INSERT INTO `calendar_campaigns` VALUES ('1', 'test', '', '2022-02-09 16:49:13', '31', '1', '1');
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for calendar_rewards
|
-- Table structure for calendar_rewards
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@ -57,12 +53,23 @@ CREATE TABLE `calendar_rewards` (
|
|||||||
`points_type` int NOT NULL DEFAULT '0',
|
`points_type` int NOT NULL DEFAULT '0',
|
||||||
`badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
|
`badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
|
||||||
`item_id` int NOT NULL DEFAULT '0',
|
`item_id` int NOT NULL DEFAULT '0',
|
||||||
`subscription_type` enum('HABBO_CLUB') CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL,
|
|
||||||
`subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '',
|
`subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '',
|
||||||
`subscription_days` int NOT NULL DEFAULT '0',
|
`subscription_days` int NOT NULL DEFAULT '0',
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for calendar_rewards_claimed
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `calendar_rewards_claimed`;
|
||||||
|
CREATE TABLE `calendar_rewards_claimed` (
|
||||||
|
`user_id` int NOT NULL,
|
||||||
|
`campaign_id` int NOT NULL DEFAULT '0',
|
||||||
|
`day` int NOT NULL,
|
||||||
|
`reward_id` int NOT NULL,
|
||||||
|
`timestamp` int NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test');
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test');
|
||||||
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.pixels.hc_modifier', '2.0');
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.pixels.hc_modifier', '2.0');
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class CalendarCampaign {
|
|||||||
private final String name;
|
private final String name;
|
||||||
private final String image;
|
private final String image;
|
||||||
private Map<Integer , CalendarRewardObject> rewards = new THashMap<>();
|
private Map<Integer , CalendarRewardObject> rewards = new THashMap<>();
|
||||||
private final Timestamp start_timestamp;
|
private final Integer start_timestamp;
|
||||||
private final int total_days;
|
private final int total_days;
|
||||||
private final boolean lock_expired;
|
private final boolean lock_expired;
|
||||||
|
|
||||||
@ -20,12 +20,12 @@ public class CalendarCampaign {
|
|||||||
this.id = set.getInt("id");
|
this.id = set.getInt("id");
|
||||||
this.name = set.getString("name");
|
this.name = set.getString("name");
|
||||||
this.image = set.getString("image");
|
this.image = set.getString("image");
|
||||||
this.start_timestamp = set.getTimestamp("start_timestamp");
|
this.start_timestamp = set.getInt("start_timestamp");
|
||||||
this.total_days = set.getInt("total_days");
|
this.total_days = set.getInt("total_days");
|
||||||
this.lock_expired = set.getInt("lock_expired") == 1;
|
this.lock_expired = set.getInt("lock_expired") == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CalendarCampaign(int id, String name, String image, Timestamp start_timestamp, int total_days, boolean lock_expired) {
|
public CalendarCampaign(int id, String name, String image, Integer start_timestamp, int total_days, boolean lock_expired) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.image = image;
|
this.image = image;
|
||||||
@ -46,7 +46,7 @@ public class CalendarCampaign {
|
|||||||
return this.image;
|
return this.image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getStartTimestamp() {
|
public Integer getStartTimestamp() {
|
||||||
return this.start_timestamp;
|
return this.start_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class CalendarManager {
|
|||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||||
statement.setString(1, campaign.getName());
|
statement.setString(1, campaign.getName());
|
||||||
statement.setString(2, campaign.getImage());
|
statement.setString(2, campaign.getImage());
|
||||||
statement.setTimestamp(3, campaign.getStartTimestamp());
|
statement.setInt(3, campaign.getStartTimestamp());
|
||||||
statement.setInt(4, campaign.getTotalDays());
|
statement.setInt(4, campaign.getTotalDays());
|
||||||
statement.setBoolean(5, campaign.getLockExpired());
|
statement.setBoolean(5, campaign.getLockExpired());
|
||||||
int affectedRows = statement.executeUpdate();
|
int affectedRows = statement.executeUpdate();
|
||||||
@ -124,7 +124,7 @@ public class CalendarManager {
|
|||||||
int random = rewards.get(rand);
|
int random = rewards.get(rand);
|
||||||
CalendarRewardObject object = campaign.getRewards().get(random);
|
CalendarRewardObject object = campaign.getRewards().get(random);
|
||||||
if (object == null) return;
|
if (object == null) return;
|
||||||
int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant());
|
int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
|
||||||
if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) {
|
if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) {
|
||||||
int diff = (daysBetween - day);
|
int diff = (daysBetween - day);
|
||||||
if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) {
|
if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) {
|
||||||
@ -141,7 +141,7 @@ public class CalendarManager {
|
|||||||
statement.setInt(2, campaign.getId());
|
statement.setInt(2, campaign.getId());
|
||||||
statement.setInt(3, day);
|
statement.setInt(3, day);
|
||||||
statement.setInt(4, object.getId());
|
statement.setInt(4, object.getId());
|
||||||
statement.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
|
statement.setInt(5, Emulator.getIntUnixTimestamp());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
LOGGER.error("Caught SQL exception", e);
|
LOGGER.error("Caught SQL exception", e);
|
||||||
|
@ -27,7 +27,7 @@ public class CalendarCommand extends Command {
|
|||||||
}
|
}
|
||||||
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName);
|
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName);
|
||||||
if(campaign == null) return false;
|
if(campaign == null) return false;
|
||||||
int daysBetween = (int) DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant());
|
int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
|
||||||
if(daysBetween >= 0) {
|
if(daysBetween >= 0) {
|
||||||
gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
|
gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,10 @@ public class UsernameEvent extends MessageHandler {
|
|||||||
deleteStatement.execute();
|
deleteStatement.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
|
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
|
||||||
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default"));
|
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(Emulator.getConfig().getValue("hotel.calendar.default"));
|
||||||
if(campaign != null){
|
if(campaign != null){
|
||||||
long daysBetween = DAYS.between(campaign.getStartTimestamp().toInstant(), new Date().toInstant());
|
long daysBetween = DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
|
||||||
if(daysBetween >= 0) {
|
if(daysBetween >= 0) {
|
||||||
this.client.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
|
this.client.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), (int) daysBetween, this.client.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
|
||||||
this.client.sendResponse(new NuxAlertComposer("openView/calendar"));
|
this.client.sendResponse(new NuxAlertComposer("openView/calendar"));
|
||||||
|
Loading…
Reference in New Issue
Block a user