MagicBot
8 months ago
3 changed files with 70 additions and 37 deletions
@ -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…
Reference in new issue