mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 22:18:09 +00:00
DateHelper
This commit is contained in:
parent
f28926c645
commit
619b84027f
@ -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 {
|
|||||||
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 {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user