Hopefully fixes #487
This commit is contained in:
		| @@ -109,6 +109,7 @@ public class DisguiseUtilities { | ||||
|     @Getter | ||||
|     public static final Random random = new Random(); | ||||
|     private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>(); | ||||
|     private static final List<Integer> isNoInteract = new ArrayList<>(); | ||||
|     /** | ||||
|      * A hashmap of the uuid's of entitys, alive and dead. And their disguises in use | ||||
|      */ | ||||
| @@ -186,6 +187,12 @@ public class DisguiseUtilities { | ||||
|         saveDisguiseCommandUsed = true; | ||||
|     } | ||||
|  | ||||
|     public static boolean isNotInteractable(int entityId) { | ||||
|         synchronized (isNoInteract) { | ||||
|             return isNoInteract.contains(entityId); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public static boolean isGrabSkinCommandUsed() { | ||||
|         return grabSkinCommandUsed; | ||||
|     } | ||||
| @@ -402,9 +409,24 @@ public class DisguiseUtilities { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     public static void addDisguise(UUID entityId, TargetedDisguise disguise) { | ||||
|         if (!getDisguises().containsKey(entityId)) { | ||||
|             getDisguises().put(entityId, new HashSet<>()); | ||||
|     public static void addDisguise(UUID entityUUID, TargetedDisguise disguise) { | ||||
|         if (!getDisguises().containsKey(entityUUID)) { | ||||
|             getDisguises().put(entityUUID, new HashSet<>()); | ||||
|  | ||||
|             synchronized (isNoInteract) { | ||||
|                 Entity entity = disguise.getEntity(); | ||||
|  | ||||
|                 switch (entity.getType()) { | ||||
|                     case EXPERIENCE_ORB: | ||||
|                     case DROPPED_ITEM: | ||||
|                     case ARROW: | ||||
|                     case SPECTRAL_ARROW: | ||||
|                         isNoInteract.add(entity.getEntityId()); | ||||
|                         break; | ||||
|                     default: | ||||
|                         break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ("a%%__USER__%%a".equals("a12345a") || (LibsPremium.getUserID().matches("[0-9]+") && | ||||
| @@ -427,7 +449,7 @@ public class DisguiseUtilities { | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         getDisguises().get(entityId).add(disguise); | ||||
|         getDisguises().get(entityUUID).add(disguise); | ||||
|  | ||||
|         checkConflicts(disguise, null); | ||||
|  | ||||
| @@ -1263,6 +1285,12 @@ public class DisguiseUtilities { | ||||
|         if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) { | ||||
|             if (getDisguises().get(entityId).isEmpty()) { | ||||
|                 getDisguises().remove(entityId); | ||||
|  | ||||
|                 if (disguise.getEntity() != null) { | ||||
|                     synchronized (isNoInteract) { | ||||
|                         isNoInteract.remove(disguise.getEntity().getEntityId()); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && | ||||
|   | ||||
| @@ -48,13 +48,9 @@ public class PacketListenerClientInteract extends PacketAdapter { | ||||
|         if (packet.getIntegers().read(0) == DisguiseAPI.getSelfDisguiseId()) { | ||||
|             // Self disguise | ||||
|             event.setCancelled(true); | ||||
|         } else { | ||||
|             Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), packet.getIntegers().read(0)); | ||||
|  | ||||
|             if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow) { | ||||
|         } else if (DisguiseUtilities.isNotInteractable(packet.getIntegers().read(0))) { | ||||
|             event.setCancelled(true); | ||||
|         } | ||||
|         } | ||||
|  | ||||
|         if (event.isAsync()) { | ||||
|             new BukkitRunnable() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user