From 0f7ee056704881760baee3cd178b12c765683424 Mon Sep 17 00:00:00 2001 From: jamix77 <> Date: Mon, 30 Mar 2020 17:06:12 +0100 Subject: [PATCH] Fixed a dupe and fixed the game Fixed a dupe and fixed the game. --- .../crandor/net/packet/in/SlotSwitchPacket.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Server/src/org/crandor/net/packet/in/SlotSwitchPacket.java b/Server/src/org/crandor/net/packet/in/SlotSwitchPacket.java index e5ef66596..b405ec55a 100644 --- a/Server/src/org/crandor/net/packet/in/SlotSwitchPacket.java +++ b/Server/src/org/crandor/net/packet/in/SlotSwitchPacket.java @@ -30,7 +30,7 @@ public class SlotSwitchPacket implements IncomingPacket { if (withInterfaceId == 762) { if (withChildId == 73) { container = player.getBank(); - switchItem(slot, secondSlot, container, player.getBank().isInsertItems()); + switchItem(slot, secondSlot, container, player.getBank().isInsertItems(), player); player.debug("Switching item [" + slot + ", " + interfaceId + ", " + childId + "] with [" + secondSlot + ", " + withInterfaceId + ", " + withChildId + "]!"); } else { @@ -54,7 +54,7 @@ public class SlotSwitchPacket implements IncomingPacket { break; default: player.debug("Switching item slot [from=" + slot + ", to=" + secondSlot + ", child=" + childId + ", to child=" + withChildId + "]."); - switchItem(slot, secondSlot, container, false); + switchItem(slot, secondSlot, container, false, player); break; } return; @@ -65,7 +65,7 @@ public class SlotSwitchPacket implements IncomingPacket { boolean insert = buffer.get() == 1; int interfaceId = interfaceHash >> 16; Container container = interfaceId == 762 ? player.getBank() : (interfaceId == 15 || interfaceId == 149 || interfaceId == 763) ? player.getInventory() : null; - switchItem(slot, secondSlot, container, insert); + switchItem(slot, secondSlot, container, insert, player); } /** @@ -75,12 +75,19 @@ public class SlotSwitchPacket implements IncomingPacket { * @param container The container. * @param insert If inserting should happen. */ - public void switchItem(int slot, int secondSlot, Container container, boolean insert) { + public void switchItem(int slot, int secondSlot, Container container, boolean insert, Player player) { if (container == null || slot < 0 || slot >= container.toArray().length || secondSlot < 0 || secondSlot >= container.toArray().length) { return; } + final Item item = container.get(slot); final Item second = container.get(secondSlot); + if (player.getInterfaceManager().hasChatbox()) { + player.getInterfaceManager().closeChatbox(); + switchItem(secondSlot,slot,container,insert,player); + container.refresh(); + return; + } if (item == null) { return; }