forked from MagicBane/Server
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
package engine.net.client.handlers; |
|
|
|
import engine.Enum; |
|
import engine.exception.MsgSendException; |
|
import engine.gameManager.DbManager; |
|
import engine.net.Dispatch; |
|
import engine.net.DispatchMessage; |
|
import engine.net.client.ClientConnection; |
|
import engine.net.client.msg.ClientNetMsg; |
|
import engine.net.client.msg.PetitionReceivedMsg; |
|
import engine.objects.Petition; |
|
import engine.objects.PlayerCharacter; |
|
|
|
public class PetitionReceivedMsgHandler extends AbstractClientMsgHandler { |
|
|
|
public PetitionReceivedMsgHandler() { |
|
super(PetitionReceivedMsg.class); |
|
} |
|
|
|
@Override |
|
protected boolean _handleNetMsg(ClientNetMsg msg, ClientConnection origin) throws MsgSendException { |
|
|
|
if (msg == null) |
|
return true; |
|
|
|
PetitionReceivedMsg petitionReceivedMsg = (PetitionReceivedMsg) msg; |
|
|
|
if (origin == null) |
|
return true; |
|
|
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
|
|
|
if (playerCharacter == null) |
|
return true; |
|
|
|
Petition petition = new Petition(msg, origin); |
|
|
|
if (petition == null) |
|
return false; |
|
|
|
try { |
|
// Write petition to database |
|
|
|
DbManager.PetitionQueries.WRITE_PETITION_TO_TABLE(petition); |
|
|
|
// Close the petition window |
|
|
|
if (petitionReceivedMsg.petition != 2) |
|
petitionReceivedMsg.petition = 4; |
|
|
|
petitionReceivedMsg.unknownByte01 = 0; |
|
petitionReceivedMsg.unknown04 = 0; |
|
|
|
Dispatch dispatch = Dispatch.borrow(playerCharacter, petitionReceivedMsg); |
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
} catch (Exception e) { |
|
return false; |
|
} |
|
return true; |
|
} |
|
}
|
|
|