Fix setCustomName
This commit is contained in:
		| @@ -117,6 +117,10 @@ public abstract class Disguise { | ||||
|     } | ||||
|  | ||||
|     public void setMultiName(String... name) { | ||||
|         if (name.length == 1 && name[0].isEmpty()) { | ||||
|             name = new String[0]; | ||||
|         } | ||||
|  | ||||
|         name = DisguiseUtilities.reverse(name); | ||||
|  | ||||
|         String[] oldName = multiName; | ||||
|   | ||||
| @@ -256,7 +256,12 @@ public class FlagWatcher { | ||||
|     } | ||||
|  | ||||
|     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"); | ||||
|         } | ||||
|  | ||||
| @@ -276,7 +281,8 @@ public class FlagWatcher { | ||||
|     } | ||||
|  | ||||
|     public void setCustomName(String name) { | ||||
|         if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) { | ||||
|         if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() && | ||||
|                 DisguiseConfig.isOverrideCustomNames()) { | ||||
|             if (NmsVersion.v1_13.isSupported()) { | ||||
|                 if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME)) { | ||||
|                     setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.empty()); | ||||
| @@ -289,7 +295,7 @@ public class FlagWatcher { | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (name == null) { | ||||
|             if (Strings.isNullOrEmpty(name)) { | ||||
|                 getDisguise().setMultiName(); | ||||
|             } else { | ||||
|                 getDisguise().setMultiName(DisguiseUtilities.splitNewLine(name)); | ||||
|   | ||||
| @@ -217,18 +217,22 @@ public class DisguiseParser { | ||||
|     } | ||||
|  | ||||
|     private static void addWatcherDefault(Method setMethod, Method getMethod, Object object) { | ||||
|         Map.Entry<Method, Object> entry = new HashMap.SimpleEntry<>(getMethod, object); | ||||
|  | ||||
|         if (defaultWatcherValues.containsKey(setMethod)) { | ||||
|             Object dObj = defaultWatcherValues.get(setMethod); | ||||
|             Object dObj = defaultWatcherValues.get(setMethod).getValue(); | ||||
|  | ||||
|             if (!Objects.deepEquals(defaultWatcherValues.get(setMethod).getValue(), object)) { | ||||
|                 throw new IllegalStateException(String.format("%s has conflicting values!", setMethod.getName())); | ||||
|             if (!Objects.deepEquals(dObj, object)) { | ||||
|                 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; | ||||
|         } | ||||
|  | ||||
|         Map.Entry<Method, Object> entry = new HashMap.SimpleEntry<>(getMethod, object); | ||||
|  | ||||
|         defaultWatcherValues.put(setMethod, entry); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user