Add <Inherit> for player disguises name to inherit custom names from entities

This commit is contained in:
libraryaddict 2020-01-28 15:13:59 +13:00
parent 7ee65d26b2
commit 3a2e7602fb
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -15,6 +15,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup; import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -313,6 +314,16 @@ public class PlayerDisguise extends TargetedDisguise {
setSkin(gameProfile); setSkin(gameProfile);
} }
} }
if (getName().equals("<Inherit>") && getEntity() != null) {
String name = getEntity().getCustomName();
if (name == null || name.isEmpty()) {
name = getEntity().getType().name();
}
setName(name);
}
} }
boolean result = super.startDisguise(); boolean result = super.startDisguise();