mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 15:39:37 +00:00
Fix possible exploit with mcoin exchange
This commit is contained in:
parent
da3eb3d26c
commit
eac82f3c01
@ -13,14 +13,15 @@ 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()) {
|
||||
|
||||
if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user