forked from MagicBane/Server
MagicBot
8 months ago
8 changed files with 252 additions and 115 deletions
@ -0,0 +1,100 @@
@@ -0,0 +1,100 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// 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.ErrorPopupMsg; |
||||
import engine.net.client.msg.TransferItemToBankMsg; |
||||
import engine.net.client.msg.UpdateGoldMsg; |
||||
import engine.objects.CharacterItemManager; |
||||
import engine.objects.Item; |
||||
import engine.objects.PlayerCharacter; |
||||
|
||||
public class TransferItemToBankMsgHandler extends AbstractClientMsgHandler { |
||||
|
||||
public TransferItemToBankMsgHandler() { |
||||
super(TransferItemToBankMsg.class); |
||||
} |
||||
|
||||
@Override |
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException { |
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter(); |
||||
Dispatch dispatch; |
||||
|
||||
if (player == null) |
||||
return true; |
||||
|
||||
TransferItemToBankMsg msg = (TransferItemToBankMsg) baseMsg; |
||||
|
||||
if (!NPCManager.NPCVaultBankRangeCheck(player, origin, "bank")) |
||||
return true; |
||||
|
||||
CharacterItemManager itemManager = player.charItemManager; |
||||
|
||||
if (itemManager == null) |
||||
return true; |
||||
|
||||
if (itemManager.getBankWeight() > 500) { |
||||
ErrorPopupMsg.sendErrorPopup(player, 21); |
||||
return true; |
||||
} |
||||
|
||||
int uuid = msg.getUUID(); |
||||
|
||||
Item item = itemManager.getItemByUUID(uuid); |
||||
|
||||
if (item == null) |
||||
return true; |
||||
|
||||
//dupe check WTF CHECK BUT NO LOGGING?
|
||||
|
||||
if (!item.validForInventory(origin, player, itemManager)) |
||||
return true; |
||||
|
||||
if (item.containerType == Enum.ItemContainerType.INVENTORY && itemManager.isBankOpen()) |
||||
if (item.template.item_type.equals(engine.Enum.ItemType.GOLD)) { |
||||
if (!itemManager.moveGoldToBank(item, msg.getNumItems())) |
||||
return true; |
||||
UpdateGoldMsg goldMes = new UpdateGoldMsg(player); |
||||
goldMes.configure(); |
||||
|
||||
dispatch = Dispatch.borrow(player, goldMes); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
} else { |
||||
|
||||
if (!itemManager.hasRoomBank(item.template.item_wt)) |
||||
return true; |
||||
|
||||
if (!itemManager.moveItemToBank(item)) |
||||
return true; |
||||
|
||||
dispatch = Dispatch.borrow(player, msg); |
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); |
||||
|
||||
} |
||||
return true; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue