Commit 420f544d authored by Yazawazi's avatar Yazawazi
Browse files

DateHelper

parent aab66272
...@@ -534,7 +534,7 @@ public class GenshinPlayer { ...@@ -534,7 +534,7 @@ public class GenshinPlayer {
remainCalendar.setTime(moonCardStartTime); remainCalendar.setTime(moonCardStartTime);
remainCalendar.add(Calendar.DATE, moonCardDuration); remainCalendar.add(Calendar.DATE, moonCardDuration);
Date theLastDay = remainCalendar.getTime(); 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 return (int) ((theLastDay.getTime() - now.getTime()) / (24 * 60 * 60 * 1000)); // By copilot
} }
...@@ -547,7 +547,7 @@ public class GenshinPlayer { ...@@ -547,7 +547,7 @@ public class GenshinPlayer {
if (!moonCard) { if (!moonCard) {
moonCard = true; moonCard = true;
Date now = new Date(); Date now = new Date();
moonCardStartTime = DateHelper.onlyYDM(now); moonCardStartTime = DateHelper.onlyYearMonthDay(now);
moonCardDuration = 30; moonCardDuration = 30;
} else { } else {
moonCardDuration += 30; moonCardDuration += 30;
...@@ -561,7 +561,7 @@ public class GenshinPlayer { ...@@ -561,7 +561,7 @@ public class GenshinPlayer {
if (!moonCard) { if (!moonCard) {
return; return;
} }
Date now = DateHelper.onlyYDM(new Date()); Date now = DateHelper.onlyYearMonthDay(new Date());
if (moonCardGetTimes.contains(now)) { if (moonCardGetTimes.contains(now)) {
return; return;
} }
......
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);
}
}
...@@ -4,7 +4,7 @@ import java.util.Date; ...@@ -4,7 +4,7 @@ import java.util.Date;
import java.util.Calendar; import java.util.Calendar;
public final class DateHelper { public final class DateHelper {
public static Date onlyYDM(Date now) { public static Date onlyYearMonthDay(Date now) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(now); calendar.setTime(now);
calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.HOUR_OF_DAY, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment