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
da3eb3d2
Commit
da3eb3d2
authored
May 01, 2022
by
Kinesis
Committed by
Melledy
Apr 30, 2022
Browse files
implement McoinExchange packet Handler
parent
fb547c17
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerMcoinExchangeHcoinReq.java
0 → 100644
View file @
da3eb3d2
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.McoinExchangeHcoinReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketMcoinExchangeHcoinRsp
;
@Opcodes
(
PacketOpcodes
.
McoinExchangeHcoinReq
)
public
class
HandlerMcoinExchangeHcoinReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
McoinExchangeHcoinReqOuterClass
.
McoinExchangeHcoinReq
exchangeReq
=
McoinExchangeHcoinReqOuterClass
.
McoinExchangeHcoinReq
.
parseFrom
(
payload
);
if
(
session
==
null
)
{
return
;
}
else
if
(
session
.
getPlayer
().
getCrystals
()
<
exchangeReq
.
getMCoinNum
())
{
return
;
}
session
.
getPlayer
().
setCrystals
(
session
.
getPlayer
().
getCrystals
()
-
exchangeReq
.
getMCoinNum
());
session
.
getPlayer
().
setPrimogems
(
session
.
getPlayer
().
getPrimogems
()
+
exchangeReq
.
getHCoinNum
());
session
.
getPlayer
().
save
();
session
.
send
(
new
PacketMcoinExchangeHcoinRsp
(
session
.
getPlayer
().
getCrystals
(),
session
.
getPlayer
().
getPrimogems
()));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketMcoinExchangeHcoinRsp.java
0 → 100644
View file @
da3eb3d2
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.McoinExchangeHcoinRspOuterClass
;
public
class
PacketMcoinExchangeHcoinRsp
extends
BasePacket
{
public
PacketMcoinExchangeHcoinRsp
(
int
mcoin
,
int
hcoin
)
{
super
(
PacketOpcodes
.
McoinExchangeHcoinRsp
);
McoinExchangeHcoinRspOuterClass
.
McoinExchangeHcoinRsp
mcoinExchangeHcoinRsp
=
McoinExchangeHcoinRspOuterClass
.
McoinExchangeHcoinRsp
.
newBuilder
()
.
setMCoinNum
(
mcoin
)
.
setHCoinNum
(
hcoin
).
build
();
this
.
setData
(
mcoinExchangeHcoinRsp
);
}
}
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