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.
		
		
		
		
			
				
					100 lines
				
				3.3 KiB
			
		
		
			
		
	
	
					100 lines
				
				3.3 KiB
			| 
											2 years ago
										 | // • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | ||
|  | // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | ||
|  | // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | ||
|  | // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | ||
|  | // ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | ||
|  | //      Magicbane Emulator Project © 2013 - 2022
 | ||
|  | //                www.magicbane.com
 | ||
|  | 
 | ||
|  | package engine.net.client.handlers;
 | ||
|  | 
 | ||
|  | import engine.Enum;
 | ||
|  | import engine.Enum.DispatchChannel;
 | ||
|  | import engine.exception.MsgSendException;
 | ||
|  | import engine.gameManager.NPCManager;
 | ||
|  | import engine.net.Dispatch;
 | ||
|  | import engine.net.DispatchMessage;
 | ||
|  | import engine.net.client.ClientConnection;
 | ||
|  | import engine.net.client.msg.ClientNetMsg;
 | ||
|  | import engine.net.client.msg.TransferItemFromBankMsg;
 | ||
|  | import engine.net.client.msg.UpdateGoldMsg;
 | ||
|  | import engine.objects.CharacterItemManager;
 | ||
|  | import engine.objects.Item;
 | ||
|  | import engine.objects.PlayerCharacter;
 | ||
|  | 
 | ||
|  | public class TransferItemFromBankMsgHandler extends AbstractClientMsgHandler {
 | ||
|  | 
 | ||
|  |     public TransferItemFromBankMsgHandler() {
 | ||
|  |         super(TransferItemFromBankMsg.class);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     @Override
 | ||
|  |     protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
 | ||
|  | 
 | ||
|  |         PlayerCharacter player = origin.getPlayerCharacter();
 | ||
|  |         Dispatch dispatch;
 | ||
|  | 
 | ||
|  |         if (player == null)
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         TransferItemFromBankMsg msg = (TransferItemFromBankMsg) baseMsg;
 | ||
|  | 
 | ||
|  |         if (!NPCManager.NPCVaultBankRangeCheck(player, origin, "bank"))
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         CharacterItemManager itemManager = player.charItemManager;
 | ||
|  | 
 | ||
|  |         if (itemManager == null)
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         int uuid = msg.getUUID();
 | ||
|  | 
 | ||
|  |         Item item = itemManager.getItemByUUID(uuid);
 | ||
|  | 
 | ||
|  |         if (item == null)
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         //dupe check
 | ||
|  |         // WTF Checking but not logging?
 | ||
|  | 
 | ||
|  |         if (!item.validForBank(origin, player, itemManager))
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         if (item.containerType == Enum.ItemContainerType.BANK && itemManager.isBankOpen() == false)
 | ||
|  |             return true;
 | ||
|  |         ;
 | ||
|  | 
 | ||
|  |         if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) {
 | ||
|  | 
 | ||
|  |             if (!itemManager.moveGoldToInventory(item, msg.getNumItems()))
 | ||
|  |                 return true;
 | ||
|  |             ;
 | ||
|  | 
 | ||
|  |             UpdateGoldMsg goldMes = new UpdateGoldMsg(player);
 | ||
|  |             goldMes.configure();
 | ||
|  | 
 | ||
|  |             dispatch = Dispatch.borrow(player, goldMes);
 | ||
|  |             DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
 | ||
|  | 
 | ||
|  |             return true;
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         // Not gold, process update here
 | ||
|  | 
 | ||
|  |         if (!itemManager.hasRoomInventory(item.template.item_wt))
 | ||
|  |             return true;
 | ||
|  | 
 | ||
|  |         if (itemManager.moveItemToInventory(item) == false)
 | ||
|  |             return true;
 | ||
|  | 
 | ||
|  |         dispatch = Dispatch.borrow(player, msg);
 | ||
|  |         DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
 | ||
|  |         return true;
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | }
 |