Fix setCustomName
This commit is contained in:
parent
62b4408e21
commit
7efb85db7c
@ -117,6 +117,10 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMultiName(String... name) {
|
public void setMultiName(String... name) {
|
||||||
|
if (name.length == 1 && name[0].isEmpty()) {
|
||||||
|
name = new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
name = DisguiseUtilities.reverse(name);
|
name = DisguiseUtilities.reverse(name);
|
||||||
|
|
||||||
String[] oldName = multiName;
|
String[] oldName = multiName;
|
||||||
@ -939,7 +943,7 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMultiNameLength()> 0) {
|
if (getMultiNameLength() > 0) {
|
||||||
PacketContainer packet = new PacketContainer(Server.ENTITY_DESTROY);
|
PacketContainer packet = new PacketContainer(Server.ENTITY_DESTROY);
|
||||||
packet.getIntegerArrays().write(0, Arrays.copyOf(getArmorstandIds(), getMultiNameLength()));
|
packet.getIntegerArrays().write(0, Arrays.copyOf(getArmorstandIds(), getMultiNameLength()));
|
||||||
|
|
||||||
|
@ -256,7 +256,12 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomName() {
|
public String getCustomName() {
|
||||||
if (DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) {
|
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isOverrideCustomNames() &&
|
||||||
|
DisguiseConfig.isArmorstandsName()) {
|
||||||
|
if (getDisguise().getMultiNameLength() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return StringUtils.join(getDisguise().getMultiName(), "\n");
|
return StringUtils.join(getDisguise().getMultiName(), "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +281,8 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomName(String name) {
|
public void setCustomName(String name) {
|
||||||
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() &&
|
||||||
|
DisguiseConfig.isOverrideCustomNames()) {
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME)) {
|
if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME)) {
|
||||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.empty());
|
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.empty());
|
||||||
@ -289,7 +295,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == null) {
|
if (Strings.isNullOrEmpty(name)) {
|
||||||
getDisguise().setMultiName();
|
getDisguise().setMultiName();
|
||||||
} else {
|
} else {
|
||||||
getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name));
|
getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name));
|
||||||
|
@ -217,18 +217,22 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addWatcherDefault(Method setMethod, Method getMethod, Object object) {
|
private static void addWatcherDefault(Method setMethod, Method getMethod, Object object) {
|
||||||
Map.Entry<Method, Object> entry = new HashMap.SimpleEntry<>(getMethod, object);
|
|
||||||
|
|
||||||
if (defaultWatcherValues.containsKey(setMethod)) {
|
if (defaultWatcherValues.containsKey(setMethod)) {
|
||||||
Object dObj = defaultWatcherValues.get(setMethod);
|
Object dObj = defaultWatcherValues.get(setMethod).getValue();
|
||||||
|
|
||||||
if (!Objects.deepEquals(defaultWatcherValues.get(setMethod).getValue(), object)) {
|
if (!Objects.deepEquals(dObj, object)) {
|
||||||
throw new IllegalStateException(String.format("%s has conflicting values!", setMethod.getName()));
|
throw new IllegalStateException(String.format(
|
||||||
|
"%s has conflicting values! This means it expected the same value again but received a " +
|
||||||
|
"different value on a different disguise! %s is not the same as %s!", setMethod.getName(), object,
|
||||||
|
dObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map.Entry<Method, Object> entry = new HashMap.SimpleEntry<>(getMethod, object);
|
||||||
|
|
||||||
defaultWatcherValues.put(setMethod, entry);
|
defaultWatcherValues.put(setMethod, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user