From 619b84027fc4a675cc2c0e2a45e75ca6e5ba2f5b Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Wed, 27 Apr 2022 07:01:05 +0800 Subject: [PATCH] DateHelper --- .../emu/grasscutter/game/GenshinPlayer.java | 6 ++--- .../send/PacketCardProductRewardNotify.java | 24 +++++++++++++++++++ .../emu/grasscutter/utils/DateHelper.java | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/main/java/emu/grasscutter/server/packet/send/PacketCardProductRewardNotify.java diff --git a/src/main/java/emu/grasscutter/game/GenshinPlayer.java b/src/main/java/emu/grasscutter/game/GenshinPlayer.java index a4e5f265a..4c5afb88f 100644 --- a/src/main/java/emu/grasscutter/game/GenshinPlayer.java +++ b/src/main/java/emu/grasscutter/game/GenshinPlayer.java @@ -534,7 +534,7 @@ public class GenshinPlayer { remainCalendar.setTime(moonCardStartTime); remainCalendar.add(Calendar.DATE, moonCardDuration); Date theLastDay = remainCalendar.getTime(); - Date now = DateHelper.onlyYDM(new Date()); + Date now = DateHelper.onlyYearMonthDay(new Date()); return (int) ((theLastDay.getTime() - now.getTime()) / (24 * 60 * 60 * 1000)); // By copilot } @@ -547,7 +547,7 @@ public class GenshinPlayer { if (!moonCard) { moonCard = true; Date now = new Date(); - moonCardStartTime = DateHelper.onlyYDM(now); + moonCardStartTime = DateHelper.onlyYearMonthDay(now); moonCardDuration = 30; } else { moonCardDuration += 30; @@ -561,7 +561,7 @@ public class GenshinPlayer { if (!moonCard) { return; } - Date now = DateHelper.onlyYDM(new Date()); + Date now = DateHelper.onlyYearMonthDay(new Date()); if (moonCardGetTimes.contains(now)) { return; } diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketCardProductRewardNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketCardProductRewardNotify.java new file mode 100644 index 000000000..ca5a5fc00 --- /dev/null +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketCardProductRewardNotify.java @@ -0,0 +1,24 @@ +package emu.grasscutter.server.packet.send; + + +import emu.grasscutter.net.packet.GenshinPacket; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.CardProductRewardNotifyOuterClass.CardProductRewardNotify; + +public class PacketCardProductRewardNotify extends GenshinPacket { + + public PacketCardProductRewardNotify(int remainsDay) { + super(PacketOpcodes.CardProductRewardNotify); + + CardProductRewardNotify proto = CardProductRewardNotify.newBuilder() + .setProductId("ys_chn_blessofmoon_tier5") + .setHcoin(90) + .setRemainDays(remainsDay) + .build(); + + // Hard code Product id keep cool 😎 + + this.setData(proto); + } + +} diff --git a/src/main/java/emu/grasscutter/utils/DateHelper.java b/src/main/java/emu/grasscutter/utils/DateHelper.java index 5e5e4df03..7005d9457 100644 --- a/src/main/java/emu/grasscutter/utils/DateHelper.java +++ b/src/main/java/emu/grasscutter/utils/DateHelper.java @@ -4,7 +4,7 @@ import java.util.Date; import java.util.Calendar; public final class DateHelper { - public static Date onlyYDM(Date now) { + public static Date onlyYearMonthDay(Date now) { Calendar calendar = Calendar.getInstance(); calendar.setTime(now); calendar.set(Calendar.HOUR_OF_DAY, 0);