Add uuid change for possible compatibility with voice chat

This commit is contained in:
libraryaddict 2024-07-14 09:39:26 +12:00
parent c3bd465250
commit a9152f7689
4 changed files with 33 additions and 12 deletions

View File

@ -297,6 +297,9 @@ public class DisguiseConfig {
@Getter
@Setter
private static double scaleSelfDisguisesMax;
@Getter
@Setter
private static boolean uniquePlayerDisguiseUUIDs;
public static boolean isArmorstandsName() {
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
@ -700,6 +703,7 @@ public class DisguiseConfig {
setRemoveDisguiseBlockPlace(config.getBoolean("UndisguiseOnBlockPlace"));
String apiKey = config.getString("MineSkinAPIKey");
setSoundsEnabled(config.getBoolean("DisguiseSounds"));
setUniquePlayerDisguiseUUIDs(config.getBoolean("UniquePlayerUUID"));
if (apiKey != null && apiKey.matches("[a-zA-Z\\d]{8,}")) {
DisguiseUtilities.getMineSkinAPI().setApiKey(apiKey);

View File

@ -63,6 +63,13 @@ public abstract class Disguise {
private transient boolean disguiseInUse;
private final DisguiseType disguiseType;
private transient BukkitRunnable runnable;
/**
* -- GETTER --
* Get the disguised entity
*
* @return entity
*/
@Getter
private transient Entity entity;
private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced();
private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf();
@ -136,8 +143,11 @@ public abstract class Disguise {
}
public UUID getUUID() {
if (!isPlayerDisguise() && !DisguiseConfig.isRandomUUIDS() && getEntity() != null) {
return getEntity().getUniqueId();
// If this is not a player disguise, or it is but we're not trying to make sure its unique
if (!isPlayerDisguise() || !DisguiseConfig.isUniquePlayerDisguiseUUIDs()) {
if (!DisguiseConfig.isRandomUUIDS() && getEntity() != null) {
return getEntity().getUniqueId();
}
}
// Partial fix for disguises serialized in older versions
@ -481,15 +491,6 @@ public abstract class Disguise {
runnable.runTaskTimer(LibsDisguises.getInstance(), 1, 1);
}
/**
* Get the disguised entity
*
* @return entity
*/
public Entity getEntity() {
return entity;
}
/**
* Set the entity of the disguise. Only used for internal things.
*

View File

@ -603,7 +603,20 @@ public class PlayerDisguise extends TargetedDisguise {
@Override
public PlayerDisguise setEntity(Entity entity) {
return (PlayerDisguise) super.setEntity(entity);
super.setEntity(entity);
// Here we're making sure that the userprofile is constructed with the correct UUID, but only if the disguise isn't active yet
// If disguise is already active, or if entity is null, or userprofile wasn't constructed yet, or the user profile is already set
// to the correct uuid
if (isDisguiseInUse() || entity == null || userProfile == null || getUUID().equals(userProfile.getUUID())) {
return this;
}
// Otherwise, recreate the user profile!
userProfile = ReflectionManager.getUserProfileWithThisSkin(getUUID(), userProfile.getName(), userProfile);
return this;
}
@Override

View File

@ -45,6 +45,9 @@ SaddleableHorse: false
# If you are getting issues using this, please do not report them. You disable this at your own risk.
RandomUUIDs: true
# Player disguises by default generate a unique UUID per disguise, this will disable it if 'false' and may create issues
UniquePlayerUUID: true
# When you for some strange reason don't want PacketEvents to update, enable this!
# Disclaimer: If you enable this, you are responsible for ensuring PacketEvents is up to date.
NeverUpdatePacketEvents: false