Fix up self disguises flicking and Evoker Fangs
This commit is contained in:
parent
ce134af4fa
commit
eb1733262f
@ -209,7 +209,7 @@ public abstract class Disguise {
|
|||||||
if (getType() == DisguiseType.FIREWORK) {
|
if (getType() == DisguiseType.FIREWORK) {
|
||||||
refreshDisguise++;
|
refreshDisguise++;
|
||||||
|
|
||||||
if (refreshDisguise % 40 == 0) {
|
if (refreshDisguise == 40) {
|
||||||
refreshDisguise = 0;
|
refreshDisguise = 0;
|
||||||
|
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
@ -218,7 +218,7 @@ public abstract class Disguise {
|
|||||||
else if (getType() == DisguiseType.EVOKER_FANGS) {
|
else if (getType() == DisguiseType.EVOKER_FANGS) {
|
||||||
refreshDisguise++;
|
refreshDisguise++;
|
||||||
|
|
||||||
if (refreshDisguise % 20 == 0) {
|
if (refreshDisguise == 23) {
|
||||||
refreshDisguise = 0;
|
refreshDisguise = 0;
|
||||||
|
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
|
@ -880,74 +880,73 @@ public class DisguiseUtilities {
|
|||||||
if (mainThread != Thread.currentThread())
|
if (mainThread != Thread.currentThread())
|
||||||
throw new IllegalStateException("Cannot modify disguises on an async thread");
|
throw new IllegalStateException("Cannot modify disguises on an async thread");
|
||||||
|
|
||||||
if (disguise.getEntity().isValid()) {
|
if (!disguise.getEntity().isValid()) {
|
||||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) {
|
|
||||||
removeSelfDisguise((Player) disguise.getEntity());
|
|
||||||
|
|
||||||
selfDisguised.add(disguise.getEntity().getUniqueId());
|
try {
|
||||||
|
if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) {
|
||||||
|
removeSelfDisguise((Player) disguise.getEntity());
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||||
@Override
|
|
||||||
public void run() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
try {
|
@Override
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
public void run() {
|
||||||
}
|
try {
|
||||||
catch (Exception ex) {
|
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 2);
|
catch (Exception ex) {
|
||||||
}
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2);
|
||||||
|
}
|
||||||
|
|
||||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
|
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||||
.get(entityTrackerEntry);
|
.get(entityTrackerEntry);
|
||||||
|
|
||||||
final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
final Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
|
|
||||||
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
|
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
|
||||||
|
|
||||||
for (final Object p : trackedPlayers) {
|
for (final Object p : trackedPlayers) {
|
||||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||||
|
|
||||||
if (disguise.getEntity() != player && disguise.canSee(player)) {
|
if (disguise.getEntity() != player && disguise.canSee(player)) {
|
||||||
clear.invoke(entityTrackerEntry, p);
|
clear.invoke(entityTrackerEntry, p);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
updatePlayer.invoke(entityTrackerEntry, p);
|
updatePlayer.invoke(entityTrackerEntry, p);
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 2);
|
catch (Exception ex) {
|
||||||
}
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
Exception ex) {
|
ex.printStackTrace();
|
||||||
ex.printStackTrace();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
@ -46,6 +47,14 @@ public class PacketListenerViewDisguises extends PacketAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!DisguiseAPI.isSelfDisguised(observer)) {
|
if (!DisguiseAPI.isSelfDisguised(observer)) {
|
||||||
|
if (event.getPacketType() == PacketType.Play.Server.ENTITY_METADATA) {
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise(observer, observer);
|
||||||
|
|
||||||
|
if (disguise != null && disguise.isSelfDisguiseVisible()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user