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.
59 lines
2.2 KiB
59 lines
2.2 KiB
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . |
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· |
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ |
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ |
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ |
|
// Magicbane Emulator Project © 2013 - 2022 |
|
// www.magicbane.com |
|
|
|
package engine.net.client.handlers; |
|
|
|
import engine.Enum; |
|
import engine.exception.MsgSendException; |
|
import engine.net.Dispatch; |
|
import engine.net.DispatchMessage; |
|
import engine.net.client.ClientConnection; |
|
import engine.net.client.msg.ClientNetMsg; |
|
import engine.net.client.msg.TrainerInfoMsg; |
|
import engine.objects.NPC; |
|
import engine.objects.PlayerCharacter; |
|
|
|
public class TrainerInfoMsgHandler extends AbstractClientMsgHandler { |
|
|
|
public TrainerInfoMsgHandler() { |
|
super(TrainerInfoMsg.class); |
|
} |
|
|
|
@Override |
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
PlayerCharacter playerCharacter = origin.getPlayerCharacter(); |
|
|
|
// Member variable declaration |
|
|
|
TrainerInfoMsg msg; |
|
|
|
// Member variable assignment |
|
|
|
msg = (TrainerInfoMsg) baseMsg; |
|
|
|
NPC npc = NPC.getFromCache(msg.getObjectID()); |
|
float sellPercent = 1; |
|
|
|
if (npc != null) { |
|
|
|
if (origin.getPlayerCharacter() != null) |
|
sellPercent = npc.getSellPercent(origin.getPlayerCharacter()); |
|
else |
|
sellPercent = npc.getSellPercent(); |
|
|
|
msg.setTrainPercent(sellPercent); //TrainMsg.getTrainPercent(npc)); |
|
} |
|
|
|
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg); |
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
return true; |
|
} |
|
|
|
} |