|
|
@ -10,6 +10,7 @@ package engine.net.client.handlers; |
|
|
|
|
|
|
|
|
|
|
|
import engine.Enum; |
|
|
|
import engine.Enum; |
|
|
|
import engine.exception.MsgSendException; |
|
|
|
import engine.exception.MsgSendException; |
|
|
|
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.gameManager.SessionManager; |
|
|
|
import engine.gameManager.SessionManager; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.msg.BuyFromNPCMsg; |
|
|
|
import engine.net.client.msg.BuyFromNPCMsg; |
|
|
@ -26,6 +27,21 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { |
|
|
|
super(BuyFromNPCMsg.class); |
|
|
|
super(BuyFromNPCMsg.class); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Item createItemForPlayer(PlayerCharacter pc, int templateID) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Item item = new Item(templateID); |
|
|
|
|
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
|
|
|
|
item.ownerType = Enum.OwnerType.PlayerCharacter; |
|
|
|
|
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
item = DbManager.ItemQueries.PERSIST(item); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
|
|
|
|
|
|
|
@ -108,7 +124,7 @@ public class BuyFromNPCMsgHandler extends AbstractClientMsgHandler { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vendorItem = Item.createItemForPlayer(sourcePlayer, me.templateID); |
|
|
|
vendorItem = createItemForPlayer(sourcePlayer, me.templateID); |
|
|
|
|
|
|
|
|
|
|
|
if (vendorItem != null) { |
|
|
|
if (vendorItem != null) { |
|
|
|
// me.transferEnchants(buy);
|
|
|
|
// me.transferEnchants(buy);
|
|
|
|