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
d359e511
Commit
d359e511
authored
Apr 28, 2022
by
KingRainbow44
Browse files
Player events + mail receive event
parent
d7016138
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/Player.java
View file @
d359e511
...
@@ -38,6 +38,7 @@ import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
...
@@ -38,6 +38,7 @@ import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SocialShowAvatarInfoOuterClass
;
import
emu.grasscutter.net.proto.SocialShowAvatarInfoOuterClass
;
import
emu.grasscutter.server.event.game.PlayerQuitEvent
;
import
emu.grasscutter.server.event.game.PlayerQuitEvent
;
import
emu.grasscutter.server.event.player.PlayerReceiveMailEvent
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.*
;
import
emu.grasscutter.server.packet.send.*
;
...
@@ -726,9 +727,13 @@ public class Player {
...
@@ -726,9 +727,13 @@ public class Player {
public
List
<
Mail
>
getAllMail
()
{
return
this
.
mail
;
}
public
List
<
Mail
>
getAllMail
()
{
return
this
.
mail
;
}
public
void
sendMail
(
Mail
message
)
{
public
void
sendMail
(
Mail
message
)
{
// Call mail receive event.
PlayerReceiveMailEvent
event
=
new
PlayerReceiveMailEvent
(
this
,
message
);
event
.
call
();
if
(
event
.
isCanceled
())
return
;
message
=
event
.
getMessage
();
this
.
mail
.
add
(
message
);
this
.
mail
.
add
(
message
);
this
.
save
();
this
.
save
();
Grasscutter
.
getLogger
().
info
(
"Mail sent to user ["
+
this
.
getUid
()
+
":"
+
this
.
getNickname
()
+
"]!"
);
Grasscutter
.
getLogger
().
debug
(
"Mail sent to user ["
+
this
.
getUid
()
+
":"
+
this
.
getNickname
()
+
"]!"
);
if
(
this
.
isOnline
())
{
if
(
this
.
isOnline
())
{
this
.
sendPacket
(
new
PacketMailChangeNotify
(
this
,
message
));
this
.
sendPacket
(
new
PacketMailChangeNotify
(
this
,
message
));
}
// TODO: setup a way for the mail notification to show up when someone receives mail when they were offline
}
// TODO: setup a way for the mail notification to show up when someone receives mail when they were offline
...
...
src/main/java/emu/grasscutter/server/event/player/PlayerReceiveMailEvent.java
0 → 100644
View file @
d359e511
package
emu.grasscutter.server.event.player
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.event.Cancellable
;
import
emu.grasscutter.server.event.types.PlayerEvent
;
public
final
class
PlayerReceiveMailEvent
extends
PlayerEvent
implements
Cancellable
{
private
Mail
message
;
public
PlayerReceiveMailEvent
(
Player
player
,
Mail
message
)
{
super
(
player
);
this
.
message
=
message
;
}
public
void
setMessage
(
Mail
message
)
{
this
.
message
=
message
;
}
public
Mail
getMessage
()
{
return
this
.
message
;
}
}
src/main/java/emu/grasscutter/server/event/types/PlayerEvent.java
0 → 100644
View file @
d359e511
package
emu.grasscutter.server.event.types
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.server.event.Event
;
/**
* An event that is related to player interactions.
*/
public
abstract
class
PlayerEvent
extends
Event
{
protected
final
Player
player
;
public
PlayerEvent
(
Player
player
)
{
this
.
player
=
player
;
}
public
Player
getPlayer
()
{
return
this
.
player
;
}
}
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