Hopefully fixes #487
This commit is contained in:
parent
c5ee5f1fbd
commit
472649cad7
@ -109,6 +109,7 @@ public class DisguiseUtilities {
|
|||||||
@Getter
|
@Getter
|
||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
|
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
|
* 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;
|
saveDisguiseCommandUsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isNotInteractable(int entityId) {
|
||||||
|
synchronized (isNoInteract) {
|
||||||
|
return isNoInteract.contains(entityId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isGrabSkinCommandUsed() {
|
public static boolean isGrabSkinCommandUsed() {
|
||||||
return grabSkinCommandUsed;
|
return grabSkinCommandUsed;
|
||||||
}
|
}
|
||||||
@ -402,9 +409,24 @@ public class DisguiseUtilities {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addDisguise(UUID entityId, TargetedDisguise disguise) {
|
public static void addDisguise(UUID entityUUID, TargetedDisguise disguise) {
|
||||||
if (!getDisguises().containsKey(entityId)) {
|
if (!getDisguises().containsKey(entityUUID)) {
|
||||||
getDisguises().put(entityId, new HashSet<>());
|
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]+") &&
|
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);
|
checkConflicts(disguise, null);
|
||||||
|
|
||||||
@ -1263,6 +1285,12 @@ public class DisguiseUtilities {
|
|||||||
if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) {
|
if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) {
|
||||||
if (getDisguises().get(entityId).isEmpty()) {
|
if (getDisguises().get(entityId).isEmpty()) {
|
||||||
getDisguises().remove(entityId);
|
getDisguises().remove(entityId);
|
||||||
|
|
||||||
|
if (disguise.getEntity() != null) {
|
||||||
|
synchronized (isNoInteract) {
|
||||||
|
isNoInteract.remove(disguise.getEntity().getEntityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
||||||
|
@ -48,12 +48,8 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||||||
if (packet.getIntegers().read(0) == DisguiseAPI.getSelfDisguiseId()) {
|
if (packet.getIntegers().read(0) == DisguiseAPI.getSelfDisguiseId()) {
|
||||||
// Self disguise
|
// Self disguise
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else if (DisguiseUtilities.isNotInteractable(packet.getIntegers().read(0))) {
|
||||||
Entity entity = DisguiseUtilities.getEntity(observer.getWorld(), packet.getIntegers().read(0));
|
event.setCancelled(true);
|
||||||
|
|
||||||
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.isAsync()) {
|
if (event.isAsync()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user