Update dynamic name for non-player disguises

This commit is contained in:
libraryaddict 2020-05-11 15:22:02 +12:00
parent 0fe54d6683
commit f6eb0f14b7
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
2 changed files with 25 additions and 7 deletions

View File

@ -102,6 +102,9 @@ public abstract class Disguise {
private boolean tallDisguisesVisible = DisguiseConfig.isTallSelfDisguises();
private String[] multiName = new String[0];
private transient int[] armorstandIds = new int[0];
@Getter
@Setter
private boolean dynamicName;
public Disguise(DisguiseType disguiseType) {
this.disguiseType = disguiseType;
@ -126,6 +129,10 @@ public abstract class Disguise {
String[] oldName = multiName;
multiName = name;
if (Arrays.equals(oldName, name)) {
return;
}
if (!isDisguiseInUse()) {
return;
}
@ -192,6 +199,7 @@ public abstract class Disguise {
disguise.setVelocitySent(isVelocitySent());
disguise.setModifyBoundingBox(isModifyBoundingBox());
disguise.multiName = Arrays.copyOf(multiName, multiName.length);
disguise.setDynamicName(isDynamicName());
if (getWatcher() != null) {
disguise.setWatcher(getWatcher().clone(disguise));
@ -367,16 +375,20 @@ public abstract class Disguise {
new ComponentBuilder(LibsMsg.ACTION_BAR_MESSAGE.get(getDisguiseName())).create());
}
if (Disguise.this instanceof PlayerDisguise && ((PlayerDisguise) Disguise.this).isDynamicName()) {
if (isDynamicName()) {
String name = getEntity().getCustomName();
if (name == null) {
name = "";
}
if (isPlayerDisguise()) {
if (!((PlayerDisguise) Disguise.this).getName().equals(name)) {
((PlayerDisguise) Disguise.this).setName(name);
}
} else {
getWatcher().setCustomName(name);
}
}
}
@ -1161,6 +1173,16 @@ public abstract class Disguise {
System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(330));
}
if (isDynamicName() && !isPlayerDisguise()) {
String name = getEntity().getCustomName();
if (name == null) {
name = "";
}
getWatcher().setCustomName(name);
}
makeBossBar();
return true;

View File

@ -31,9 +31,6 @@ public class PlayerDisguise extends TargetedDisguise {
*/
private boolean explicitNameVisible = false;
private UUID uuid = UUID.randomUUID();
@Getter
@Setter
private boolean dynamicName;
private volatile DisguiseUtilities.DScoreTeam scoreboardName;
@Getter
private boolean upsideDown;
@ -226,7 +223,6 @@ public class PlayerDisguise extends TargetedDisguise {
disguise.setName(getName());
disguise.nameVisible = isNameVisible();
disguise.explicitNameVisible = explicitNameVisible;
disguise.setDynamicName(isDynamicName());
disguise.setUpsideDown(isUpsideDown());
clone(disguise);