Skip to content

Commit 9417e3d

Browse files
committed
BackwardsCompat: WrapperPlayClientWindowClick
1 parent 9ee8284 commit 9417e3d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayClientWindowClick.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
*/
1919
package com.comphenix.packetwrapper;
2020

21+
import com.comphenix.packetwrapper.util.BackwardsCompatible;
2122
import org.bukkit.inventory.ItemStack;
2223

2324
import com.comphenix.protocol.PacketType;
2425
import com.comphenix.protocol.events.PacketContainer;
2526

27+
@BackwardsCompatible
2628
public class WrapperPlayClientWindowClick extends AbstractPacket {
2729
public static final PacketType TYPE = PacketType.Play.Client.WINDOW_CLICK;
2830

@@ -135,14 +137,23 @@ public void setClickedItem(ItemStack value) {
135137
}
136138

137139
public InventoryClickType getShift() {
138-
return handle.getEnumModifier(InventoryClickType.class, 5).read(0);
140+
return MINOR_VERSION >= 9
141+
? handle.getEnumModifier(InventoryClickType.class, 5).read(0)
142+
: InventoryClickType.fromId(handle.getIntegers().read(3));
139143
}
140144

141145
public void setShift(InventoryClickType value) {
142-
handle.getEnumModifier(InventoryClickType.class, 5).write(0, value);
146+
if (MINOR_VERSION >= 9) handle.getEnumModifier(InventoryClickType.class, 5).write(0, value);
147+
else handle.getIntegers().write(3, value.ordinal());
143148
}
144149

145150
public enum InventoryClickType {
146151
PICKUP, QUICK_MOVE, SWAP, CLONE, THROW, QUICK_CRAFT, PICKUP_ALL;
152+
153+
private static final InventoryClickType[] VALUES = values();
154+
155+
public static InventoryClickType fromId(final int id) {
156+
return VALUES[id];
157+
}
147158
}
148159
}

0 commit comments

Comments
 (0)