Browse Source

Handlers created for vault interactions

combat-2
MagicBot 8 months ago
parent
commit
5439df5653
  1. 43
      src/engine/net/client/ClientMessagePump.java
  2. 4
      src/engine/net/client/Protocol.java
  3. 43
      src/engine/net/client/handlers/ItemFromVaultMsgHandler.java
  4. 43
      src/engine/net/client/handlers/ItemToVaultMsgHandler.java
  5. 22
      src/engine/net/client/msg/ItemFromVaultMsg.java
  6. 16
      src/engine/net/client/msg/ItemToVaultMsg.java
  7. 4
      src/engine/objects/Account.java

43
src/engine/net/client/ClientMessagePump.java

@ -155,23 +155,8 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true); DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, true);
} }
private static void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch;
if (player == null)
return;
if (player.getAccount() == null)
return;
player.getAccount().transferItemFromVaultToInventory(msg, origin);
}
//call this if the transfer fails server side to kick the item back to inventory from vault //call this if the transfer fails server side to kick the item back to inventory from vault
public static void forceTransferFromInventoryToVault(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin, String reason) { public static void forceTransferFromInventoryToVault(ItemFromVaultMsg msg, ClientConnection origin, String reason) {
PlayerCharacter player = origin.getPlayerCharacter(); PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch; Dispatch dispatch;
@ -179,29 +164,15 @@ public class ClientMessagePump implements NetMsgHandler {
if (player == null) if (player == null)
return; return;
TransferItemFromInventoryToVaultMsg back = new TransferItemFromInventoryToVaultMsg(msg); ItemToVaultMsg back = new ItemToVaultMsg(msg);
dispatch = Dispatch.borrow(player, back); dispatch = Dispatch.borrow(player, back);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
ChatManager.chatInfoError(player, "Can't transfer to inventory: " + reason); ChatManager.chatInfoError(player, "Can't transfer to inventory: " + reason);
} }
private static void transferItemFromInventoryToVault(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch;
if (player == null)
return;
if (player.getAccount() == null)
return;
player.getAccount().transferItemFromInventoryToVault(msg, origin);
}
//call this if the transfer fails server side to kick the item back to vault from inventory //call this if the transfer fails server side to kick the item back to vault from inventory
public static void forceTransferFromVaultToInventory(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin, String reason) { public static void forceTransferFromVaultToInventory(ItemToVaultMsg msg, ClientConnection origin, String reason) {
PlayerCharacter player = origin.getPlayerCharacter(); PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch; Dispatch dispatch;
@ -209,7 +180,7 @@ public class ClientMessagePump implements NetMsgHandler {
if (player == null) if (player == null)
return; return;
TransferItemFromVaultToInventoryMsg back = new TransferItemFromVaultToInventoryMsg(msg); ItemFromVaultMsg back = new ItemFromVaultMsg(msg);
dispatch = Dispatch.borrow(player, back); dispatch = Dispatch.borrow(player, back);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY); DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
@ -1173,12 +1144,6 @@ public class ClientMessagePump implements NetMsgHandler {
case SHOWCOMBATINFO: case SHOWCOMBATINFO:
show((ShowMsg) msg, origin); show((ShowMsg) msg, origin);
break; break;
case TRANSFERITEMFROMVAULTTOINVENTORY:
transferItemFromVaultToInventory((TransferItemFromVaultToInventoryMsg) msg, origin);
break;
case ITEMTOVAULT:
transferItemFromInventoryToVault((TransferItemFromInventoryToVaultMsg) msg, origin);
break;
case TRANSFERGOLDFROMVAULTTOINVENTORY: case TRANSFERGOLDFROMVAULTTOINVENTORY:
transferGoldFromVaultToInventory((TransferGoldFromVaultToInventoryMsg) msg, origin); transferGoldFromVaultToInventory((TransferGoldFromVaultToInventoryMsg) msg, origin);
break; break;

4
src/engine/net/client/Protocol.java

@ -116,7 +116,8 @@ public enum Protocol {
INVITETOGUILD(0x6819062A, InviteToGuildMsg.class, InviteToGuildHandler.class), // Invite player to guild, refuse guild invite INVITETOGUILD(0x6819062A, InviteToGuildMsg.class, InviteToGuildHandler.class), // Invite player to guild, refuse guild invite
ITEMHEALTHUPDATE(0xB635F55E, ItemHealthUpdateMsg.class, null), //Update Durability of item ITEMHEALTHUPDATE(0xB635F55E, ItemHealthUpdateMsg.class, null), //Update Durability of item
ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class), ITEMPRODUCTION(0x3CCE8E30, ItemProductionMsg.class, ItemProductionMsgHandler.class),
ITEMTOVAULT(0x3ABE4927, TransferItemFromInventoryToVaultMsg.class, null), // Transfer Item to Vault ITEMTOVAULT(0x3ABE4927, ItemToVaultMsg.class, ItemToVaultMsgHandler.class), // Transfer Item to Vault
ITEMFROMVAULT(0x0119A64D, ItemFromVaultMsg.class, ItemFromVaultMsgHandler.class), // Transfer Item from Vault to Inventory
JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, AcceptSubInviteHandler.class), //Response to invite to swear? JOINFORPROVINCE(0x1FB369CD, AcceptSubInviteMsg.class, AcceptSubInviteHandler.class), //Response to invite to swear?
JOINFORSWORN(0xF6A4170F, null, null), JOINFORSWORN(0xF6A4170F, null, null),
JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite JOINGROUP(0x7EC5E636, GroupInviteResponseMsg.class, GroupInviteResponseHandler.class), // Accept Group Invite
@ -223,7 +224,6 @@ public enum Protocol {
TRANSFERGOLDFROMVAULTTOINVENTORY(0x011D0123, TransferGoldFromVaultToInventoryMsg.class, null), // Transfer Gold from Vault to Inventory TRANSFERGOLDFROMVAULTTOINVENTORY(0x011D0123, TransferGoldFromVaultToInventoryMsg.class, null), // Transfer Gold from Vault to Inventory
TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error TRANSFERGOLDTOFROMBUILDING(0x1B1AC8C7, TransferGoldToFromBuildingMsg.class, TransferGoldToFromBuildingMsgHandler.class), // Transfer Gold to/From Building, Transfer Error
TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankMsg.class, TransferItemFromBankMsgHandler.class), // Transfer Item from Bank to Inventory TRANSFERITEMFROMBANK(0x9D04977B, TransferItemFromBankMsg.class, TransferItemFromBankMsgHandler.class), // Transfer Item from Bank to Inventory
TRANSFERITEMFROMVAULTTOINVENTORY(0x0119A64D, TransferItemFromVaultToInventoryMsg.class, null), // Transfer Item from Vault to Inventory
TRANSFERITEMTOBANK(0xD48C46FA, TransferItemToBankMsg.class, TransferItemToBankMsgHandler.class), // Transfer Item from Inventory to Bank TRANSFERITEMTOBANK(0xD48C46FA, TransferItemToBankMsg.class, TransferItemToBankMsgHandler.class), // Transfer Item from Inventory to Bank
UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, TransferItemFromEquipToInventoryHandler.class), // Transfer Item from Equip to Inventory UNEQUIP(0xC6BFB907, TransferItemFromEquipToInventoryMsg.class, TransferItemFromEquipToInventoryHandler.class), // Transfer Item from Equip to Inventory
UNKNOWN(0x238C9259, UnknownMsg.class, null), UNKNOWN(0x238C9259, UnknownMsg.class, null),

43
src/engine/net/client/handlers/ItemFromVaultMsgHandler.java

@ -0,0 +1,43 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ItemFromVaultMsg;
import engine.objects.PlayerCharacter;
public class ItemFromVaultMsgHandler extends AbstractClientMsgHandler {
public ItemFromVaultMsgHandler() {
super(ItemFromVaultMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter player = origin.getPlayerCharacter();
ItemFromVaultMsg msg = (ItemFromVaultMsg) baseMsg;
if (player == null)
return true;
;
if (player.getAccount() == null)
return true;
;
player.getAccount().transferItemFromVaultToInventory(msg, origin);
return true;
}
}

43
src/engine/net/client/handlers/ItemToVaultMsgHandler.java

@ -0,0 +1,43 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ItemToVaultMsg;
import engine.objects.PlayerCharacter;
public class ItemToVaultMsgHandler extends AbstractClientMsgHandler {
public ItemToVaultMsgHandler() {
super(ItemToVaultMsg.class);
}
@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;
}
}

22
src/engine/net/client/msg/TransferItemFromVaultToInventoryMsg.java → src/engine/net/client/msg/ItemFromVaultMsg.java

@ -22,7 +22,7 @@ import engine.net.client.Protocol;
* @author Eighty * @author Eighty
*/ */
public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg { public class ItemFromVaultMsg extends ClientNetMsg {
private int unknown01; private int unknown01;
private int unknown02; private int unknown02;
@ -35,9 +35,9 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor * This is the general purpose constructor
*/ */
public TransferItemFromVaultToInventoryMsg(int unknown01, int unknown02, public ItemFromVaultMsg(int unknown01, int unknown02,
long playerCompID, int type, int objectUUID, int unknown03, int unknown04) { long playerCompID, int type, int objectUUID, int unknown03, int unknown04) {
super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); super(Protocol.ITEMFROMVAULT);
this.unknown01 = unknown01; this.unknown01 = unknown01;
this.unknown02 = unknown02; this.unknown02 = unknown02;
this.playerCompID = playerCompID; this.playerCompID = playerCompID;
@ -47,8 +47,8 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg {
this.unknown04 = unknown04; this.unknown04 = unknown04;
} }
public TransferItemFromVaultToInventoryMsg(TransferItemFromInventoryToVaultMsg msg) { public ItemFromVaultMsg(ItemToVaultMsg msg) {
super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); super(Protocol.ITEMFROMVAULT);
this.playerCompID = msg.getPlayerCompID(); this.playerCompID = msg.getPlayerCompID();
this.unknown01 = msg.getUnknown01(); this.unknown01 = msg.getUnknown01();
this.unknown02 = msg.getUnknown02(); this.unknown02 = msg.getUnknown02();
@ -61,8 +61,8 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor * This is the general purpose constructor
*/ */
public TransferItemFromVaultToInventoryMsg() { public ItemFromVaultMsg() {
super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY); super(Protocol.ITEMFROMVAULT);
} }
/** /**
@ -71,9 +71,9 @@ public class TransferItemFromVaultToInventoryMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the * past the limit) then this constructor Throws that Exception to the
* caller. * caller.
*/ */
public TransferItemFromVaultToInventoryMsg(AbstractConnection origin, public ItemFromVaultMsg(AbstractConnection origin,
ByteBufferReader reader) { ByteBufferReader reader) {
super(Protocol.TRANSFERITEMFROMVAULTTOINVENTORY, origin, reader); super(Protocol.ITEMFROMVAULT, origin, reader);
} }
/** /**

16
src/engine/net/client/msg/TransferItemFromInventoryToVaultMsg.java → src/engine/net/client/msg/ItemToVaultMsg.java

@ -22,7 +22,7 @@ import engine.net.client.Protocol;
* @author Eighty * @author Eighty
*/ */
public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg { public class ItemToVaultMsg extends ClientNetMsg {
private int unknown01; private int unknown01;
private int unknown02; private int unknown02;
@ -35,9 +35,9 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor * This is the general purpose constructor
*/ */
public TransferItemFromInventoryToVaultMsg(long playerCompID, public ItemToVaultMsg(long playerCompID,
int unknown01, int unknown02, int type, int objectUUID, int unknown03, int unknown01, int unknown02, int type, int objectUUID, int unknown03,
int unknown04) { int unknown04) {
super(Protocol.ITEMTOVAULT); super(Protocol.ITEMTOVAULT);
this.playerCompID = playerCompID; this.playerCompID = playerCompID;
this.unknown01 = unknown01; this.unknown01 = unknown01;
@ -48,7 +48,7 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg {
this.unknown04 = unknown04; this.unknown04 = unknown04;
} }
public TransferItemFromInventoryToVaultMsg(TransferItemFromVaultToInventoryMsg msg) { public ItemToVaultMsg(ItemFromVaultMsg msg) {
super(Protocol.ITEMTOVAULT); super(Protocol.ITEMTOVAULT);
this.playerCompID = msg.getPlayerCompID(); this.playerCompID = msg.getPlayerCompID();
this.unknown01 = msg.getUnknown01(); this.unknown01 = msg.getUnknown01();
@ -62,7 +62,7 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor * This is the general purpose constructor
*/ */
public TransferItemFromInventoryToVaultMsg() { public ItemToVaultMsg() {
super(Protocol.ITEMTOVAULT); super(Protocol.ITEMTOVAULT);
} }
@ -72,8 +72,8 @@ public class TransferItemFromInventoryToVaultMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the * past the limit) then this constructor Throws that Exception to the
* caller. * caller.
*/ */
public TransferItemFromInventoryToVaultMsg(AbstractConnection origin, public ItemToVaultMsg(AbstractConnection origin,
ByteBufferReader reader) { ByteBufferReader reader) {
super(Protocol.ITEMTOVAULT, origin, reader); super(Protocol.ITEMTOVAULT, origin, reader);
} }

4
src/engine/objects/Account.java

@ -193,7 +193,7 @@ public class Account extends AbstractGameObject {
} }
} }
public synchronized void transferItemFromInventoryToVault(TransferItemFromInventoryToVaultMsg msg, ClientConnection origin) { public synchronized void transferItemFromInventoryToVault(ItemToVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter(); PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch; Dispatch dispatch;
@ -233,7 +233,7 @@ public class Account extends AbstractGameObject {
} }
} }
public synchronized void transferItemFromVaultToInventory(TransferItemFromVaultToInventoryMsg msg, ClientConnection origin) { public synchronized void transferItemFromVaultToInventory(ItemFromVaultMsg msg, ClientConnection origin) {
PlayerCharacter player = origin.getPlayerCharacter(); PlayerCharacter player = origin.getPlayerCharacter();
Dispatch dispatch; Dispatch dispatch;

Loading…
Cancel
Save