mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-08 09:42:56 +01:00
Fix offhand slot not being handled
This commit is contained in:
parent
22649ff445
commit
7ab456c7e6
@ -66,7 +66,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
|
|
||||||
mods.write(0, 0);
|
mods.write(0, 0);
|
||||||
mods.write(1, slot);
|
mods.write(1, slot);
|
||||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||||
@ -77,12 +77,12 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (slot >= 36 && slot <= 44) {
|
else if (slot >= 36 && slot <= 45) {
|
||||||
if (disguise.isHidingHeldItemFromSelf()) {
|
if (disguise.isHidingHeldItemFromSelf()) {
|
||||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||||
|
|
||||||
if (slot + 36 == currentSlot) {
|
if (slot + 36 == currentSlot || slot == 45) {
|
||||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||||
@ -90,7 +90,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, 0);
|
mods.write(0, 0);
|
||||||
mods.write(1, slot);
|
mods.write(1, slot);
|
||||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||||
@ -140,7 +140,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
|
|
||||||
mods.write(0, 0);
|
mods.write(0, 0);
|
||||||
mods.write(1, event.getPacket().getIntegers().read(0) + 36);
|
mods.write(1, event.getPacket().getIntegers().read(0) + 36);
|
||||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||||
@ -192,7 +192,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
|
|
||||||
mods.write(0, 0);
|
mods.write(0, 0);
|
||||||
mods.write(1, slot);
|
mods.write(1, slot);
|
||||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||||
@ -203,18 +203,18 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
// Else if its a hotbar slot
|
// Else if its a hotbar slot
|
||||||
}
|
}
|
||||||
else if (slot >= 36 && slot <= 44) {
|
else if (slot >= 36 && slot <= 45) {
|
||||||
if (disguise.isHidingHeldItemFromSelf()) {
|
if (disguise.isHidingHeldItemFromSelf()) {
|
||||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||||
|
|
||||||
// Check if the player is on the same slot as the slot that its setting
|
// Check if the player is on the same slot as the slot that its setting
|
||||||
if (slot == currentSlot + 36) {
|
if (slot == currentSlot + 36 || slot == 45) {
|
||||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||||
|
|
||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, 0);
|
mods.write(0, 0);
|
||||||
mods.write(1, slot);
|
mods.write(1, slot);
|
||||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||||
@ -271,23 +271,23 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
event.setPacket(event.getPacket().shallowClone());
|
event.setPacket(event.getPacket().shallowClone());
|
||||||
|
|
||||||
event.getPacket().getModifier().write(2,
|
event.getPacket().getModifier().write(2,
|
||||||
ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Else if its a hotbar slot
|
// Else if its a hotbar slot
|
||||||
}
|
}
|
||||||
else if (slot >= 36 && slot <= 44) {
|
else if (slot >= 36 && slot <= 45) {
|
||||||
if (disguise.isHidingHeldItemFromSelf()) {
|
if (disguise.isHidingHeldItemFromSelf()) {
|
||||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||||
|
|
||||||
// Check if the player is on the same slot as the slot that its setting
|
// Check if the player is on the same slot as the slot that its setting
|
||||||
if (slot == currentSlot + 36) {
|
if (slot == currentSlot + 36 || slot == 45) {
|
||||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
event.setPacket(event.getPacket().shallowClone());
|
event.setPacket(event.getPacket().shallowClone());
|
||||||
event.getPacket().getModifier().write(2,
|
event.getPacket().getModifier().write(2,
|
||||||
ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(Material.AIR)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,13 +313,13 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
// Else if its a hotbar slot
|
// Else if its a hotbar slot
|
||||||
}
|
}
|
||||||
else if (slot >= 36 && slot <= 44) {
|
else if (slot >= 36 && slot <= 45) {
|
||||||
if (disguise.isHidingHeldItemFromSelf()) {
|
if (disguise.isHidingHeldItemFromSelf()) {
|
||||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||||
|
|
||||||
// Check if the player is on the same slot as the slot that its setting
|
// Check if the player is on the same slot as the slot that its setting
|
||||||
if (slot == currentSlot + 36) {
|
if (slot == currentSlot + 36 || slot == 45) {
|
||||||
ItemStack item = event.getPlayer().getItemInHand();
|
ItemStack item = event.getPlayer().getInventory().getItemInMainHand();
|
||||||
|
|
||||||
if (item != null && item.getType() != Material.AIR) {
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
items.set(slot, new ItemStack(Material.AIR));
|
items.set(slot, new ItemStack(Material.AIR));
|
||||||
|
Loading…
Reference in New Issue
Block a user