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

View File

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

View File

@ -603,7 +603,20 @@ public class PlayerDisguise extends TargetedDisguise {
@Override @Override
public PlayerDisguise setEntity(Entity entity) { 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 @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. # If you are getting issues using this, please do not report them. You disable this at your own risk.
RandomUUIDs: true 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! # 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. # Disclaimer: If you enable this, you are responsible for ensuring PacketEvents is up to date.
NeverUpdatePacketEvents: false NeverUpdatePacketEvents: false