Handler created for DeleteItemMsg
This commit is contained in:
@@ -92,39 +92,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
DispatchMessage.dispatchMsgToInterestArea(pc, rwss, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
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) {
|
private static void ackBankWindowOpened(AckBankWindowOpenedMsg msg, ClientConnection origin) {
|
||||||
// According to the Wiki, the client should not send this message.
|
// According to the Wiki, the client should not send this message.
|
||||||
// Log the instance to investigate, and modify Wiki accordingly.
|
// Log the instance to investigate, and modify Wiki accordingly.
|
||||||
@@ -761,9 +728,6 @@ public class ClientMessagePump implements NetMsgHandler {
|
|||||||
case IGNORE:
|
case IGNORE:
|
||||||
((IgnoreMsg) msg).handleRequest(origin);
|
((IgnoreMsg) msg).handleRequest(origin);
|
||||||
break;
|
break;
|
||||||
case DELETEOBJECT:
|
|
||||||
DeleteItem((DeleteItemMsg) msg, origin);
|
|
||||||
break;
|
|
||||||
case VIEWRESOURCES:
|
case VIEWRESOURCES:
|
||||||
ViewResourcesMessage((ViewResourcesMessage) msg, origin);
|
ViewResourcesMessage((ViewResourcesMessage) msg, origin);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public enum Protocol {
|
|||||||
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
CREATECHAR(0x5D18B5C8, CommitNewCharacterMsg.class, null), // Commit New Character,
|
||||||
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
CREATEPETITION(0xD489CFED, GuildCreationFinalizeMsg.class, GuildCreationFinalizeHandler.class), //Confirm guild creation
|
||||||
CUSTOMERPETITION(0x7F9D7D6D, PetitionReceivedMsg.class, PetitionReceivedMsgHandler.class),
|
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
|
DESTROYBUILDING(0x3CB6FAD3, DestroyBuildingMsg.class, DestroyBuildingHandler.class), // Destroy Building
|
||||||
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
|
DISBANDGUILD(0x77AABD64, DisbandGuildMsg.class, DisbandGuildHandler.class), //Disband Guild
|
||||||
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),
|
DISMISSGUILD(0x8D2D3D61, DismissGuildMsg.class, DismissGuildHandler.class),
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user