Browse Source

Handler created for DeleteItemMsg

combat-2
MagicBot 8 months ago
parent
commit
8083f39ba1
  1. 36
      src/engine/net/client/ClientMessagePump.java
  2. 2
      src/engine/net/client/Protocol.java
  3. 69
      src/engine/net/client/handlers/DeleteItemMsgHandler.java

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

@ -92,39 +92,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -92,39 +92,6 @@ public class ClientMessagePump implements NetMsgHandler {
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
}
private static void DeleteItem(DeleteItemMsg msg, ClientConnection origin) {
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
int uuid = msg.getUUID();
PlayerCharacter sourcePlayer = origin.getPlayerCharacter();
if (sourcePlayer == null)
return;
if (!sourcePlayer.isAlive())
return;
Item i = Item.getFromCache(msg.getUUID());
if (i == null)
return;
if (!itemManager.doesCharOwnThisItem(i.getObjectUUID()))
return;
if (!itemManager.inventoryContains(i))
return;
if (i.isCanDestroy())
if (itemManager.delete(i) == true) {
Dispatch dispatch = Dispatch.borrow(sourcePlayer, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
}
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
// According to the Wiki, the client should not send this message.
// Log the instance to investigate, and modify Wiki accordingly.
@ -761,9 +728,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -761,9 +728,6 @@ public class ClientMessagePump implements NetMsgHandler {
case IGNORE:
((IgnoreMsg) msg).handleRequest(origin);
break;
case DELETEOBJECT:
DeleteItem((DeleteItemMsg) msg, origin);
break;
case VIEWRESOURCES:
ViewResourcesMessage((ViewResourcesMessage) msg, origin);
break;

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

@ -85,7 +85,7 @@ public enum Protocol { @@ -85,7 +85,7 @@ public enum Protocol {
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, PetitionReceivedMsgHandler.class),
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, null), //Delete Item from Inventory
DELETEOBJECT(0x57F069D8, DeleteItemMsg.class, DeleteItemMsgHandler.class), //Delete Item from Inventory
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),

69
src/engine/net/client/handlers/DeleteItemMsgHandler.java

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.Enum.DispatchChannel;
import engine.exception.MsgSendException;
import engine.net.Dispatch;
import engine.net.DispatchMessage;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.DeleteItemMsg;
import engine.objects.CharacterItemManager;
import engine.objects.Item;
import engine.objects.PlayerCharacter;
public class DeleteItemMsgHandler extends AbstractClientMsgHandler {
public DeleteItemMsgHandler() {
super(DeleteItemMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter player = origin.getPlayerCharacter();
// Member variable declaration
DeleteItemMsg msg;
// Member variable assignment
msg = (DeleteItemMsg) baseMsg;
CharacterItemManager itemManager = origin.getPlayerCharacter().charItemManager;
int uuid = msg.getUUID();
if (player == null)
return true;
if (!player.isAlive())
return true;
Item item = Item.getFromCache(msg.getUUID());
if (item == null)
return true;
if (!itemManager.doesCharOwnThisItem(item.getObjectUUID()))
return true;
if (!itemManager.inventoryContains(item))
return true;
if (item.isCanDestroy())
if (itemManager.delete(item) == true) {
Dispatch dispatch = Dispatch.borrow(player, msg);
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
}
return true;
}
}
Loading…
Cancel
Save