本文整理汇总了Java中org.bukkit.entity.Horse.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java Horse.getColor方法的具体用法?Java Horse.getColor怎么用?Java Horse.getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Horse
的用法示例。
在下文中一共展示了Horse.getColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
@Override
protected boolean init(final @Nullable Class<? extends Horse> c, final @Nullable Horse e) {
if (e != null) {
variant = e.getVariant();
color = e.getColor();
style = e.getStyle();
}
return true;
}
示例2: EntityHorseData
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
public EntityHorseData(Horse horse) {
color = horse.getColor();
variant = horse.getVariant();
style = horse.getStyle();
saddle = horse.getInventory().getSaddle();
armor = horse.getInventory().getArmor();
domestication = horse.getDomestication();
maxDomestication = horse.getMaxDomestication();
jumpStrength = horse.getJumpStrength();
}
示例3: HorseAnimal
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
public HorseAnimal(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Horse, "org.bukkit.entity.Horse expected.");
Horse horse = (Horse) entity;
_color = horse.getColor();
_variant = horse.getVariant();
_style = horse.getStyle();
_domestication = horse.getDomestication();
_maxDomestication = horse.getMaxDomestication();
_hasChest = horse.isCarryingChest();
_jumpStrength = horse.getJumpStrength();
}
示例4: match
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
@Override
protected boolean match(final Horse entity) {
return (variant == null || variant == entity.getVariant())
&& (color == null || color == entity.getColor())
&& (style == null || style == entity.getStyle());
}
示例5: StoredEntity
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
StoredEntity(final SharedTablesModule module, final Entity entity) {
this.module = module;
this.id = StoredEntity.TEMP_ID;
this.type = module.getEntityType(entity).orElseThrow(() -> new IllegalStateException("Missing storedentitytype for entity type " + entity.getType().toString()));
if (entity.getCustomName() != null) { this.name = Optional.of(module.getOrCreateText(entity.getCustomName())); }
else { this.name = Optional.empty(); }
if (entity instanceof LivingEntity) {
LivingEntity living = (LivingEntity) entity;
this.maxHP = Optional.of(living.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
}
else { this.maxHP = Optional.empty(); }
if (entity instanceof Wolf) {
final Wolf wolf = (Wolf) entity;
this.color = Optional.of(module.getColor(wolf.getCollarColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + wolf.getCollarColor().name())));
this.horseStrength = Optional.empty();
this.armorType = Optional.empty();
}
else if (entity instanceof Sheep) {
final Sheep sheep = (Sheep) entity;
this.color = Optional.of(module.getColor(sheep.getColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + sheep.getColor().name())));
this.horseStrength = Optional.empty();
this.armorType = Optional.empty();
}
else if (entity instanceof Horse) {
final Horse horse = (Horse) entity;
if (horse.getColor() != null) { this.color = Optional.of(module.getColor(horse.getColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + horse.getColor().name()))); }
else { this.color = Optional.empty(); }
if (horse.getInventory() != null && horse.getInventory().getArmor() != null && horse.getInventory().getArmor().getType() != null) {
final Material armorTypeItem = horse.getInventory().getArmor().getType();
this.armorType = Optional.of(module.getArmor(armorTypeItem).orElseThrow(() -> new NoSuchElementException("Failed to find armortype for armor " + armorTypeItem.name())));
}
else { this.armorType = Optional.empty(); }
this.horseStrength = Optional.of(horse.getJumpStrength());
}
else {
this.color = Optional.empty();
this.horseStrength = Optional.empty();
this.armorType = Optional.empty();
}
final int uuidId = module.getDatabase().getUniqueIdStorage().getOrCreateId(entity.getUniqueId());//.orElseThrow(() -> new NoSuchElementException("Failed to retrieve storeduuid for entity " + entity.getUniqueId()));
this.uniqueId = new StoredUUID(uuidId, entity.getUniqueId());
this.createdAt = Instant.now();
}
示例6: update
import org.bukkit.entity.Horse; //导入方法依赖的package包/类
/**
* Updates the attributes of this {@link StoredEntity} instance based on the given entity.
* Note that the entity type of this instance will not be changed.
* @param entity The entity to take the attributes from.
*/
public void update(final Entity entity) {
Check.notNull(entity, "The entity in StoredEntity#update(Entity) cannot be null!");
// Update displayname
if (entity.getCustomName() != null) { this.name = Optional.of(this.module.getOrCreateText(entity.getCustomName())); }
else { this.name = Optional.empty(); }
// Update max hp
if (entity instanceof LivingEntity) { this.maxHP = Optional.of(((LivingEntity)entity).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); }
else { this.maxHP = Optional.empty(); }
// Update color
this.color = Optional.empty();
this.armorType = Optional.empty();
this.horseStrength = Optional.empty();
if (entity instanceof Wolf) {
final Wolf wolf = (Wolf) entity;
this.color = Optional.of(this.module.getColor(wolf.getCollarColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + wolf.getCollarColor().name())));
}
else if (entity instanceof Sheep) {
final Sheep sheep = (Sheep) entity;
this.color = Optional.of(this.module.getColor(sheep.getColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + sheep.getColor().name())));
}
else if (entity instanceof Horse) {
final Horse horse = (Horse) entity;
if (horse.getColor() != null) { this.color = Optional.of(this.module.getColor(horse.getColor().name()).orElseThrow(() -> new NoSuchElementException("Failed to find color " + horse.getColor().name()))); }
else { this.color = Optional.empty(); }
// Update armor
if (horse.getInventory() != null && horse.getInventory().getArmor() != null && horse.getInventory().getArmor().getType() != null) {
final Material armorTypeItem = horse.getInventory().getArmor().getType();
this.armorType = Optional.of(this.module.getArmor(armorTypeItem).orElseThrow(() -> new NoSuchElementException("Failed to find armortype for armor " + armorTypeItem.name())));
}
else { this.armorType = Optional.empty(); }
// Update horse jump strength
this.horseStrength = Optional.of(horse.getJumpStrength());
}
// Update uuid
if (!this.uniqueId.get().equals(entity.getUniqueId())) {
final int uuidId = this.module.getDatabase().getUniqueIdStorage().getOrCreateId(entity.getUniqueId());//.orElseThrow(() -> new NoSuchElementException("Failed to retrieve storeduuid for entity " + entity.getUniqueId()));
this.uniqueId = new StoredUUID(uuidId, entity.getUniqueId());
}
}