Fix rainbow wool on sheep self disguises not working

This commit is contained in:
libraryaddict 2023-03-20 07:13:28 +13:00
parent 16c294ae6f
commit 7cff37eebc
2 changed files with 22 additions and 3 deletions

View File

@ -855,8 +855,8 @@ public abstract class Disguise {
}
// Sometimes someone may set the custom name stuff on the actual player... Normally harmless, until I come along..
if (getEntity() instanceof Player && !getWatcher().hasCustomName() && !getWatcher().isUpsideDown() &&
(!(getWatcher() instanceof SheepWatcher) || !((SheepWatcher) getWatcher()).isRainbowWool())) {
if (getEntity() instanceof Player && !getWatcher().hasCustomName() && !isUpsideDown() &&
!(getWatcher() instanceof SheepWatcher && ((SheepWatcher) getWatcher()).isRainbowWool())) {
getWatcher().setInteralCustomName("");
getWatcher().setInternalCustomNameVisible(false);
}

View File

@ -1,10 +1,14 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.DyeColor;
import java.util.Optional;
public class SheepWatcher extends AgeableWatcher {
public SheepWatcher(Disguise disguise) {
@ -28,7 +32,22 @@ public class SheepWatcher extends AgeableWatcher {
}
public boolean isRainbowWool() {
return "jeb_".equals(getCustomName());
if (!NmsVersion.v1_13.isSupported()) {
if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME_OLD)) {
return false;
}
return "jeb_".equals(getData(MetaIndex.ENTITY_CUSTOM_NAME_OLD));
}
if (!hasValue(MetaIndex.ENTITY_CUSTOM_NAME)) {
return false;
}
Optional<WrappedChatComponent> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
return optional.filter(wrappedChatComponent -> "{\"text\":\"jeb_\"}".equals(wrappedChatComponent.getJson())).isPresent();
}
public void setRainbowWool(boolean rainbow) {