mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-10 09:21:31 +01:00
Add support for villager stats to blueprints.
https://github.com/BentoBoxWorld/BentoBox/issues/1695
This commit is contained in:
parent
a8473c27a9
commit
3a8c1e7df0
@ -26,6 +26,7 @@ import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Attachable;
|
||||
@ -194,6 +195,9 @@ public class BlueprintClipboard {
|
||||
BlueprintEntity bpe = new BlueprintEntity();
|
||||
bpe.setType(entity.getType());
|
||||
bpe.setCustomName(entity.getCustomName());
|
||||
if (entity instanceof Villager) {
|
||||
setVillager(entity, bpe);
|
||||
}
|
||||
if (entity instanceof Colorable) {
|
||||
Colorable c = (Colorable)entity;
|
||||
if (c.getColor() != null) {
|
||||
@ -301,6 +305,19 @@ public class BlueprintClipboard {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the villager stats
|
||||
* @param entity - villager
|
||||
* @param bpe - Blueprint Entity
|
||||
*/
|
||||
private void setVillager(LivingEntity entity, BlueprintEntity bpe) {
|
||||
Villager v = (Villager)entity;
|
||||
bpe.setExperience(v.getVillagerExperience());
|
||||
bpe.setLevel(v.getVillagerLevel());
|
||||
bpe.setProfession(v.getProfession());
|
||||
bpe.setVillagerType(v.getVillagerType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the origin
|
||||
*/
|
||||
|
@ -11,6 +11,8 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
@ -40,11 +42,23 @@ public class BlueprintEntity {
|
||||
private Map<Integer, ItemStack> inventory;
|
||||
@Expose
|
||||
private Style style;
|
||||
@Expose
|
||||
private Integer level;
|
||||
@Expose
|
||||
private Profession profession;
|
||||
@Expose
|
||||
private Integer experience;
|
||||
@Expose
|
||||
private Villager.Type villagerType;
|
||||
|
||||
|
||||
/**
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public void configureEntity(Entity e) {
|
||||
if (e instanceof Villager) {
|
||||
setVillager(e);
|
||||
}
|
||||
if (e instanceof Colorable) {
|
||||
((Colorable) e).setColor(color);
|
||||
}
|
||||
@ -73,6 +87,19 @@ public class BlueprintEntity {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e - villager
|
||||
* @since 1.16.0
|
||||
*/
|
||||
private void setVillager(Entity e) {
|
||||
Villager v = (Villager)e;
|
||||
v.setProfession(profession == null ? Profession.NONE : profession);
|
||||
v.setVillagerExperience(experience == null ? 0 : experience);
|
||||
v.setVillagerLevel(level == null ? 0 : level);
|
||||
v.setVillagerType(villagerType == null ? Villager.Type.PLAINS : villagerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the color
|
||||
*/
|
||||
@ -181,4 +208,68 @@ public class BlueprintEntity {
|
||||
public void setStyle(Style style) {
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param level the level to set
|
||||
*/
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the profession
|
||||
*/
|
||||
public Profession getProfession() {
|
||||
return profession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param profession the profession to set
|
||||
*/
|
||||
public void setProfession(Profession profession) {
|
||||
this.profession = profession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the experience
|
||||
*/
|
||||
public Integer getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param experience the experience to set
|
||||
*/
|
||||
public void setExperience(Integer experience) {
|
||||
this.experience = experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the villagerType
|
||||
*/
|
||||
public Villager.Type getVillagerType() {
|
||||
return villagerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param villagerType the villagerType to set
|
||||
*/
|
||||
public void setVillagerType(Villager.Type villagerType) {
|
||||
this.villagerType = villagerType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param domestication the domestication to set
|
||||
*/
|
||||
public void setDomestication(Integer domestication) {
|
||||
this.domestication = domestication;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user