Try another fix for tablist
This commit is contained in:
parent
68a4f125e9
commit
d971ad5380
@ -530,7 +530,7 @@ public abstract class Disguise {
|
|||||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||||
NativeGameMode.SURVIVAL,
|
NativeGameMode.SURVIVAL,
|
||||||
WrappedChatComponent.fromText(((Player) getEntity()).getPlayerListName()))));
|
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
@ -59,7 +59,7 @@ public abstract class TargetedDisguise extends Disguise {
|
|||||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||||
.fromText(((Player) getEntity()).getPlayerListName()))));
|
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public abstract class TargetedDisguise extends Disguise {
|
|||||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||||
.fromText(((Player) getEntity()).getPlayerListName()))));
|
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,11 @@ import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
|||||||
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
||||||
import me.libraryaddict.disguise.utilities.backwards.BackwardsSupport;
|
import me.libraryaddict.disguise.utilities.backwards.BackwardsSupport;
|
||||||
import me.libraryaddict.disguise.utilities.json.*;
|
import me.libraryaddict.disguise.utilities.json.*;
|
||||||
import org.bukkit.*;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -46,7 +50,10 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.Array;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -58,7 +65,8 @@ public class DisguiseUtilities {
|
|||||||
*/
|
*/
|
||||||
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
|
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for
|
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only
|
||||||
|
* stay in for
|
||||||
* a max of a second.
|
* a max of a second.
|
||||||
*/
|
*/
|
||||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
||||||
@ -286,8 +294,8 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
checkConflicts(disguise, null);
|
checkConflicts(disguise, null);
|
||||||
|
|
||||||
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
||||||
.isModifyBoundingBox()) {
|
disguise.isModifyBoundingBox()) {
|
||||||
doBoundingBox(disguise);
|
doBoundingBox(disguise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,7 +355,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the
|
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure
|
||||||
|
* that the
|
||||||
* observers in the disguise don't see any other disguise.
|
* observers in the disguise don't see any other disguise.
|
||||||
*/
|
*/
|
||||||
public static void checkConflicts(TargetedDisguise disguise, String name) {
|
public static void checkConflicts(TargetedDisguise disguise, String name) {
|
||||||
@ -458,9 +467,10 @@ public class DisguiseUtilities {
|
|||||||
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
||||||
|
|
||||||
if (disguiseValues.getBabyBox() != null) {
|
if (disguiseValues.getBabyBox() != null) {
|
||||||
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher())
|
if ((disguise.getWatcher() instanceof AgeableWatcher &&
|
||||||
.isBaby()) || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise
|
((AgeableWatcher) disguise.getWatcher()).isBaby()) ||
|
||||||
.getWatcher()).isBaby())) {
|
(disguise.getWatcher() instanceof ZombieWatcher &&
|
||||||
|
((ZombieWatcher) disguise.getWatcher()).isBaby())) {
|
||||||
disguiseBox = disguiseValues.getBabyBox();
|
disguiseBox = disguiseValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,8 +482,8 @@ public class DisguiseUtilities {
|
|||||||
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
||||||
|
|
||||||
if (entityValues.getBabyBox() != null) {
|
if (entityValues.getBabyBox() != null) {
|
||||||
if ((entity instanceof Ageable && !((Ageable) entity)
|
if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) ||
|
||||||
.isAdult()) || (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
(entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
||||||
entityBox = entityValues.getBabyBox();
|
entityBox = entityValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,8 +703,8 @@ public class DisguiseUtilities {
|
|||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName()
|
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName()
|
||||||
.equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) || !gameProfile
|
.equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) ||
|
||||||
.getProperties().isEmpty())) {
|
!gameProfile.getProperties().isEmpty())) {
|
||||||
disguise.setGameProfile(gameProfile);
|
disguise.setGameProfile(gameProfile);
|
||||||
|
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
@ -720,7 +730,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does
|
||||||
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
|
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
|
||||||
@ -728,7 +739,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does
|
||||||
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn,
|
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn,
|
||||||
@ -790,9 +802,8 @@ public class DisguiseUtilities {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
runnables.remove(playerName);
|
runnables.remove(playerName);
|
||||||
|
|
||||||
System.out
|
System.out.print("[LibsDisguises] Error when fetching " + playerName +
|
||||||
.print("[LibsDisguises] Error when fetching " + playerName + "'s uuid from mojang: " + e
|
"'s uuid from mojang: " + e.getMessage());
|
||||||
.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -813,7 +824,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does
|
||||||
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
|
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
|
||||||
@ -821,7 +833,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
|
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does
|
||||||
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn,
|
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn,
|
||||||
@ -916,9 +929,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDisguiseInUse(Disguise disguise) {
|
public static boolean isDisguiseInUse(Disguise disguise) {
|
||||||
return disguise.getEntity() != null && getDisguises()
|
return disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId()) &&
|
||||||
.containsKey(disguise.getEntity().getUniqueId()) && getDisguises()
|
getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise);
|
||||||
.get(disguise.getEntity().getUniqueId()).contains(disguise);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -941,8 +953,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && ((Player) disguise.getEntity())
|
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player &&
|
||||||
.getName().equalsIgnoreCase(player)) {
|
((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
|
||||||
removeSelfDisguise((Player) disguise.getEntity());
|
removeSelfDisguise((Player) disguise.getEntity());
|
||||||
|
|
||||||
if (disguise.isSelfDisguiseVisible()) {
|
if (disguise.isSelfDisguiseVisible()) {
|
||||||
@ -1153,8 +1165,8 @@ public class DisguiseUtilities {
|
|||||||
getDisguises().remove(entityId);
|
getDisguises().remove(entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
||||||
.isModifyBoundingBox()) {
|
disguise.isModifyBoundingBox()) {
|
||||||
doBoundingBox(disguise);
|
doBoundingBox(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1276,8 +1288,8 @@ public class DisguiseUtilities {
|
|||||||
throw new IllegalStateException("Cannot modify disguises on an async thread");
|
throw new IllegalStateException("Cannot modify disguises on an async thread");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise
|
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() ||
|
||||||
.isSelfDisguiseVisible() || !disguise.canSee(player)) {
|
!disguise.isSelfDisguiseVisible() || !disguise.canSee(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1318,8 +1330,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the player is in a team already and the team isn't one controlled by Lib's Disguises
|
// If the player is in a team already and the team isn't one controlled by Lib's Disguises
|
||||||
if (prevTeam != null && !(prevTeam.getName().equals("LD Pushing") || prevTeam.getName()
|
if (prevTeam != null &&
|
||||||
.endsWith("_LDP"))) {
|
!(prevTeam.getName().equals("LD Pushing") || prevTeam.getName().endsWith("_LDP"))) {
|
||||||
// If we're creating a scoreboard
|
// If we're creating a scoreboard
|
||||||
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
if (pOption == DisguisePushing.CREATE_SCOREBOARD) {
|
||||||
// Remember his old team so we can give him it back later
|
// Remember his old team so we can give him it back later
|
||||||
@ -1407,10 +1419,10 @@ public class DisguiseUtilities {
|
|||||||
// Send the velocity packets
|
// Send the velocity packets
|
||||||
if (isMoving) {
|
if (isMoving) {
|
||||||
Vector velocity = player.getVelocity();
|
Vector velocity = player.getVelocity();
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player, manager
|
||||||
manager.createPacketConstructor(Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(),
|
.createPacketConstructor(Server.ENTITY_VELOCITY, player.getEntityId(), velocity.getX(),
|
||||||
velocity.getY(), velocity.getZ())
|
velocity.getY(), velocity.getZ())
|
||||||
.createPacket(player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ()));
|
.createPacket(player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Why the hell would he even need this. Meh.
|
// Why the hell would he even need this. Meh.
|
||||||
@ -1478,6 +1490,10 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPlayerListName(Player player) {
|
||||||
|
return Strings.isEmpty(player.getPlayerListName()) ? player.getName() : player.getPlayerListName();
|
||||||
|
}
|
||||||
|
|
||||||
public static LibsDisguises getPlugin() {
|
public static LibsDisguises getPlugin() {
|
||||||
return libsDisguises;
|
return libsDisguises;
|
||||||
}
|
}
|
||||||
@ -1523,8 +1539,8 @@ public class DisguiseUtilities {
|
|||||||
Entity e = disguise.getEntity();
|
Entity e = disguise.getEntity();
|
||||||
|
|
||||||
// If the disguises entity is null, or the disguised entity isn't a player return
|
// If the disguises entity is null, or the disguised entity isn't a player return
|
||||||
if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) || !getDisguises()
|
if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) ||
|
||||||
.get(e.getUniqueId()).contains(disguise)) {
|
!getDisguises().get(e.getUniqueId()).contains(disguise)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1539,8 +1555,8 @@ public class DisguiseUtilities {
|
|||||||
DisguiseUtilities.removeSelfDisguise(player);
|
DisguiseUtilities.removeSelfDisguise(player);
|
||||||
|
|
||||||
// If the disguised player can't see himself. Return
|
// If the disguised player can't see himself. Return
|
||||||
if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() || player
|
if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() ||
|
||||||
.getVehicle() != null) {
|
player.getVehicle() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user