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.
60 lines
2.4 KiB
60 lines
2.4 KiB
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . |
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· |
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ |
|
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ |
|
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ |
|
// Magicbane Emulator Project © 2013 - 2022 |
|
// www.magicbane.com |
|
|
|
package engine.net.client.handlers; |
|
|
|
import engine.exception.MsgSendException; |
|
import engine.gameManager.ChatManager; |
|
import engine.gameManager.DispatchManager; |
|
import engine.mbEnums; |
|
import engine.net.Dispatch; |
|
import engine.net.client.ClientConnection; |
|
import engine.net.client.msg.ClientNetMsg; |
|
import engine.net.client.msg.ItemFromVaultMsg; |
|
import engine.net.client.msg.ItemToVaultMsg; |
|
import engine.objects.PlayerCharacter; |
|
|
|
public class ItemToVaultMsgHandler extends AbstractClientMsgHandler { |
|
|
|
public ItemToVaultMsgHandler() { |
|
super(); |
|
} |
|
|
|
//call this if the transfer fails server side to kick the item back to vault from inventory |
|
public static void forceTransferFromVaultToInventory(ItemToVaultMsg msg, ClientConnection origin, String reason) { |
|
|
|
PlayerCharacter player = origin.getPlayerCharacter(); |
|
Dispatch dispatch; |
|
|
|
if (player == null) |
|
return; |
|
|
|
ItemFromVaultMsg back = new ItemFromVaultMsg(msg); |
|
dispatch = Dispatch.borrow(player, back); |
|
DispatchManager.dispatchMsgDispatch(dispatch, mbEnums.DispatchChannel.SECONDARY); |
|
|
|
ChatManager.chatInfoError(player, "Can't transfer to vault: " + reason); |
|
} |
|
|
|
@Override |
|
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
|
|
|
ItemToVaultMsg msg = (ItemToVaultMsg) baseMsg; |
|
PlayerCharacter player = origin.getPlayerCharacter(); |
|
|
|
if (player == null) |
|
return true; |
|
|
|
if (player.getAccount() == null) |
|
return true; |
|
|
|
player.getAccount().transferItemFromInventoryToVault(msg, origin); |
|
return true; |
|
} |
|
|
|
} |