From f322a80b69559516b4aa5efdda07eda38cec4615 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 12 Aug 2020 08:06:31 +1200 Subject: [PATCH] Only modify entity metadata if they are currently self disguised --- .../packets/packetlisteners/PacketListenerInventory.java | 5 +++-- .../packetlisteners/PacketListenerViewSelfDisguise.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java index 868aa99a..2fb36344 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerInventory.java @@ -11,6 +11,7 @@ import com.comphenix.protocol.reflect.StructureModifier; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -60,7 +61,7 @@ public class PacketListenerInventory extends PacketAdapter { Disguise disguise = DisguiseAPI.getDisguise(player, player); // If player is disguised, views self disguises and has a inventory modifier - if (disguise != null && disguise.isSelfDisguiseVisible() && + if (disguise != null && DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) { // If they are in creative and clicked on a slot if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT) { @@ -256,7 +257,7 @@ public class PacketListenerInventory extends PacketAdapter { Disguise disguise = DisguiseAPI.getDisguise(player, player); - if (disguise == null || !disguise.isSelfDisguiseVisible() || + if (disguise == null || !DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) || (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) { return; } diff --git a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java index 5d4c17aa..e73a68f1 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/packets/packetlisteners/PacketListenerViewSelfDisguise.java @@ -55,7 +55,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter { if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) { Disguise disguise = DisguiseAPI.getDisguise(observer, observer); - if (disguise != null && disguise.isSelfDisguiseVisible()) { + if (disguise != null && DisguiseUtilities.getSelfDisguised().contains(observer.getUniqueId())) { event.setCancelled(true); } }