mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2025-01-06 19:09:27 +01:00
Reintroduce setCarpet on llama by acting as a middleman for body armor
This commit is contained in:
parent
7455d6e002
commit
3e24b5381a
@ -25,6 +25,10 @@ public enum AnimalColor {
|
||||
WHITE(DyeColor.WHITE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("BONE_MEAL") : null),
|
||||
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : Material.getMaterial("DANDELION_YELLOW"));
|
||||
|
||||
public Material getCarpetMaterial() {
|
||||
return Material.valueOf(name() + "_CARPET");
|
||||
}
|
||||
|
||||
public static AnimalColor getColorByWool(int woolId) {
|
||||
for (AnimalColor color : values()) {
|
||||
if (woolId != color.getDyeColor().getWoolData()) {
|
||||
|
@ -4,9 +4,10 @@ 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 me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class LlamaWatcher extends ChestedHorseWatcher {
|
||||
|
||||
@ -23,6 +24,22 @@ public class LlamaWatcher extends ChestedHorseWatcher {
|
||||
}
|
||||
|
||||
public DyeColor getCarpet() {
|
||||
if (NmsVersion.v1_20_R4.isSupported()) {
|
||||
ItemStack item = getEquipment().getItem(EquipmentSlot.BODY);
|
||||
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AnimalColor color = AnimalColor.getColorByWool(item.getType());
|
||||
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return color.getDyeColor();
|
||||
}
|
||||
|
||||
if (!hasValue(MetaIndex.LLAMA_CARPET) || getData(MetaIndex.LLAMA_CARPET) == -1) {
|
||||
return null;
|
||||
}
|
||||
@ -30,8 +47,19 @@ public class LlamaWatcher extends ChestedHorseWatcher {
|
||||
return AnimalColor.getColorByWool(getData(MetaIndex.LLAMA_CARPET)).getDyeColor();
|
||||
}
|
||||
|
||||
@NmsRemovedIn(NmsVersion.v1_20_R4)
|
||||
public void setCarpet(DyeColor dyeColor) {
|
||||
if (NmsVersion.v1_20_R4.isSupported()) {
|
||||
AnimalColor color = AnimalColor.getColor(dyeColor);
|
||||
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack item = new ItemStack(color.getCarpetMaterial());
|
||||
getEquipment().setItem(EquipmentSlot.BODY, item);
|
||||
return;
|
||||
}
|
||||
|
||||
sendData(MetaIndex.LLAMA_CARPET, dyeColor == null ? -1 : (int) dyeColor.getWoolData());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user