More disguiseNextEntity fixing
This commit is contained in:
parent
7f65d8c8f1
commit
fa4c577f7e
@ -428,36 +428,48 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addFutureDisguise(final int entityId, final TargetedDisguise disguise) {
|
public static void onFutureDisguise(Entity entity) {
|
||||||
if (!futureDisguises.containsKey(entityId)) {
|
if (!getFutureDisguises().containsKey(entity.getEntityId())) {
|
||||||
futureDisguises.put(entityId, new HashSet<TargetedDisguise>());
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
futureDisguises.get(entityId).add(disguise);
|
UUID uniqueId = entity.getUniqueId();
|
||||||
|
|
||||||
|
for (TargetedDisguise disguise : getFutureDisguises().remove(entity.getEntityId())) {
|
||||||
|
addDisguise(uniqueId, disguise);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addFutureDisguise(final int entityId, final TargetedDisguise disguise) {
|
||||||
|
if (!getFutureDisguises().containsKey(entityId)) {
|
||||||
|
getFutureDisguises().put(entityId, new HashSet<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
getFutureDisguises().get(entityId).add(disguise);
|
||||||
|
|
||||||
final BukkitRunnable runnable = new BukkitRunnable() {
|
final BukkitRunnable runnable = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) {
|
if (!getFutureDisguises().containsKey(entityId) ||
|
||||||
for (World world : Bukkit.getWorlds()) {
|
!getFutureDisguises().get(entityId).contains(disguise)) {
|
||||||
for (Entity entity : world.getEntities()) {
|
return;
|
||||||
if (entity.getEntityId() == entityId) {
|
|
||||||
UUID uniqueId = entity.getUniqueId();
|
|
||||||
|
|
||||||
for (TargetedDisguise disguise : futureDisguises.remove(entityId)) {
|
|
||||||
addDisguise(uniqueId, disguise);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
for (Entity entity : world.getEntities()) {
|
||||||
|
if (entity.getEntityId() != entityId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
onFutureDisguise(entity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
futureDisguises.get(entityId).remove(disguise);
|
getFutureDisguises().get(entityId).remove(disguise);
|
||||||
|
|
||||||
if (futureDisguises.get(entityId).isEmpty()) {
|
if (getFutureDisguises().get(entityId).isEmpty()) {
|
||||||
futureDisguises.remove(entityId);
|
getFutureDisguises().remove(entityId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2227,14 +2239,14 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getFutureDisguises().containsKey(entityId)) {
|
if (getFutureDisguises().containsKey(entityId)) {
|
||||||
HashSet<TargetedDisguise> hashSet = getFutureDisguises().get(entityId);
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
for (Entity entity : world.getEntities()) {
|
||||||
for (TargetedDisguise dis : hashSet) {
|
if (entity.getEntityId() != entityId) {
|
||||||
if (!dis.canSee(observer) || !dis.isDisguiseInUse()) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return dis;
|
onFutureDisguise(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,25 +39,10 @@ public class PacketListenerMain extends PacketAdapter {
|
|||||||
|
|
||||||
final Disguise disguise = DisguiseUtilities.getDisguise(observer, entityId);
|
final Disguise disguise = DisguiseUtilities.getDisguise(observer, entityId);
|
||||||
|
|
||||||
if (disguise == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disguise.getEntity() == null) {
|
|
||||||
for (Entity e : observer.getWorld().getEntities()) {
|
|
||||||
if (e.getEntityId() != entityId) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
disguise.setEntity(e);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the entity is the same as the sender. Don't disguise!
|
// If the entity is the same as the sender. Don't disguise!
|
||||||
// Prevents problems and there is no advantage to be gained.
|
// Prevents problems and there is no advantage to be gained.
|
||||||
// Or if they are null and there's no disguise
|
// Or if they are null and there's no disguise
|
||||||
if (disguise.getEntity() == observer) {
|
if (disguise == null || disguise.getEntity() == observer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||||||
|
|
||||||
Entity entity = disguise.getEntity();
|
Entity entity = disguise.getEntity();
|
||||||
|
|
||||||
if (disguise != null && !disguise.getType().isPlayer() &&
|
if (!disguise.getType().isPlayer() &&
|
||||||
(disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) {
|
(disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) {
|
||||||
DisguiseSound disSound = DisguiseSound.getType(entity.getType().name());
|
DisguiseSound disSound = DisguiseSound.getType(entity.getType().name());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user