Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
420f544d
Commit
420f544d
authored
Apr 27, 2022
by
Yazawazi
Browse files
DateHelper
parent
aab66272
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
420f544d
...
@@ -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
.
onlyY
DM
(
new
Date
());
Date
now
=
DateHelper
.
onlyY
earMonthDay
(
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
.
onlyY
DM
(
now
);
moonCardStartTime
=
DateHelper
.
onlyY
earMonthDay
(
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
.
onlyY
DM
(
new
Date
());
Date
now
=
DateHelper
.
onlyY
earMonthDay
(
new
Date
());
if
(
moonCardGetTimes
.
contains
(
now
))
{
if
(
moonCardGetTimes
.
contains
(
now
))
{
return
;
return
;
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketCardProductRewardNotify.java
0 → 100644
View file @
420f544d
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
);
}
}
src/main/java/emu/grasscutter/utils/DateHelper.java
View file @
420f544d
...
@@ -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
onlyY
DM
(
Date
now
)
{
public
static
Date
onlyY
earMonthDay
(
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment